Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'vfio-v4.15-rc1' of git://github.com/awilliam/linux-vfio

Pull VFIO updates from Alex Williamson:

- Virtualize PCI MPS and MRRS registers

- Avoid soft lockups on SPAPR when clearing TCE

- Broadcom FlexRM platform device support

- Samples driver cleanup & type1 integer overflow fix

* tag 'vfio-v4.15-rc1' of git://github.com/awilliam/linux-vfio:
vfio: platform: reset: Add Broadcom FlexRM reset module
vfio/type1: silence integer overflow warning
vfio-mdev/samples: make mdev_fops const and static
vfio/spapr: Add cond_resched() for huge updates
vfio/pci: Virtualize Maximum Read Request Size
vfio/pci: Virtualize Maximum Payload Size

+157 -4
+28 -3
drivers/vfio/pci/vfio_pci_config.c
··· 808 808 { 809 809 __le16 *ctrl = (__le16 *)(vdev->vconfig + pos - 810 810 offset + PCI_EXP_DEVCTL); 811 + int readrq = le16_to_cpu(*ctrl) & PCI_EXP_DEVCTL_READRQ; 811 812 812 813 count = vfio_default_config_write(vdev, pos, count, perm, offset, val); 813 814 if (count < 0) ··· 834 833 pci_try_reset_function(vdev->pdev); 835 834 } 836 835 836 + /* 837 + * MPS is virtualized to the user, writes do not change the physical 838 + * register since determining a proper MPS value requires a system wide 839 + * device view. The MRRS is largely independent of MPS, but since the 840 + * user does not have that system-wide view, they might set a safe, but 841 + * inefficiently low value. Here we allow writes through to hardware, 842 + * but we set the floor to the physical device MPS setting, so that 843 + * we can at least use full TLPs, as defined by the MPS value. 844 + * 845 + * NB, if any devices actually depend on an artificially low MRRS 846 + * setting, this will need to be revisited, perhaps with a quirk 847 + * though pcie_set_readrq(). 848 + */ 849 + if (readrq != (le16_to_cpu(*ctrl) & PCI_EXP_DEVCTL_READRQ)) { 850 + readrq = 128 << 851 + ((le16_to_cpu(*ctrl) & PCI_EXP_DEVCTL_READRQ) >> 12); 852 + readrq = max(readrq, pcie_get_mps(vdev->pdev)); 853 + 854 + pcie_set_readrq(vdev->pdev, readrq); 855 + } 856 + 837 857 return count; 838 858 } 839 859 ··· 871 849 872 850 /* 873 851 * Allow writes to device control fields, except devctl_phantom, 874 - * which could confuse IOMMU, and the ARI bit in devctl2, which 875 - * is set at probe time. FLR gets virtualized via our writefn. 852 + * which could confuse IOMMU, MPS, which can break communication 853 + * with other physical devices, and the ARI bit in devctl2, which 854 + * is set at probe time. FLR and MRRS get virtualized via our 855 + * writefn. 876 856 */ 877 857 p_setw(perm, PCI_EXP_DEVCTL, 878 - PCI_EXP_DEVCTL_BCR_FLR, ~PCI_EXP_DEVCTL_PHANTOM); 858 + PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_PAYLOAD | 859 + PCI_EXP_DEVCTL_READRQ, ~PCI_EXP_DEVCTL_PHANTOM); 879 860 p_setw(perm, PCI_EXP_DEVCTL2, NO_VIRT, ~PCI_EXP_DEVCTL2_ARI); 880 861 return 0; 881 862 }
+9
drivers/vfio/platform/reset/Kconfig
··· 13 13 Enables the VFIO platform driver to handle reset for AMD XGBE 14 14 15 15 If you don't know what to do here, say N. 16 + 17 + config VFIO_PLATFORM_BCMFLEXRM_RESET 18 + tristate "VFIO support for Broadcom FlexRM reset" 19 + depends on VFIO_PLATFORM && (ARCH_BCM_IPROC || COMPILE_TEST) 20 + default ARCH_BCM_IPROC 21 + help 22 + Enables the VFIO platform driver to handle reset for Broadcom FlexRM 23 + 24 + If you don't know what to do here, say N.
+1
drivers/vfio/platform/reset/Makefile
··· 6 6 7 7 obj-$(CONFIG_VFIO_PLATFORM_CALXEDAXGMAC_RESET) += vfio-platform-calxedaxgmac.o 8 8 obj-$(CONFIG_VFIO_PLATFORM_AMDXGBE_RESET) += vfio-platform-amdxgbe.o 9 + obj-$(CONFIG_VFIO_PLATFORM_BCMFLEXRM_RESET) += vfio_platform_bcmflexrm.o
+113
drivers/vfio/platform/reset/vfio_platform_bcmflexrm.c
··· 1 + /* 2 + * Copyright (C) 2017 Broadcom 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License as 6 + * published by the Free Software Foundation version 2. 7 + * 8 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 9 + * kind, whether express or implied; without even the implied warranty 10 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + */ 13 + 14 + /* 15 + * This driver provides reset support for Broadcom FlexRM ring manager 16 + * to VFIO platform. 17 + */ 18 + 19 + #include <linux/delay.h> 20 + #include <linux/device.h> 21 + #include <linux/init.h> 22 + #include <linux/io.h> 23 + #include <linux/kernel.h> 24 + #include <linux/module.h> 25 + 26 + #include "vfio_platform_private.h" 27 + 28 + /* FlexRM configuration */ 29 + #define RING_REGS_SIZE 0x10000 30 + #define RING_VER_MAGIC 0x76303031 31 + 32 + /* Per-Ring register offsets */ 33 + #define RING_VER 0x000 34 + #define RING_CONTROL 0x034 35 + #define RING_FLUSH_DONE 0x038 36 + 37 + /* Register RING_CONTROL fields */ 38 + #define CONTROL_FLUSH_SHIFT 5 39 + 40 + /* Register RING_FLUSH_DONE fields */ 41 + #define FLUSH_DONE_MASK 0x1 42 + 43 + static int vfio_platform_bcmflexrm_shutdown(void __iomem *ring) 44 + { 45 + unsigned int timeout; 46 + 47 + /* Disable/inactivate ring */ 48 + writel_relaxed(0x0, ring + RING_CONTROL); 49 + 50 + /* Set ring flush state */ 51 + timeout = 1000; /* timeout of 1s */ 52 + writel_relaxed(BIT(CONTROL_FLUSH_SHIFT), ring + RING_CONTROL); 53 + do { 54 + if (readl_relaxed(ring + RING_FLUSH_DONE) & 55 + FLUSH_DONE_MASK) 56 + break; 57 + mdelay(1); 58 + } while (--timeout); 59 + if (!timeout) 60 + return -ETIMEDOUT; 61 + 62 + /* Clear ring flush state */ 63 + timeout = 1000; /* timeout of 1s */ 64 + writel_relaxed(0x0, ring + RING_CONTROL); 65 + do { 66 + if (!(readl_relaxed(ring + RING_FLUSH_DONE) & 67 + FLUSH_DONE_MASK)) 68 + break; 69 + mdelay(1); 70 + } while (--timeout); 71 + if (!timeout) 72 + return -ETIMEDOUT; 73 + 74 + return 0; 75 + } 76 + 77 + static int vfio_platform_bcmflexrm_reset(struct vfio_platform_device *vdev) 78 + { 79 + void __iomem *ring; 80 + int rc = 0, ret = 0, ring_num = 0; 81 + struct vfio_platform_region *reg = &vdev->regions[0]; 82 + 83 + /* Map FlexRM ring registers if not mapped */ 84 + if (!reg->ioaddr) { 85 + reg->ioaddr = ioremap_nocache(reg->addr, reg->size); 86 + if (!reg->ioaddr) 87 + return -ENOMEM; 88 + } 89 + 90 + /* Discover and shutdown each FlexRM ring */ 91 + for (ring = reg->ioaddr; 92 + ring < (reg->ioaddr + reg->size); ring += RING_REGS_SIZE) { 93 + if (readl_relaxed(ring + RING_VER) == RING_VER_MAGIC) { 94 + rc = vfio_platform_bcmflexrm_shutdown(ring); 95 + if (rc) { 96 + dev_warn(vdev->device, 97 + "FlexRM ring%d shutdown error %d\n", 98 + ring_num, rc); 99 + ret |= rc; 100 + } 101 + ring_num++; 102 + } 103 + } 104 + 105 + return ret; 106 + } 107 + 108 + module_vfio_reset_handler("brcm,iproc-flexrm-mbox", 109 + vfio_platform_bcmflexrm_reset); 110 + 111 + MODULE_LICENSE("GPL v2"); 112 + MODULE_AUTHOR("Anup Patel <anup.patel@broadcom.com>"); 113 + MODULE_DESCRIPTION("Reset support for Broadcom FlexRM VFIO platform device");
+2
drivers/vfio/vfio_iommu_spapr_tce.c
··· 507 507 enum dma_data_direction direction; 508 508 509 509 for ( ; pages; --pages, ++entry) { 510 + cond_resched(); 511 + 510 512 direction = DMA_NONE; 511 513 oldhpa = 0; 512 514 ret = iommu_tce_xchg(tbl, entry, &oldhpa, &direction);
+3
drivers/vfio/vfio_iommu_type1.c
··· 767 767 return -EINVAL; 768 768 if (!unmap->size || unmap->size & mask) 769 769 return -EINVAL; 770 + if (unmap->iova + unmap->size < unmap->iova || 771 + unmap->size > SIZE_MAX) 772 + return -EINVAL; 770 773 771 774 WARN_ON(mask & PAGE_MASK); 772 775 again:
+1 -1
samples/vfio-mdev/mtty.c
··· 1413 1413 NULL, 1414 1414 }; 1415 1415 1416 - struct mdev_parent_ops mdev_fops = { 1416 + static const struct mdev_parent_ops mdev_fops = { 1417 1417 .owner = THIS_MODULE, 1418 1418 .dev_attr_groups = mtty_dev_groups, 1419 1419 .mdev_attr_groups = mdev_dev_groups,