From: sathyanarayanan.kuppuswamy at linux.intel.com (sathyanarayanan kuppuswamy) Subject: [Linux-kernel-mentees] [PATCH v3 4/4] PCI/IOV: Move sysfs SR-IOV functions to iov.c Date: Thu, 15 Aug 2019 10:34:43 -0700 [thread overview] Message-ID: <59c7fc35-656e-e388-6ca5-e4e7ac2b01b3@linux.intel.com> (raw) In-Reply-To: <20190815153352.86143-5-skunberg.kelsey@gmail.com> On 8/15/19 8:33 AM, Kelsey Skunberg wrote: > The sysfs SR-IOV functions are for an optional feature and will be better > organized to keep with the feature's code. Move the sysfs SR-IOV functions > to /pci/iov.c. > > Signed-off-by: Kelsey Skunberg <skunberg.kelsey at gmail.com> Looks good to me. Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy at linux.intel.com> > --- > drivers/pci/iov.c | 168 ++++++++++++++++++++++++++++++++++++++ > drivers/pci/pci-sysfs.c | 173 ---------------------------------------- > drivers/pci/pci.h | 2 +- > 3 files changed, 169 insertions(+), 174 deletions(-) > > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index 9b48818ced01..b335db21c85e 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -240,6 +240,174 @@ void pci_iov_remove_virtfn(struct pci_dev *dev, int id) > pci_dev_put(dev); > } > > +static ssize_t sriov_totalvfs_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev)); > +} > + > +static ssize_t sriov_numvfs_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pdev->sriov->num_VFs); > +} > + > +/* > + * num_vfs > 0; number of VFs to enable > + * num_vfs = 0; disable all VFs > + * > + * Note: SRIOV spec does not allow partial VF > + * disable, so it's all or none. > + */ > +static ssize_t sriov_numvfs_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + int ret; > + u16 num_vfs; > + > + ret = kstrtou16(buf, 0, &num_vfs); > + if (ret < 0) > + return ret; > + > + if (num_vfs > pci_sriov_get_totalvfs(pdev)) > + return -ERANGE; > + > + device_lock(&pdev->dev); > + > + if (num_vfs == pdev->sriov->num_VFs) > + goto exit; > + > + /* is PF driver loaded w/callback */ > + if (!pdev->driver || !pdev->driver->sriov_configure) { > + pci_info(pdev, "Driver does not support SRIOV configuration via sysfs\n"); > + ret = -ENOENT; > + goto exit; > + } > + > + if (num_vfs == 0) { > + /* disable VFs */ > + ret = pdev->driver->sriov_configure(pdev, 0); > + goto exit; > + } > + > + /* enable VFs */ > + if (pdev->sriov->num_VFs) { > + pci_warn(pdev, "%d VFs already enabled. Disable before enabling %d VFs\n", > + pdev->sriov->num_VFs, num_vfs); > + ret = -EBUSY; > + goto exit; > + } > + > + ret = pdev->driver->sriov_configure(pdev, num_vfs); > + if (ret < 0) > + goto exit; > + > + if (ret != num_vfs) > + pci_warn(pdev, "%d VFs requested; only %d enabled\n", > + num_vfs, ret); > + > +exit: > + device_unlock(&pdev->dev); > + > + if (ret < 0) > + return ret; > + > + return count; > +} > + > +static ssize_t sriov_offset_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pdev->sriov->offset); > +} > + > +static ssize_t sriov_stride_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pdev->sriov->stride); > +} > + > +static ssize_t sriov_vf_device_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%x\n", pdev->sriov->vf_device); > +} > + > +static ssize_t sriov_drivers_autoprobe_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe); > +} > + > +static ssize_t sriov_drivers_autoprobe_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + bool drivers_autoprobe; > + > + if (kstrtobool(buf, &drivers_autoprobe) < 0) > + return -EINVAL; > + > + pdev->sriov->drivers_autoprobe = drivers_autoprobe; > + > + return count; > +} > + > +static DEVICE_ATTR_RO(sriov_totalvfs); > +static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, sriov_numvfs_store); > +static DEVICE_ATTR_RO(sriov_offset); > +static DEVICE_ATTR_RO(sriov_stride); > +static DEVICE_ATTR_RO(sriov_vf_device); > +static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, sriov_drivers_autoprobe_show, > + sriov_drivers_autoprobe_store); > + > +static struct attribute *sriov_dev_attrs[] = { > + &dev_attr_sriov_totalvfs.attr, > + &dev_attr_sriov_numvfs.attr, > + &dev_attr_sriov_offset.attr, > + &dev_attr_sriov_stride.attr, > + &dev_attr_sriov_vf_device.attr, > + &dev_attr_sriov_drivers_autoprobe.attr, > + NULL, > +}; > + > +static umode_t sriov_attrs_are_visible(struct kobject *kobj, > + struct attribute *a, int n) > +{ > + struct device *dev = kobj_to_dev(kobj); > + > + if (!dev_is_pf(dev)) > + return 0; > + > + return a->mode; > +} > + > +const struct attribute_group sriov_dev_attr_group = { > + .attrs = sriov_dev_attrs, > + .is_visible = sriov_attrs_are_visible, > +}; > + > int __weak pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs) > { > return 0; > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > index 5bb301efec98..868e35109284 100644 > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -548,151 +548,6 @@ static ssize_t devspec_show(struct device *dev, > static DEVICE_ATTR_RO(devspec); > #endif > > -#ifdef CONFIG_PCI_IOV > -static ssize_t sriov_totalvfs_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev)); > -} > - > - > -static ssize_t sriov_numvfs_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pdev->sriov->num_VFs); > -} > - > -/* > - * num_vfs > 0; number of VFs to enable > - * num_vfs = 0; disable all VFs > - * > - * Note: SRIOV spec doesn't allow partial VF > - * disable, so it's all or none. > - */ > -static ssize_t sriov_numvfs_store(struct device *dev, > - struct device_attribute *attr, > - const char *buf, size_t count) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - int ret; > - u16 num_vfs; > - > - ret = kstrtou16(buf, 0, &num_vfs); > - if (ret < 0) > - return ret; > - > - if (num_vfs > pci_sriov_get_totalvfs(pdev)) > - return -ERANGE; > - > - device_lock(&pdev->dev); > - > - if (num_vfs == pdev->sriov->num_VFs) > - goto exit; > - > - /* is PF driver loaded w/callback */ > - if (!pdev->driver || !pdev->driver->sriov_configure) { > - pci_info(pdev, "Driver doesn't support SRIOV configuration via sysfs\n"); > - ret = -ENOENT; > - goto exit; > - } > - > - if (num_vfs == 0) { > - /* disable VFs */ > - ret = pdev->driver->sriov_configure(pdev, 0); > - goto exit; > - } > - > - /* enable VFs */ > - if (pdev->sriov->num_VFs) { > - pci_warn(pdev, "%d VFs already enabled. Disable before enabling %d VFs\n", > - pdev->sriov->num_VFs, num_vfs); > - ret = -EBUSY; > - goto exit; > - } > - > - ret = pdev->driver->sriov_configure(pdev, num_vfs); > - if (ret < 0) > - goto exit; > - > - if (ret != num_vfs) > - pci_warn(pdev, "%d VFs requested; only %d enabled\n", > - num_vfs, ret); > - > -exit: > - device_unlock(&pdev->dev); > - > - if (ret < 0) > - return ret; > - > - return count; > -} > - > -static ssize_t sriov_offset_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pdev->sriov->offset); > -} > - > -static ssize_t sriov_stride_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pdev->sriov->stride); > -} > - > -static ssize_t sriov_vf_device_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%x\n", pdev->sriov->vf_device); > -} > - > -static ssize_t sriov_drivers_autoprobe_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe); > -} > - > -static ssize_t sriov_drivers_autoprobe_store(struct device *dev, > - struct device_attribute *attr, > - const char *buf, size_t count) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - bool drivers_autoprobe; > - > - if (kstrtobool(buf, &drivers_autoprobe) < 0) > - return -EINVAL; > - > - pdev->sriov->drivers_autoprobe = drivers_autoprobe; > - > - return count; > -} > - > -static DEVICE_ATTR_RO(sriov_totalvfs); > -static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, sriov_numvfs_store); > -static DEVICE_ATTR_RO(sriov_offset); > -static DEVICE_ATTR_RO(sriov_stride); > -static DEVICE_ATTR_RO(sriov_vf_device); > -static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, sriov_drivers_autoprobe_show, > - sriov_drivers_autoprobe_store); > -#endif /* CONFIG_PCI_IOV */ > - > static ssize_t driver_override_store(struct device *dev, > struct device_attribute *attr, > const char *buf, size_t count) > @@ -1691,34 +1546,6 @@ static const struct attribute_group pci_dev_hp_attr_group = { > .is_visible = pci_dev_hp_attrs_are_visible, > }; > > -#ifdef CONFIG_PCI_IOV > -static struct attribute *sriov_dev_attrs[] = { > - &dev_attr_sriov_totalvfs.attr, > - &dev_attr_sriov_numvfs.attr, > - &dev_attr_sriov_offset.attr, > - &dev_attr_sriov_stride.attr, > - &dev_attr_sriov_vf_device.attr, > - &dev_attr_sriov_drivers_autoprobe.attr, > - NULL, > -}; > - > -static umode_t sriov_attrs_are_visible(struct kobject *kobj, > - struct attribute *a, int n) > -{ > - struct device *dev = kobj_to_dev(kobj); > - > - if (!dev_is_pf(dev)) > - return 0; > - > - return a->mode; > -} > - > -static const struct attribute_group sriov_dev_attr_group = { > - .attrs = sriov_dev_attrs, > - .is_visible = sriov_attrs_are_visible, > -}; > -#endif /* CONFIG_PCI_IOV */ > - > static const struct attribute_group pci_dev_attr_group = { > .attrs = pci_dev_dev_attrs, > .is_visible = pci_dev_attrs_are_visible, > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h > index 61bbfd611140..7e3c6c8ae6f9 100644 > --- a/drivers/pci/pci.h > +++ b/drivers/pci/pci.h > @@ -455,7 +455,7 @@ void pci_iov_update_resource(struct pci_dev *dev, int resno); > resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno); > void pci_restore_iov_state(struct pci_dev *dev); > int pci_iov_bus_range(struct pci_bus *bus); > - > +extern const struct attribute_group sriov_dev_attr_group; > #else > static inline int pci_iov_init(struct pci_dev *dev) > { -- Sathyanarayanan Kuppuswamy Linux kernel developer
WARNING: multiple messages have this Message-ID (diff)
From: sathyanarayanan.kuppuswamy@linux.intel.com (sathyanarayanan kuppuswamy) Subject: [Linux-kernel-mentees] [PATCH v3 4/4] PCI/IOV: Move sysfs SR-IOV functions to iov.c Date: Thu, 15 Aug 2019 10:34:43 -0700 [thread overview] Message-ID: <59c7fc35-656e-e388-6ca5-e4e7ac2b01b3@linux.intel.com> (raw) Message-ID: <20190815173443._w9k2YUzveq2fAvz3NnRWaU2VdOpZMPwX9FTtmy2hsI@z> (raw) In-Reply-To: <20190815153352.86143-5-skunberg.kelsey@gmail.com> On 8/15/19 8:33 AM, Kelsey Skunberg wrote: > The sysfs SR-IOV functions are for an optional feature and will be better > organized to keep with the feature's code. Move the sysfs SR-IOV functions > to /pci/iov.c. > > Signed-off-by: Kelsey Skunberg <skunberg.kelsey at gmail.com> Looks good to me. Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy at linux.intel.com> > --- > drivers/pci/iov.c | 168 ++++++++++++++++++++++++++++++++++++++ > drivers/pci/pci-sysfs.c | 173 ---------------------------------------- > drivers/pci/pci.h | 2 +- > 3 files changed, 169 insertions(+), 174 deletions(-) > > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index 9b48818ced01..b335db21c85e 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -240,6 +240,174 @@ void pci_iov_remove_virtfn(struct pci_dev *dev, int id) > pci_dev_put(dev); > } > > +static ssize_t sriov_totalvfs_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev)); > +} > + > +static ssize_t sriov_numvfs_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pdev->sriov->num_VFs); > +} > + > +/* > + * num_vfs > 0; number of VFs to enable > + * num_vfs = 0; disable all VFs > + * > + * Note: SRIOV spec does not allow partial VF > + * disable, so it's all or none. > + */ > +static ssize_t sriov_numvfs_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + int ret; > + u16 num_vfs; > + > + ret = kstrtou16(buf, 0, &num_vfs); > + if (ret < 0) > + return ret; > + > + if (num_vfs > pci_sriov_get_totalvfs(pdev)) > + return -ERANGE; > + > + device_lock(&pdev->dev); > + > + if (num_vfs == pdev->sriov->num_VFs) > + goto exit; > + > + /* is PF driver loaded w/callback */ > + if (!pdev->driver || !pdev->driver->sriov_configure) { > + pci_info(pdev, "Driver does not support SRIOV configuration via sysfs\n"); > + ret = -ENOENT; > + goto exit; > + } > + > + if (num_vfs == 0) { > + /* disable VFs */ > + ret = pdev->driver->sriov_configure(pdev, 0); > + goto exit; > + } > + > + /* enable VFs */ > + if (pdev->sriov->num_VFs) { > + pci_warn(pdev, "%d VFs already enabled. Disable before enabling %d VFs\n", > + pdev->sriov->num_VFs, num_vfs); > + ret = -EBUSY; > + goto exit; > + } > + > + ret = pdev->driver->sriov_configure(pdev, num_vfs); > + if (ret < 0) > + goto exit; > + > + if (ret != num_vfs) > + pci_warn(pdev, "%d VFs requested; only %d enabled\n", > + num_vfs, ret); > + > +exit: > + device_unlock(&pdev->dev); > + > + if (ret < 0) > + return ret; > + > + return count; > +} > + > +static ssize_t sriov_offset_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pdev->sriov->offset); > +} > + > +static ssize_t sriov_stride_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pdev->sriov->stride); > +} > + > +static ssize_t sriov_vf_device_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%x\n", pdev->sriov->vf_device); > +} > + > +static ssize_t sriov_drivers_autoprobe_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe); > +} > + > +static ssize_t sriov_drivers_autoprobe_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + bool drivers_autoprobe; > + > + if (kstrtobool(buf, &drivers_autoprobe) < 0) > + return -EINVAL; > + > + pdev->sriov->drivers_autoprobe = drivers_autoprobe; > + > + return count; > +} > + > +static DEVICE_ATTR_RO(sriov_totalvfs); > +static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, sriov_numvfs_store); > +static DEVICE_ATTR_RO(sriov_offset); > +static DEVICE_ATTR_RO(sriov_stride); > +static DEVICE_ATTR_RO(sriov_vf_device); > +static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, sriov_drivers_autoprobe_show, > + sriov_drivers_autoprobe_store); > + > +static struct attribute *sriov_dev_attrs[] = { > + &dev_attr_sriov_totalvfs.attr, > + &dev_attr_sriov_numvfs.attr, > + &dev_attr_sriov_offset.attr, > + &dev_attr_sriov_stride.attr, > + &dev_attr_sriov_vf_device.attr, > + &dev_attr_sriov_drivers_autoprobe.attr, > + NULL, > +}; > + > +static umode_t sriov_attrs_are_visible(struct kobject *kobj, > + struct attribute *a, int n) > +{ > + struct device *dev = kobj_to_dev(kobj); > + > + if (!dev_is_pf(dev)) > + return 0; > + > + return a->mode; > +} > + > +const struct attribute_group sriov_dev_attr_group = { > + .attrs = sriov_dev_attrs, > + .is_visible = sriov_attrs_are_visible, > +}; > + > int __weak pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs) > { > return 0; > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > index 5bb301efec98..868e35109284 100644 > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -548,151 +548,6 @@ static ssize_t devspec_show(struct device *dev, > static DEVICE_ATTR_RO(devspec); > #endif > > -#ifdef CONFIG_PCI_IOV > -static ssize_t sriov_totalvfs_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev)); > -} > - > - > -static ssize_t sriov_numvfs_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pdev->sriov->num_VFs); > -} > - > -/* > - * num_vfs > 0; number of VFs to enable > - * num_vfs = 0; disable all VFs > - * > - * Note: SRIOV spec doesn't allow partial VF > - * disable, so it's all or none. > - */ > -static ssize_t sriov_numvfs_store(struct device *dev, > - struct device_attribute *attr, > - const char *buf, size_t count) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - int ret; > - u16 num_vfs; > - > - ret = kstrtou16(buf, 0, &num_vfs); > - if (ret < 0) > - return ret; > - > - if (num_vfs > pci_sriov_get_totalvfs(pdev)) > - return -ERANGE; > - > - device_lock(&pdev->dev); > - > - if (num_vfs == pdev->sriov->num_VFs) > - goto exit; > - > - /* is PF driver loaded w/callback */ > - if (!pdev->driver || !pdev->driver->sriov_configure) { > - pci_info(pdev, "Driver doesn't support SRIOV configuration via sysfs\n"); > - ret = -ENOENT; > - goto exit; > - } > - > - if (num_vfs == 0) { > - /* disable VFs */ > - ret = pdev->driver->sriov_configure(pdev, 0); > - goto exit; > - } > - > - /* enable VFs */ > - if (pdev->sriov->num_VFs) { > - pci_warn(pdev, "%d VFs already enabled. Disable before enabling %d VFs\n", > - pdev->sriov->num_VFs, num_vfs); > - ret = -EBUSY; > - goto exit; > - } > - > - ret = pdev->driver->sriov_configure(pdev, num_vfs); > - if (ret < 0) > - goto exit; > - > - if (ret != num_vfs) > - pci_warn(pdev, "%d VFs requested; only %d enabled\n", > - num_vfs, ret); > - > -exit: > - device_unlock(&pdev->dev); > - > - if (ret < 0) > - return ret; > - > - return count; > -} > - > -static ssize_t sriov_offset_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pdev->sriov->offset); > -} > - > -static ssize_t sriov_stride_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pdev->sriov->stride); > -} > - > -static ssize_t sriov_vf_device_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%x\n", pdev->sriov->vf_device); > -} > - > -static ssize_t sriov_drivers_autoprobe_show(struct device *dev, > - struct device_attribute *attr, > - char *buf) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - > - return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe); > -} > - > -static ssize_t sriov_drivers_autoprobe_store(struct device *dev, > - struct device_attribute *attr, > - const char *buf, size_t count) > -{ > - struct pci_dev *pdev = to_pci_dev(dev); > - bool drivers_autoprobe; > - > - if (kstrtobool(buf, &drivers_autoprobe) < 0) > - return -EINVAL; > - > - pdev->sriov->drivers_autoprobe = drivers_autoprobe; > - > - return count; > -} > - > -static DEVICE_ATTR_RO(sriov_totalvfs); > -static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, sriov_numvfs_store); > -static DEVICE_ATTR_RO(sriov_offset); > -static DEVICE_ATTR_RO(sriov_stride); > -static DEVICE_ATTR_RO(sriov_vf_device); > -static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, sriov_drivers_autoprobe_show, > - sriov_drivers_autoprobe_store); > -#endif /* CONFIG_PCI_IOV */ > - > static ssize_t driver_override_store(struct device *dev, > struct device_attribute *attr, > const char *buf, size_t count) > @@ -1691,34 +1546,6 @@ static const struct attribute_group pci_dev_hp_attr_group = { > .is_visible = pci_dev_hp_attrs_are_visible, > }; > > -#ifdef CONFIG_PCI_IOV > -static struct attribute *sriov_dev_attrs[] = { > - &dev_attr_sriov_totalvfs.attr, > - &dev_attr_sriov_numvfs.attr, > - &dev_attr_sriov_offset.attr, > - &dev_attr_sriov_stride.attr, > - &dev_attr_sriov_vf_device.attr, > - &dev_attr_sriov_drivers_autoprobe.attr, > - NULL, > -}; > - > -static umode_t sriov_attrs_are_visible(struct kobject *kobj, > - struct attribute *a, int n) > -{ > - struct device *dev = kobj_to_dev(kobj); > - > - if (!dev_is_pf(dev)) > - return 0; > - > - return a->mode; > -} > - > -static const struct attribute_group sriov_dev_attr_group = { > - .attrs = sriov_dev_attrs, > - .is_visible = sriov_attrs_are_visible, > -}; > -#endif /* CONFIG_PCI_IOV */ > - > static const struct attribute_group pci_dev_attr_group = { > .attrs = pci_dev_dev_attrs, > .is_visible = pci_dev_attrs_are_visible, > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h > index 61bbfd611140..7e3c6c8ae6f9 100644 > --- a/drivers/pci/pci.h > +++ b/drivers/pci/pci.h > @@ -455,7 +455,7 @@ void pci_iov_update_resource(struct pci_dev *dev, int resno); > resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno); > void pci_restore_iov_state(struct pci_dev *dev); > int pci_iov_bus_range(struct pci_bus *bus); > - > +extern const struct attribute_group sriov_dev_attr_group; > #else > static inline int pci_iov_init(struct pci_dev *dev) > { -- Sathyanarayanan Kuppuswamy Linux kernel developer
next prev parent reply other threads:[~2019-08-15 17:34 UTC|newest] Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-09 19:57 [Linux-kernel-mentees] [PATCH] PCI/IOV: Move sysfs SR-IOV functions to iov.c skunberg.kelsey 2019-08-09 19:57 ` Kelsey Skunberg 2019-08-10 7:17 ` greg 2019-08-10 7:17 ` Greg KH 2019-08-10 17:15 ` helgaas 2019-08-10 17:15 ` Bjorn Helgaas 2019-08-10 17:24 ` greg 2019-08-10 17:24 ` Greg KH 2019-08-10 21:32 ` skunberg.kelsey 2019-08-10 21:32 ` Kelsey Skunberg 2019-08-13 20:45 ` [Linux-kernel-mentees] [PATCH v2 0/3] PCI: pci-sysfs.c cleanup skunberg.kelsey 2019-08-13 20:45 ` Kelsey Skunberg 2019-08-13 20:45 ` [Linux-kernel-mentees] [PATCH v2 1/3] PCI: sysfs: Define device attributes with DEVICE_ATTR*() skunberg.kelsey 2019-08-13 20:45 ` Kelsey Skunberg 2019-08-14 7:52 ` gregkh 2019-08-14 7:52 ` Greg KH 2019-08-14 23:14 ` skunberg.kelsey 2019-08-14 23:14 ` Kelsey Skunberg 2019-08-15 15:54 ` skunberg.kelsey 2019-08-15 15:54 ` Kelsey Skunberg 2019-08-13 20:45 ` [Linux-kernel-mentees] [PATCH v2 2/3] PCI: sysfs: Change permissions from symbolic to octal skunberg.kelsey 2019-08-13 20:45 ` Kelsey Skunberg 2019-08-14 5:38 ` helgaas 2019-08-14 5:38 ` Bjorn Helgaas 2019-08-14 7:53 ` gregkh 2019-08-14 7:53 ` Greg Kroah-Hartman 2019-08-15 14:37 ` ddutile 2019-08-15 14:37 ` Don Dutile 2019-09-04 6:22 ` skunberg.kelsey 2019-09-04 6:22 ` Kelsey Skunberg 2019-09-04 15:32 ` ddutile 2019-09-04 15:32 ` Don Dutile 2019-09-04 18:33 ` ddutile 2019-09-04 18:33 ` Don Dutile 2019-09-05 4:04 ` skunberg.kelsey 2019-09-05 4:04 ` Kelsey Skunberg 2019-08-13 20:45 ` [Linux-kernel-mentees] [PATCH v2 3/3] PCI/IOV: Move sysfs SR-IOV functions to iov.c skunberg.kelsey 2019-08-13 20:45 ` Kelsey Skunberg 2019-08-14 5:40 ` [Linux-kernel-mentees] [PATCH v2 0/3] PCI: pci-sysfs.c cleanup helgaas 2019-08-14 5:40 ` Bjorn Helgaas 2019-08-15 15:33 ` [Linux-kernel-mentees] [PATCH v3 0/4] PCI: Clean up pci-sysfs.c skunberg.kelsey 2019-08-15 15:33 ` Kelsey Skunberg 2019-08-15 16:08 ` gregkh 2019-08-15 16:08 ` Greg KH 2019-08-16 4:22 ` ddutile 2019-08-16 4:22 ` Don Dutile 2019-08-19 22:42 ` helgaas 2019-08-19 22:42 ` Bjorn Helgaas 2019-08-15 15:33 ` [Linux-kernel-mentees] [PATCH v3 1/4] PCI: sysfs: Define device attributes with DEVICE_ATTR* skunberg.kelsey 2019-08-15 15:33 ` Kelsey Skunberg 2020-03-14 10:51 ` Ruslan Bilovol 2020-03-14 11:20 ` Greg Kroah-Hartman 2020-03-24 6:10 ` Kelsey 2020-03-24 6:24 ` Greg Kroah-Hartman 2020-03-24 23:53 ` Kelsey 2020-03-25 7:17 ` Greg Kroah-Hartman 2020-03-25 15:15 ` Kelsey 2019-08-15 15:33 ` [Linux-kernel-mentees] [PATCH v3 2/4] PCI: sysfs: Change permissions from symbolic to octal skunberg.kelsey 2019-08-15 15:33 ` Kelsey Skunberg 2019-08-15 15:33 ` [Linux-kernel-mentees] [PATCH v3 3/4] PCI: sysfs: Change DEVICE_ATTR() to DEVICE_ATTR_WO() skunberg.kelsey 2019-08-15 15:33 ` Kelsey Skunberg 2019-08-15 15:33 ` [Linux-kernel-mentees] [PATCH v3 4/4] PCI/IOV: Move sysfs SR-IOV functions to iov.c skunberg.kelsey 2019-08-15 15:33 ` Kelsey Skunberg 2019-08-15 17:34 ` sathyanarayanan.kuppuswamy [this message] 2019-08-15 17:34 ` sathyanarayanan kuppuswamy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=59c7fc35-656e-e388-6ca5-e4e7ac2b01b3@linux.intel.com \ --to=linux-kernel-mentees@lists.linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).