.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * VMware VMCI Driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2012 VMware, Inc. All rights reserved. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify it |
---|
7 | | - * under the terms of the GNU General Public License as published by the |
---|
8 | | - * Free Software Foundation version 2 and no later version. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, but |
---|
11 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
---|
12 | | - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
13 | | - * for more details. |
---|
14 | 6 | */ |
---|
15 | 7 | |
---|
16 | 8 | #include <linux/vmw_vmci_defs.h> |
---|
.. | .. |
---|
63 | 55 | void *notification_bitmap; |
---|
64 | 56 | dma_addr_t notification_base; |
---|
65 | 57 | }; |
---|
| 58 | + |
---|
| 59 | +static bool use_ppn64; |
---|
| 60 | + |
---|
| 61 | +bool vmci_use_ppn64(void) |
---|
| 62 | +{ |
---|
| 63 | + return use_ppn64; |
---|
| 64 | +} |
---|
66 | 65 | |
---|
67 | 66 | /* vmci_dev singleton device and supporting data*/ |
---|
68 | 67 | struct pci_dev *vmci_pdev; |
---|
.. | .. |
---|
432 | 431 | struct vmci_guest_device *vmci_dev; |
---|
433 | 432 | void __iomem *iobase; |
---|
434 | 433 | unsigned int capabilities; |
---|
| 434 | + unsigned int caps_in_use; |
---|
435 | 435 | unsigned long cmd; |
---|
436 | 436 | int vmci_err; |
---|
437 | 437 | int error; |
---|
.. | .. |
---|
496 | 496 | error = -ENXIO; |
---|
497 | 497 | goto err_free_data_buffer; |
---|
498 | 498 | } |
---|
| 499 | + caps_in_use = VMCI_CAPS_DATAGRAM; |
---|
| 500 | + |
---|
| 501 | + /* |
---|
| 502 | + * Use 64-bit PPNs if the device supports. |
---|
| 503 | + * |
---|
| 504 | + * There is no check for the return value of dma_set_mask_and_coherent |
---|
| 505 | + * since this driver can handle the default mask values if |
---|
| 506 | + * dma_set_mask_and_coherent fails. |
---|
| 507 | + */ |
---|
| 508 | + if (capabilities & VMCI_CAPS_PPN64) { |
---|
| 509 | + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); |
---|
| 510 | + use_ppn64 = true; |
---|
| 511 | + caps_in_use |= VMCI_CAPS_PPN64; |
---|
| 512 | + } else { |
---|
| 513 | + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(44)); |
---|
| 514 | + use_ppn64 = false; |
---|
| 515 | + } |
---|
499 | 516 | |
---|
500 | 517 | /* |
---|
501 | 518 | * If the hardware supports notifications, we will use that as |
---|
.. | .. |
---|
510 | 527 | "Unable to allocate notification bitmap\n"); |
---|
511 | 528 | } else { |
---|
512 | 529 | memset(vmci_dev->notification_bitmap, 0, PAGE_SIZE); |
---|
513 | | - capabilities |= VMCI_CAPS_NOTIFICATIONS; |
---|
| 530 | + caps_in_use |= VMCI_CAPS_NOTIFICATIONS; |
---|
514 | 531 | } |
---|
515 | 532 | } |
---|
516 | 533 | |
---|
517 | | - dev_info(&pdev->dev, "Using capabilities 0x%x\n", capabilities); |
---|
| 534 | + dev_info(&pdev->dev, "Using capabilities 0x%x\n", caps_in_use); |
---|
518 | 535 | |
---|
519 | 536 | /* Let the host know which capabilities we intend to use. */ |
---|
520 | | - iowrite32(capabilities, vmci_dev->iobase + VMCI_CAPS_ADDR); |
---|
| 537 | + iowrite32(caps_in_use, vmci_dev->iobase + VMCI_CAPS_ADDR); |
---|
521 | 538 | |
---|
522 | 539 | /* Set up global device so that we can start sending datagrams */ |
---|
523 | 540 | spin_lock_irq(&vmci_dev_spinlock); |
---|
.. | .. |
---|
529 | 546 | * Register notification bitmap with device if that capability is |
---|
530 | 547 | * used. |
---|
531 | 548 | */ |
---|
532 | | - if (capabilities & VMCI_CAPS_NOTIFICATIONS) { |
---|
| 549 | + if (caps_in_use & VMCI_CAPS_NOTIFICATIONS) { |
---|
533 | 550 | unsigned long bitmap_ppn = |
---|
534 | 551 | vmci_dev->notification_base >> PAGE_SHIFT; |
---|
535 | 552 | if (!vmci_dbell_register_notification_bitmap(bitmap_ppn)) { |
---|
536 | 553 | dev_warn(&pdev->dev, |
---|
537 | | - "VMCI device unable to register notification bitmap with PPN 0x%x\n", |
---|
538 | | - (u32) bitmap_ppn); |
---|
| 554 | + "VMCI device unable to register notification bitmap with PPN 0x%lx\n", |
---|
| 555 | + bitmap_ppn); |
---|
539 | 556 | error = -ENXIO; |
---|
540 | 557 | goto err_remove_vmci_dev_g; |
---|
541 | 558 | } |
---|
.. | .. |
---|
611 | 628 | |
---|
612 | 629 | /* Enable specific interrupt bits. */ |
---|
613 | 630 | cmd = VMCI_IMR_DATAGRAM; |
---|
614 | | - if (capabilities & VMCI_CAPS_NOTIFICATIONS) |
---|
| 631 | + if (caps_in_use & VMCI_CAPS_NOTIFICATIONS) |
---|
615 | 632 | cmd |= VMCI_IMR_NOTIFICATION; |
---|
616 | 633 | iowrite32(cmd, vmci_dev->iobase + VMCI_IMR_ADDR); |
---|
617 | 634 | |
---|
.. | .. |
---|
620 | 637 | vmci_dev->iobase + VMCI_CONTROL_ADDR); |
---|
621 | 638 | |
---|
622 | 639 | pci_set_drvdata(pdev, vmci_dev); |
---|
| 640 | + |
---|
| 641 | + vmci_call_vsock_callback(false); |
---|
623 | 642 | return 0; |
---|
624 | 643 | |
---|
625 | 644 | err_free_irq: |
---|