All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/
@ 2010-03-08 17:24 Alex Chiang
  2010-03-09  1:16 ` Kenji Kaneshige
  2010-03-19 21:46 ` Jesse Barnes
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Chiang @ 2010-03-08 17:24 UTC (permalink / raw)
  To: Jesse Barnes, linux-pci, linux-kernel; +Cc: willy

Create convenience symlinks in sysfs, linking slots to device
functions, and vice versa. These links make it easier for users to
figure out which devices actually live in what slots.

For example:

sapphire:/sys/bus/pci/slots # ls
1  10  2  3  4  5  6  7  8  9

sapphire:/sys/bus/pci/slots # ls -l 3
total 0
-r--r--r-- 1 root root 65536 Aug 18 14:10 address
lrwxrwxrwx 1 root root     0 Aug 18 14:10 function0 ->
../../../../devices/pci0000:23/0000:23:01.0
lrwxrwxrwx 1 root root     0 Aug 18 14:10 function1 ->
../../../../devices/pci0000:23/0000:23:01.1

sapphire:/sys/bus/pci/slots # ls -l 3/function0/slot
lrwxrwxrwx 1 root root 0 Aug 18 14:13 3/function0/slot ->
../../../bus/pci/slots/3

The original form of this patch was written by Matthew Wilcox,
and was enhanced to include links from the sysfs slots/ directory
pointing back at the device functions.

Cc: willy@linux.intel.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---
Not sure why I've been sitting on this patch for so long, but
I think it would be a useful thing to have upstream.

 Documentation/ABI/testing/sysfs-bus-pci |   40 ++++++++++++++++++++++++++
 drivers/pci/pci-sysfs.c                 |   37 ++++++++++++++++++++++++
 drivers/pci/slot.c                      |   48 ++++++++++++++++++++++++++++++++
 3 files changed, 125 insertions(+)
---
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
index 25be325..428676c 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci
+++ b/Documentation/ABI/testing/sysfs-bus-pci
@@ -133,6 +133,46 @@ Description:
 		The symbolic link points to the PCI device sysfs entry of the
 		Physical Function this device associates with.
 
+
+What:		/sys/bus/pci/slots/...
+Date:		April 2005 (possibly older)
+KernelVersion:	2.6.12 (possibly older)
+Contact:	linux-pci@vger.kernel.org
+Description:
+		When the appropriate driver is loaded, it will create a
+		directory per claimed physical PCI slot in
+		/sys/bus/pci/slots/.  The names of these directories are
+		specific to the driver, which in turn, are specific to the
+		platform, but in general, should match the label on the
+		machine's physical chassis.
+
+		The drivers that can create slot directories include the
+		PCI hotplug drivers, and as of 2.6.27, the pci_slot driver.
+
+		The slot directories contain, at a minimum, a file named
+		'address' which contains the PCI bus:device:function tuple.
+		Other files may appear as well, but are specific to the
+		driver.
+
+What:		/sys/bus/pci/slots/.../function[0-7]
+Date:		March 2010
+KernelVersion:	2.6.35
+Contact:	linux-pci@vger.kernel.org
+Description:
+		If PCI slot directories (as described above) are created,
+		and the physical slot is actually populated with a device,
+		symbolic links in the slot directory pointing to the
+		device's PCI functions are created as well.
+
+What:		/sys/bus/pci/devices/.../slot
+Date:		March 2010
+KernelVersion:	2.6.35
+Contact:	linux-pci@vger.kernel.org
+Description:
+		If PCI slot directories (as described above) are created,
+		a symbolic link pointing to the slot directory will be
+		created as well.
+
 What:		/sys/bus/pci/slots/.../module
 Date:		June 2009
 Contact:	linux-pci@vger.kernel.org
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 807224e..d234234 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1006,6 +1006,39 @@ error:
 	return retval;
 }
 
+static void pci_remove_slot_links(struct pci_dev *dev)
+{
+	char func[10];
+	struct pci_slot *slot;
+
+	sysfs_remove_link(&dev->dev.kobj, "slot");
+	list_for_each_entry(slot, &dev->bus->slots, list) {
+		if (slot->number != PCI_SLOT(dev->devfn))
+			continue;
+		snprintf(func, 10, "function%d", PCI_FUNC(dev->devfn));
+		sysfs_remove_link(&slot->kobj, func);
+	}
+}
+
+static int pci_create_slot_links(struct pci_dev *dev)
+{
+	int result = 0;
+	char func[10];
+	struct pci_slot *slot;
+
+	list_for_each_entry(slot, &dev->bus->slots, list) {
+		if (slot->number != PCI_SLOT(dev->devfn))
+			continue;
+		result = sysfs_create_link(&dev->dev.kobj, &slot->kobj, "slot");
+		if (result)
+			goto out;
+		snprintf(func, 10, "function%d", PCI_FUNC(dev->devfn));
+		result = sysfs_create_link(&slot->kobj, &dev->dev.kobj, func);
+	}
+out:
+	return result;
+}
+
 int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
 {
 	int retval;
@@ -1067,6 +1100,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
 	if (retval)
 		goto err_vga_file;
 
+	pci_create_slot_links(pdev);
+
 	return 0;
 
 err_vga_file:
@@ -1116,6 +1151,8 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
 	if (!sysfs_initialized)
 		return;
 
+	pci_remove_slot_links(pdev);
+
 	pci_remove_capabilities_sysfs(pdev);
 
 	if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 49c9e6c..a8e22c6 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -96,6 +96,50 @@ static ssize_t cur_speed_read_file(struct pci_slot *slot, char *buf)
 	return bus_speed_read(slot->bus->cur_bus_speed, buf);
 }
 
+static void remove_sysfs_files(struct pci_slot *slot)
+{
+	char func[10];
+	struct list_head *tmp;
+
+	list_for_each(tmp, &slot->bus->devices) {
+		struct pci_dev *dev = pci_dev_b(tmp);
+		if (PCI_SLOT(dev->devfn) != slot->number)
+			continue;
+		sysfs_remove_link(&dev->dev.kobj, "slot");
+
+		snprintf(func, 10, "function%d", PCI_FUNC(dev->devfn));
+		sysfs_remove_link(&slot->kobj, func);
+	}
+}
+
+static int create_sysfs_files(struct pci_slot *slot)
+{
+	int result;
+	char func[10];
+	struct list_head *tmp;
+
+	list_for_each(tmp, &slot->bus->devices) {
+		struct pci_dev *dev = pci_dev_b(tmp);
+		if (PCI_SLOT(dev->devfn) != slot->number)
+			continue;
+
+		result = sysfs_create_link(&dev->dev.kobj, &slot->kobj, "slot");
+		if (result)
+			goto fail;
+
+		snprintf(func, 10, "function%d", PCI_FUNC(dev->devfn));
+		result = sysfs_create_link(&slot->kobj, &dev->dev.kobj, func);
+		if (result)
+			goto fail;
+	}
+
+	return 0;
+
+fail:
+	remove_sysfs_files(slot);
+	return result;
+}
+
 static void pci_slot_release(struct kobject *kobj)
 {
 	struct pci_dev *dev;
@@ -108,6 +152,8 @@ static void pci_slot_release(struct kobject *kobj)
 		if (PCI_SLOT(dev->devfn) == slot->number)
 			dev->slot = NULL;
 
+	remove_sysfs_files(slot);
+
 	list_del(&slot->list);
 
 	kfree(slot);
@@ -299,6 +345,8 @@ placeholder:
 	INIT_LIST_HEAD(&slot->list);
 	list_add(&slot->list, &parent->slots);
 
+	create_sysfs_files(slot);
+
 	list_for_each_entry(dev, &parent->devices, bus_list)
 		if (PCI_SLOT(dev->devfn) == slot_nr)
 			dev->slot = slot;

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/
  2010-03-08 17:24 [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/ Alex Chiang
@ 2010-03-09  1:16 ` Kenji Kaneshige
  2010-03-10 18:15   ` Alex Chiang
  2010-03-19 21:46 ` Jesse Barnes
  1 sibling, 1 reply; 7+ messages in thread
From: Kenji Kaneshige @ 2010-03-09  1:16 UTC (permalink / raw)
  To: Alex Chiang; +Cc: Jesse Barnes, linux-pci, linux-kernel, willy

Alex Chiang wrote:
> Create convenience symlinks in sysfs, linking slots to device
> functions, and vice versa. These links make it easier for users to
> figure out which devices actually live in what slots.
> 
> For example:
> 
> sapphire:/sys/bus/pci/slots # ls
> 1  10  2  3  4  5  6  7  8  9
> 
> sapphire:/sys/bus/pci/slots # ls -l 3
> total 0
> -r--r--r-- 1 root root 65536 Aug 18 14:10 address
> lrwxrwxrwx 1 root root     0 Aug 18 14:10 function0 ->
> ../../../../devices/pci0000:23/0000:23:01.0
> lrwxrwxrwx 1 root root     0 Aug 18 14:10 function1 ->
> ../../../../devices/pci0000:23/0000:23:01.1
>

I usually get the similar information like the followings. Is it not enough
for you?

# /sbin/lspci -s `cat /sys/bus/pci/slots/1/address`
40:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06)
40:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06)

 
> sapphire:/sys/bus/pci/slots # ls -l 3/function0/slot
> lrwxrwxrwx 1 root root 0 Aug 18 14:13 3/function0/slot ->
> ../../../bus/pci/slots/3

IIRC, the latest 'lspci' command shows physical slot information (you added
this useful feature, didn't you?). Is it not enough for you?

Thanks,
Kenji Kaneshige



> 
> The original form of this patch was written by Matthew Wilcox,
> and was enhanced to include links from the sysfs slots/ directory
> pointing back at the device functions.
> 
> Cc: willy@linux.intel.com
> Signed-off-by: Alex Chiang <achiang@hp.com>
> ---
> Not sure why I've been sitting on this patch for so long, but
> I think it would be a useful thing to have upstream.
> 
>  Documentation/ABI/testing/sysfs-bus-pci |   40 ++++++++++++++++++++++++++
>  drivers/pci/pci-sysfs.c                 |   37 ++++++++++++++++++++++++
>  drivers/pci/slot.c                      |   48 ++++++++++++++++++++++++++++++++
>  3 files changed, 125 insertions(+)
> ---
> diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
> index 25be325..428676c 100644
> --- a/Documentation/ABI/testing/sysfs-bus-pci
> +++ b/Documentation/ABI/testing/sysfs-bus-pci
> @@ -133,6 +133,46 @@ Description:
>  		The symbolic link points to the PCI device sysfs entry of the
>  		Physical Function this device associates with.
>  
> +
> +What:		/sys/bus/pci/slots/...
> +Date:		April 2005 (possibly older)
> +KernelVersion:	2.6.12 (possibly older)
> +Contact:	linux-pci@vger.kernel.org
> +Description:
> +		When the appropriate driver is loaded, it will create a
> +		directory per claimed physical PCI slot in
> +		/sys/bus/pci/slots/.  The names of these directories are
> +		specific to the driver, which in turn, are specific to the
> +		platform, but in general, should match the label on the
> +		machine's physical chassis.
> +
> +		The drivers that can create slot directories include the
> +		PCI hotplug drivers, and as of 2.6.27, the pci_slot driver.
> +
> +		The slot directories contain, at a minimum, a file named
> +		'address' which contains the PCI bus:device:function tuple.
> +		Other files may appear as well, but are specific to the
> +		driver.
> +
> +What:		/sys/bus/pci/slots/.../function[0-7]
> +Date:		March 2010
> +KernelVersion:	2.6.35
> +Contact:	linux-pci@vger.kernel.org
> +Description:
> +		If PCI slot directories (as described above) are created,
> +		and the physical slot is actually populated with a device,
> +		symbolic links in the slot directory pointing to the
> +		device's PCI functions are created as well.
> +
> +What:		/sys/bus/pci/devices/.../slot
> +Date:		March 2010
> +KernelVersion:	2.6.35
> +Contact:	linux-pci@vger.kernel.org
> +Description:
> +		If PCI slot directories (as described above) are created,
> +		a symbolic link pointing to the slot directory will be
> +		created as well.
> +
>  What:		/sys/bus/pci/slots/.../module
>  Date:		June 2009
>  Contact:	linux-pci@vger.kernel.org
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 807224e..d234234 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -1006,6 +1006,39 @@ error:
>  	return retval;
>  }
>  
> +static void pci_remove_slot_links(struct pci_dev *dev)
> +{
> +	char func[10];
> +	struct pci_slot *slot;
> +
> +	sysfs_remove_link(&dev->dev.kobj, "slot");
> +	list_for_each_entry(slot, &dev->bus->slots, list) {
> +		if (slot->number != PCI_SLOT(dev->devfn))
> +			continue;
> +		snprintf(func, 10, "function%d", PCI_FUNC(dev->devfn));
> +		sysfs_remove_link(&slot->kobj, func);
> +	}
> +}
> +
> +static int pci_create_slot_links(struct pci_dev *dev)
> +{
> +	int result = 0;
> +	char func[10];
> +	struct pci_slot *slot;
> +
> +	list_for_each_entry(slot, &dev->bus->slots, list) {
> +		if (slot->number != PCI_SLOT(dev->devfn))
> +			continue;
> +		result = sysfs_create_link(&dev->dev.kobj, &slot->kobj, "slot");
> +		if (result)
> +			goto out;
> +		snprintf(func, 10, "function%d", PCI_FUNC(dev->devfn));
> +		result = sysfs_create_link(&slot->kobj, &dev->dev.kobj, func);
> +	}
> +out:
> +	return result;
> +}
> +
>  int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
>  {
>  	int retval;
> @@ -1067,6 +1100,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
>  	if (retval)
>  		goto err_vga_file;
>  
> +	pci_create_slot_links(pdev);
> +
>  	return 0;
>  
>  err_vga_file:
> @@ -1116,6 +1151,8 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
>  	if (!sysfs_initialized)
>  		return;
>  
> +	pci_remove_slot_links(pdev);
> +
>  	pci_remove_capabilities_sysfs(pdev);
>  
>  	if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
> index 49c9e6c..a8e22c6 100644
> --- a/drivers/pci/slot.c
> +++ b/drivers/pci/slot.c
> @@ -96,6 +96,50 @@ static ssize_t cur_speed_read_file(struct pci_slot *slot, char *buf)
>  	return bus_speed_read(slot->bus->cur_bus_speed, buf);
>  }
>  
> +static void remove_sysfs_files(struct pci_slot *slot)
> +{
> +	char func[10];
> +	struct list_head *tmp;
> +
> +	list_for_each(tmp, &slot->bus->devices) {
> +		struct pci_dev *dev = pci_dev_b(tmp);
> +		if (PCI_SLOT(dev->devfn) != slot->number)
> +			continue;
> +		sysfs_remove_link(&dev->dev.kobj, "slot");
> +
> +		snprintf(func, 10, "function%d", PCI_FUNC(dev->devfn));
> +		sysfs_remove_link(&slot->kobj, func);
> +	}
> +}
> +
> +static int create_sysfs_files(struct pci_slot *slot)
> +{
> +	int result;
> +	char func[10];
> +	struct list_head *tmp;
> +
> +	list_for_each(tmp, &slot->bus->devices) {
> +		struct pci_dev *dev = pci_dev_b(tmp);
> +		if (PCI_SLOT(dev->devfn) != slot->number)
> +			continue;
> +
> +		result = sysfs_create_link(&dev->dev.kobj, &slot->kobj, "slot");
> +		if (result)
> +			goto fail;
> +
> +		snprintf(func, 10, "function%d", PCI_FUNC(dev->devfn));
> +		result = sysfs_create_link(&slot->kobj, &dev->dev.kobj, func);
> +		if (result)
> +			goto fail;
> +	}
> +
> +	return 0;
> +
> +fail:
> +	remove_sysfs_files(slot);
> +	return result;
> +}
> +
>  static void pci_slot_release(struct kobject *kobj)
>  {
>  	struct pci_dev *dev;
> @@ -108,6 +152,8 @@ static void pci_slot_release(struct kobject *kobj)
>  		if (PCI_SLOT(dev->devfn) == slot->number)
>  			dev->slot = NULL;
>  
> +	remove_sysfs_files(slot);
> +
>  	list_del(&slot->list);
>  
>  	kfree(slot);
> @@ -299,6 +345,8 @@ placeholder:
>  	INIT_LIST_HEAD(&slot->list);
>  	list_add(&slot->list, &parent->slots);
>  
> +	create_sysfs_files(slot);
> +
>  	list_for_each_entry(dev, &parent->devices, bus_list)
>  		if (PCI_SLOT(dev->devfn) == slot_nr)
>  			dev->slot = slot;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/
  2010-03-09  1:16 ` Kenji Kaneshige
@ 2010-03-10 18:15   ` Alex Chiang
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Chiang @ 2010-03-10 18:15 UTC (permalink / raw)
  To: Kenji Kaneshige; +Cc: Jesse Barnes, linux-pci, linux-kernel, willy

Hello Kenji-san,

* Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>:
> Alex Chiang wrote:
>> Create convenience symlinks in sysfs, linking slots to device
>> functions, and vice versa. These links make it easier for users to
>> figure out which devices actually live in what slots.
>>
>> For example:
>>
>> sapphire:/sys/bus/pci/slots # ls
>> 1  10  2  3  4  5  6  7  8  9
>>
>> sapphire:/sys/bus/pci/slots # ls -l 3
>> total 0
>> -r--r--r-- 1 root root 65536 Aug 18 14:10 address
>> lrwxrwxrwx 1 root root     0 Aug 18 14:10 function0 ->
>> ../../../../devices/pci0000:23/0000:23:01.0
>> lrwxrwxrwx 1 root root     0 Aug 18 14:10 function1 ->
>> ../../../../devices/pci0000:23/0000:23:01.1
>>
>
> I usually get the similar information like the followings. Is
> it not enough for you?
>
> # /sbin/lspci -s `cat /sys/bus/pci/slots/1/address`
> 40:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06)
> 40:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06)
>
>> sapphire:/sys/bus/pci/slots # ls -l 3/function0/slot
>> lrwxrwxrwx 1 root root 0 Aug 18 14:13 3/function0/slot ->
>> ../../../bus/pci/slots/3
>
> IIRC, the latest 'lspci' command shows physical slot
> information (you added this useful feature, didn't you?). Is it
> not enough for you?

You're right, it's certainly possible to get all that information
using lspci (and yes, I did add the physical slot information ;).

I just thought that these symlinks would be quite convenient, so
that you don't have to traverse around in the sysfs tree quite so
much if you want to find other properties of your physical
device, such as net:ethX, etc.

However, I talked with my manageability userspace team and they
do not really need the links either.

I'll leave it up to Jesse. I think this is a useful feature, I
don't think it's too hard to support as a kernel ABI, but I also
agree that it's not entirely necessary.

Thanks.
/ac


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/
  2010-03-08 17:24 [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/ Alex Chiang
  2010-03-09  1:16 ` Kenji Kaneshige
@ 2010-03-19 21:46 ` Jesse Barnes
  2010-03-20 17:52   ` Yinghai Lu
  1 sibling, 1 reply; 7+ messages in thread
From: Jesse Barnes @ 2010-03-19 21:46 UTC (permalink / raw)
  To: Alex Chiang; +Cc: linux-pci, linux-kernel, willy

On Mon, 8 Mar 2010 10:24:29 -0700
Alex Chiang <achiang@hp.com> wrote:

> Create convenience symlinks in sysfs, linking slots to device
> functions, and vice versa. These links make it easier for users to
> figure out which devices actually live in what slots.
> 
> For example:

Applied to linux-next, thanks.

-- 
Jesse Barnes, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/
  2010-03-19 21:46 ` Jesse Barnes
@ 2010-03-20 17:52   ` Yinghai Lu
  2010-03-20 18:22     ` Yinghai Lu
  2010-03-22 18:17     ` Alex Chiang
  0 siblings, 2 replies; 7+ messages in thread
From: Yinghai Lu @ 2010-03-20 17:52 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: Alex Chiang, linux-pci, linux-kernel, willy

On Fri, Mar 19, 2010 at 2:46 PM, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
> On Mon, 8 Mar 2010 10:24:29 -0700
> Alex Chiang <achiang@hp.com> wrote:
>
>> Create convenience symlinks in sysfs, linking slots to device
>> functions, and vice versa. These links make it easier for users to
>> figure out which devices actually live in what slots.
>>
>> For example:
>
> Applied to linux-next, thanks.

looks this one cause

[  225.210695] calling  pci_sysfs_init+0x0/0x51 @ 1
[  225.224774] ------------[ cut here ]------------
[  225.228913] WARNING: at fs/sysfs/dir.c:451 sysfs_add_one+0xd9/0xf3()
[  225.245349] Hardware name: Sun Fire x4800
[  225.247894] sysfs: cannot create duplicate filename
'/devices/pci0000:00/0000:00:03.0/0000:02:00.0/slot'
[  225.268122] Modules linked in:
[  225.270966] Pid: 1, comm: swapper Not tainted
2.6.34-rc2-tip-yh-03489-gae232d1-dirty #684
[  225.286652] Call Trace:
[  225.288878]  [<ffffffff81079c04>] warn_slowpath_common+0x7c/0x94
[  225.306239]  [<ffffffff81079c73>] warn_slowpath_fmt+0x41/0x43
[  225.310655]  [<ffffffff811868ff>] sysfs_add_one+0xd9/0xf3
[  225.326012]  [<ffffffff8118753a>] sysfs_do_create_link+0xce/0x13c
[  225.330730]  [<ffffffff81186114>] ? sysfs_create_file+0x2a/0x2c
[  225.346429]  [<ffffffff811875cd>] sysfs_create_link+0x13/0x16
[  225.350303]  [<ffffffff813ee209>] pci_create_sysfs_dev_files+0x28e/0x3a1
[  225.367131]  [<ffffffff826c4c1a>] pci_sysfs_init+0x1f/0x51
[  225.382825]  [<ffffffff826c4bfb>] ? pci_sysfs_init+0x0/0x51
[  225.388122]  [<ffffffff826c4bfb>] ? pci_sysfs_init+0x0/0x51
[  225.403175]  [<ffffffff826c4bfb>] ? pci_sysfs_init+0x0/0x51
[  225.407330]  [<ffffffff8100020d>] do_one_initcall+0x72/0x17f
[  225.423173]  [<ffffffff8269b6d6>] do_basic_setup+0x54/0x66
[  225.428494]  [<ffffffff8269b782>] kernel_init+0x9a/0x111
[  225.443106]  [<ffffffff81bfa7ae>] ? trace_hardirqs_on_thunk+0x3a/0x3f
[  225.447205]  [<ffffffff810349d4>] kernel_thread_helper+0x4/0x10
[  225.464053]  [<ffffffff81bfb63c>] ? restore_args+0x0/0x30
[  225.467298]  [<ffffffff8269b6e8>] ? kernel_init+0x0/0x111
[  225.483514]  [<ffffffff810349d0>] ? kernel_thread_helper+0x0/0x10
[  225.487928] ---[ end trace c9d3fb1a8a3caa22 ]---

the system has pcie hotplug support.

YH

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/
  2010-03-20 17:52   ` Yinghai Lu
@ 2010-03-20 18:22     ` Yinghai Lu
  2010-03-22 18:17     ` Alex Chiang
  1 sibling, 0 replies; 7+ messages in thread
From: Yinghai Lu @ 2010-03-20 18:22 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: Alex Chiang, linux-pci, linux-kernel, willy

On Sat, Mar 20, 2010 at 10:52 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Mar 19, 2010 at 2:46 PM, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
>> On Mon, 8 Mar 2010 10:24:29 -0700
>> Alex Chiang <achiang@hp.com> wrote:
>>
>>> Create convenience symlinks in sysfs, linking slots to device
>>> functions, and vice versa. These links make it easier for users to
>>> figure out which devices actually live in what slots.
>>>
>>> For example:
>>
>> Applied to linux-next, thanks.
>
> looks this one cause
>
> [  225.210695] calling  pci_sysfs_init+0x0/0x51 @ 1
> [  225.224774] ------------[ cut here ]------------
> [  225.228913] WARNING: at fs/sysfs/dir.c:451 sysfs_add_one+0xd9/0xf3()
> [  225.245349] Hardware name: Sun Fire x4800
> [  225.247894] sysfs: cannot create duplicate filename
> '/devices/pci0000:00/0000:00:03.0/0000:02:00.0/slot'
> [  225.268122] Modules linked in:
> [  225.270966] Pid: 1, comm: swapper Not tainted
> 2.6.34-rc2-tip-yh-03489-gae232d1-dirty #684
> [  225.286652] Call Trace:
> [  225.288878]  [<ffffffff81079c04>] warn_slowpath_common+0x7c/0x94
> [  225.306239]  [<ffffffff81079c73>] warn_slowpath_fmt+0x41/0x43
> [  225.310655]  [<ffffffff811868ff>] sysfs_add_one+0xd9/0xf3
> [  225.326012]  [<ffffffff8118753a>] sysfs_do_create_link+0xce/0x13c
> [  225.330730]  [<ffffffff81186114>] ? sysfs_create_file+0x2a/0x2c
> [  225.346429]  [<ffffffff811875cd>] sysfs_create_link+0x13/0x16
> [  225.350303]  [<ffffffff813ee209>] pci_create_sysfs_dev_files+0x28e/0x3a1
> [  225.367131]  [<ffffffff826c4c1a>] pci_sysfs_init+0x1f/0x51
> [  225.382825]  [<ffffffff826c4bfb>] ? pci_sysfs_init+0x0/0x51
> [  225.388122]  [<ffffffff826c4bfb>] ? pci_sysfs_init+0x0/0x51
> [  225.403175]  [<ffffffff826c4bfb>] ? pci_sysfs_init+0x0/0x51
> [  225.407330]  [<ffffffff8100020d>] do_one_initcall+0x72/0x17f
> [  225.423173]  [<ffffffff8269b6d6>] do_basic_setup+0x54/0x66
> [  225.428494]  [<ffffffff8269b782>] kernel_init+0x9a/0x111
> [  225.443106]  [<ffffffff81bfa7ae>] ? trace_hardirqs_on_thunk+0x3a/0x3f
> [  225.447205]  [<ffffffff810349d4>] kernel_thread_helper+0x4/0x10
> [  225.464053]  [<ffffffff81bfb63c>] ? restore_args+0x0/0x30
> [  225.467298]  [<ffffffff8269b6e8>] ? kernel_init+0x0/0x111
> [  225.483514]  [<ffffffff810349d0>] ? kernel_thread_helper+0x0/0x10
> [  225.487928] ---[ end trace c9d3fb1a8a3caa22 ]---
>
> the system has pcie hotplug support.

revert that patch, make the warning go away.

YH

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/
  2010-03-20 17:52   ` Yinghai Lu
  2010-03-20 18:22     ` Yinghai Lu
@ 2010-03-22 18:17     ` Alex Chiang
  1 sibling, 0 replies; 7+ messages in thread
From: Alex Chiang @ 2010-03-22 18:17 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Jesse Barnes, linux-pci, linux-kernel, willy

* Yinghai Lu <yinghai@kernel.org>:
> On Fri, Mar 19, 2010 at 2:46 PM, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
> > On Mon, 8 Mar 2010 10:24:29 -0700
> > Alex Chiang <achiang@hp.com> wrote:
> >
> >> Create convenience symlinks in sysfs, linking slots to device
> >> functions, and vice versa. These links make it easier for users to
> >> figure out which devices actually live in what slots.
> >>
> >> For example:
> >
> > Applied to linux-next, thanks.
> 
> looks this one cause
> 
> [  225.210695] calling  pci_sysfs_init+0x0/0x51 @ 1
> [  225.224774] ------------[ cut here ]------------
> [  225.228913] WARNING: at fs/sysfs/dir.c:451 sysfs_add_one+0xd9/0xf3()
> [  225.245349] Hardware name: Sun Fire x4800
> [  225.247894] sysfs: cannot create duplicate filename
> '/devices/pci0000:00/0000:00:03.0/0000:02:00.0/slot'

That's really not supposed to happen.

It means that somehow, a single pci_dev is associated with
multiple slots.

There are dev_dbg statements in pci_create_slot() that should
display which slots are getting associated with which pci_dev
during initialization.

Can you please turn those debug statements on and send the
output?

Thanks,
/ac


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-03-22 18:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-08 17:24 [PATCH] PCI: create function symlinks in /sys/bus/pci/slots/N/ Alex Chiang
2010-03-09  1:16 ` Kenji Kaneshige
2010-03-10 18:15   ` Alex Chiang
2010-03-19 21:46 ` Jesse Barnes
2010-03-20 17:52   ` Yinghai Lu
2010-03-20 18:22     ` Yinghai Lu
2010-03-22 18:17     ` Alex Chiang

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.