All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Ben Hutchings <bhutchings@solarflare.com>,
	Bjorn Helgaas <bhelgaas@google.com>
Cc: Greg Rose <gregory.v.rose@intel.com>,
	Yuval Mintz <yuvalmin@broadcom.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Ariel Elior <ariele@broadcom.com>,
	Eilon Greenstein <eilong@broadcom.com>,
	linux-pci <linux-pci@vger.kernel.org>
Subject: Re: New commands to configure IOV features
Date: Wed, 19 Sep 2012 15:17:31 -0700	[thread overview]
Message-ID: <CAE9FiQXQj_KdWT-mVVsptxiEgGjScgDy_Lp-aXioZ4YAQh1wWQ@mail.gmail.com> (raw)
In-Reply-To: <1348083847.2636.37.camel@bwh-desktop.uk.solarflarecom.com>

[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]

On Wed, Sep 19, 2012 at 12:44 PM, Ben Hutchings
<bhutchings@solarflare.com> wrote:
> On Wed, 2012-09-19 at 08:53 -0700, Greg Rose wrote:
>> I was not able to attend the Linux conference held at the end of August
>> myself but coworkers of mine here at Intel informed that method 2 here
>> seems to be the preferred approach.  Perhaps some folks who attended
>> the the conference can chime in with more specifics.
>
> There really wasn't much more specific discussion.  Bjorn's summary of
> the mini-summit <http://lwn.net/Articles/514113/> says:
>
>> SR-IOV Management
>>
>>     Currently drivers implement module parameters like "max_vfs".  This means
>>     all devices claimed by the driver get the same number of VFs, and you can't
>>     change anything without unloading and reloading the driver.
>>
>>     Consensus that we should try to implement a knob for this in sysfs so it
>>     can be generic (not in each driver) and set individually for each device.
>
> I don't think any implementation has been posted to the linux-pci list

please check attached three patches...

Thanks

Yinghai

[-- Attachment #2: pci_dev_type.patch --]
[-- Type: application/octet-stream, Size: 2042 bytes --]

Subject: [PATCH] PCI: Add pci_dev_type

later use it for visiable attribute control.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/pci-sysfs.c |   24 ++++++++++++++++++++++++
 drivers/pci/pci.h       |    1 +
 drivers/pci/probe.c     |    1 +
 3 files changed, 26 insertions(+)

Index: linux-2.6/drivers/pci/pci-sysfs.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-sysfs.c
+++ linux-2.6/drivers/pci/pci-sysfs.c
@@ -1411,3 +1411,27 @@ static int __init pci_sysfs_init(void)
 }
 
 late_initcall(pci_sysfs_init);
+
+static struct attribute *pci_dev_dev_attrs[] = {
+	NULL,
+};
+
+static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
+						struct attribute *a, int n)
+{
+	return a->mode;
+}
+
+static struct attribute_group pci_dev_attr_group = {
+	.attrs = pci_dev_dev_attrs,
+	.is_visible = pci_dev_attrs_are_visible,
+};
+
+static const struct attribute_group *pci_dev_attr_groups[] = {
+	&pci_dev_attr_group,
+	NULL,
+};
+
+struct device_type pci_dev_type = {
+	.groups = pci_dev_attr_groups,
+};
Index: linux-2.6/drivers/pci/pci.h
===================================================================
--- linux-2.6.orig/drivers/pci/pci.h
+++ linux-2.6/drivers/pci/pci.h
@@ -157,6 +157,7 @@ static inline int pci_no_d1d2(struct pci
 }
 extern struct device_attribute pci_dev_attrs[];
 extern struct device_attribute pcibus_dev_attrs[];
+extern struct device_type pci_dev_type;
 #ifdef CONFIG_HOTPLUG
 extern struct bus_attribute pci_bus_attrs[];
 #else
Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -975,6 +975,7 @@ int pci_setup_device(struct pci_dev *dev
 	dev->sysdata = dev->bus->sysdata;
 	dev->dev.parent = dev->bus->bridge;
 	dev->dev.bus = &pci_bus_type;
+	dev->dev.type = &pci_dev_type;
 	dev->hdr_type = hdr_type & 0x7f;
 	dev->multifunction = !!(hdr_type & 0x80);
 	dev->error_state = pci_channel_io_normal;

[-- Attachment #3: pci_010_pci_dev_boot_vga_x.patch --]
[-- Type: application/octet-stream, Size: 1868 bytes --]

Subject: [PATCH 10/10] PCI, sys: Use is_visable() with boot_vga attribute for pci_dev

That could let pci_create_sysfs_dev_files more simple.

also fix possible fix memleak during removing path.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/pci-sysfs.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Index: linux-2.6/drivers/pci/pci-sysfs.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-sysfs.c
+++ linux-2.6/drivers/pci/pci-sysfs.c
@@ -1304,29 +1304,20 @@ int __must_check pci_create_sysfs_dev_fi
 		pdev->rom_attr = attr;
 	}
 
-	if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) {
-		retval = device_create_file(&pdev->dev, &vga_attr);
-		if (retval)
-			goto err_rom_file;
-	}
-
 	/* add platform-specific attributes */
 	retval = pcibios_add_platform_entries(pdev);
 	if (retval)
-		goto err_vga_file;
+		goto err_rom_file;
 
 	/* add sysfs entries for various capabilities */
 	retval = pci_create_capabilities_sysfs(pdev);
 	if (retval)
-		goto err_vga_file;
+		goto err_rom_file;
 
 	pci_create_firmware_label_files(pdev);
 
 	return 0;
 
-err_vga_file:
-	if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
-		device_remove_file(&pdev->dev, &vga_attr);
 err_rom_file:
 	if (rom_size) {
 		sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
@@ -1414,12 +1405,20 @@ static int __init pci_sysfs_init(void)
 late_initcall(pci_sysfs_init);
 
 static struct attribute *pci_dev_dev_attrs[] = {
+	&vga_attr.attr,
 	NULL,
 };
 
 static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
 						struct attribute *a, int n)
 {
+	struct device *dev = container_of(kobj, struct device, kobj);
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	if (a == &vga_attr.attr)
+		if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
+			return 0;
+
 	return a->mode;
 }
 

[-- Attachment #4: sriov_xxx.patch --]
[-- Type: application/octet-stream, Size: 2158 bytes --]

Subject: [PATCH] PCI: Add max_vfs in sysfs per pci device where supports

driver later need to check dev->max_vfs in /sys

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/pci-sysfs.c |   29 +++++++++++++++++++++++++++++
 include/linux/pci.h     |    1 +
 2 files changed, 30 insertions(+)

Index: linux-2.6/drivers/pci/pci-sysfs.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-sysfs.c
+++ linux-2.6/drivers/pci/pci-sysfs.c
@@ -459,6 +459,30 @@ boot_vga_show(struct device *dev, struct
 }
 struct device_attribute vga_attr = __ATTR_RO(boot_vga);
 
+static ssize_t
+max_vfs_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	return sprintf(buf, "%u\n", pdev->max_vfs);
+}
+static ssize_t
+max_vfs_store(struct device *dev, struct device_attribute *attr,
+		 const char *buf, size_t count)
+{
+	unsigned long val;
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	if (strict_strtoul(buf, 0, &val) < 0)
+		return -EINVAL;
+
+	pdev->max_vfs = val;
+
+	return count;
+}
+struct device_attribute max_vfs_attr =
+	__ATTR(max_vfs, 0644, max_vfs_show, max_vfs_store);
+
 static void
 pci_config_pm_runtime_get(struct pci_dev *pdev)
 {
@@ -1406,6 +1430,7 @@ late_initcall(pci_sysfs_init);
 
 static struct attribute *pci_dev_dev_attrs[] = {
 	&vga_attr.attr,
+	&max_vfs_attr.attr,
 	NULL,
 };
 
@@ -1419,6 +1444,10 @@ static umode_t pci_dev_attrs_are_visible
 		if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
 			return 0;
 
+	if (a == &max_vfs_attr.attr)
+		if (!pdev->is_physfn)
+			return 0;
+
 	return a->mode;
 }
 
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -359,6 +359,7 @@ struct pci_dev {
 	unsigned int	broken_intx_masking:1;
 	unsigned int	io_window_1k:1;	/* Intel P2P bridge 1K I/O windows */
 	pci_dev_flags_t dev_flags;
+	unsigned int	max_vfs;
 	atomic_t	enable_cnt;	/* pci_enable_device has been called */
 
 	u32		saved_config_space[16]; /* config space saved at suspend time */

  reply	other threads:[~2012-09-19 22:17 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-07 11:17 New commands to configure IOV features Yuval Mintz
2012-05-07 15:16 ` Greg Rose
2012-06-26 12:21   ` Yuval Mintz
2012-06-26 16:13     ` Alexander Duyck
2012-06-26 17:19     ` Greg Rose
2012-07-01 11:09       ` Yuval Mintz
2012-07-09 18:39       ` Ben Hutchings
2012-07-09 21:13         ` Chris Friesen
2012-07-16  9:19           ` Yuval Mintz
2012-07-17 19:29             ` Don Dutile
2012-07-17 21:08               ` Chris Friesen
2012-07-17 21:11                 ` David Miller
2012-07-20 15:27                   ` Chris Friesen
2012-07-20 15:56                     ` Don Dutile
2012-07-20 17:42                       ` Ben Hutchings
2012-07-20 19:29                         ` Chris Friesen
2012-07-20 20:01                           ` Ben Hutchings
2012-07-20 20:15                             ` Don Dutile
2012-07-20 23:42                             ` Chris Friesen
2012-07-21  0:52                               ` Rose, Gregory V
2012-07-23 14:03                               ` Don Dutile
2012-07-23 15:09                                 ` Chris Friesen
2012-07-23 17:06                                   ` Rose, Gregory V
2012-07-23 18:36                                   ` Stephen Hemminger
2012-07-23 18:40                                     ` Rose, Gregory V
2012-09-19 11:07                                       ` Yuval Mintz
2012-09-19 15:53                                         ` Greg Rose
2012-09-19 19:44                                           ` Ben Hutchings
2012-09-19 22:17                                             ` Yinghai Lu [this message]
2012-09-19 22:46                                               ` Ben Hutchings
2012-09-20  0:19                                                 ` Yinghai Lu
2012-09-20  1:23                                                   ` Ben Hutchings
2012-09-20  2:27                                                     ` Yinghai Lu
2012-09-20  3:08                                                       ` Subhendu Ghosh
2012-09-20 15:39                                                     ` Rose, Gregory V
2012-09-20 15:39                                                       ` Rose, Gregory V
2012-09-21  5:50                                                       ` Yinghai Lu
2012-09-21 17:35                                                         ` Ben Hutchings
2012-09-21 19:23                                                           ` Yinghai Lu
2012-09-21 18:06                                                         ` Don Dutile
2012-09-21 18:06                                                           ` Don Dutile
2012-09-21 19:49                                                           ` Yinghai Lu
2012-09-21 20:08                                                             ` Don Dutile
2012-09-21 20:08                                                               ` Don Dutile
2012-09-23 15:49                                                               ` Yuval Mintz
2012-09-24 17:37                                                                 ` Don Dutile
2012-09-24 17:37                                                                   ` Don Dutile
2012-09-30  6:39                                                               ` Yuval Mintz
2012-10-01 14:12                                                                 ` Don Dutile
2012-10-01 14:12                                                                   ` Don Dutile
2012-09-19 17:49                                         ` David Miller
2012-07-23 16:37                                 ` Rose, Gregory V

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=CAE9FiQXQj_KdWT-mVVsptxiEgGjScgDy_Lp-aXioZ4YAQh1wWQ@mail.gmail.com \
    --to=yinghai@kernel.org \
    --cc=ariele@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=eilong@broadcom.com \
    --cc=gregory.v.rose@intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yuvalmin@broadcom.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.