All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] sparc64: pci slots information is not populated in sysfs
@ 2015-04-28 20:51 Eric Snowberg
  2015-05-14  3:55 ` David Miller
  2015-05-15  3:53 ` Eric Snowberg
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Snowberg @ 2015-04-28 20:51 UTC (permalink / raw)
  To: sparclinux

Add PCI slot numbers within sysfs for sun4v hardware. Larger
sun4v systems contain nested PCI bridges and slots further
down on these bridges were not being populated within sysfs.
Also add ACPI style PCI slot numbers within sysfs for sun4v
hardware since the OF 'slot-names' information is not available
on all sun4v platforms.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>

---
Changes in v2:
  - Addresses Julian Calaby's comments: moved hypervisor test
      outside the while loop and updated the typo in the
      commit comment.
---
 arch/sparc/kernel/pci.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 6f7251f..d5f06bd 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -1002,6 +1002,38 @@ static int __init pcibios_init(void)
 subsys_initcall(pcibios_init);
 
 #ifdef CONFIG_SYSFS
+
+#define SLOT_NAME_SIZE  11  /* Max decimal digits + null in u32 */
+
+static void pci_sun4v_bus_slot_names(struct pci_bus *pbus)
+{
+	struct pci_dev *pdev;
+	struct pci_bus *bus;
+
+	list_for_each_entry(pdev, &pbus->devices, bus_list) {
+		char name[SLOT_NAME_SIZE];
+		struct pci_slot *pci_slot;
+		const u32 *slot_num;
+		int len;
+
+		slot_num = of_get_property(pdev->dev.of_node,
+					   "physical-slot#", &len);
+
+		if (slot_num = NULL || len != 4)
+			continue;
+
+		snprintf(name, sizeof(name), "%u", slot_num[0]);
+		pci_slot = pci_create_slot(pbus, slot_num[0], name, NULL);
+
+		if (IS_ERR(pci_slot))
+			pr_err("PCI: pci_create_slot returned %ld.\n",
+			       PTR_ERR(pci_slot));
+	}
+
+	list_for_each_entry(bus, &pbus->children, node)
+		pci_sun4v_bus_slot_names(bus);
+}
+
 static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus)
 {
 	const struct pci_slot_names {
@@ -1051,6 +1083,13 @@ static int __init of_pci_slot_init(void)
 {
 	struct pci_bus *pbus = NULL;
 
+	if (tlb_type = hypervisor) {
+		while ((pbus = pci_find_next_bus(pbus)) != NULL)
+			pci_sun4v_bus_slot_names(pbus);
+
+		return 0;
+	}
+
 	while ((pbus = pci_find_next_bus(pbus)) != NULL) {
 		struct device_node *node;
 
-- 
1.7.1


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

* Re: [PATCH v2] sparc64: pci slots information is not populated in sysfs
  2015-04-28 20:51 [PATCH v2] sparc64: pci slots information is not populated in sysfs Eric Snowberg
@ 2015-05-14  3:55 ` David Miller
  2015-05-15  3:53 ` Eric Snowberg
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-05-14  3:55 UTC (permalink / raw)
  To: sparclinux

From: Eric Snowberg <eric.snowberg@oracle.com>
Date: Tue, 28 Apr 2015 16:51:17 -0400

> Add PCI slot numbers within sysfs for sun4v hardware. Larger
> sun4v systems contain nested PCI bridges and slots further
> down on these bridges were not being populated within sysfs.
> Also add ACPI style PCI slot numbers within sysfs for sun4v
> hardware since the OF 'slot-names' information is not available
> on all sun4v platforms.
> 
> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
> 
> ---
> Changes in v2:
>   - Addresses Julian Calaby's comments: moved hypervisor test
>       outside the while loop and updated the typo in the
>       commit comment.

This property definitely exists in sun4u systems, "Ultra 45" and "Sun
Fire V245" at a minimum.

You can see this clearly by merely perusing the prtconf dumps in my
'prtconfs' GIT repository.

So it makes no sense at all the limit this code to sun4v systems.

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

* Re: [PATCH v2] sparc64: pci slots information is not populated in sysfs
  2015-04-28 20:51 [PATCH v2] sparc64: pci slots information is not populated in sysfs Eric Snowberg
  2015-05-14  3:55 ` David Miller
@ 2015-05-15  3:53 ` Eric Snowberg
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Snowberg @ 2015-05-15  3:53 UTC (permalink / raw)
  To: sparclinux


> On May 13, 2015, at 9:55 PM, David Miller <davem@davemloft.net> wrote:
> 
> From: Eric Snowberg <eric.snowberg@oracle.com>
> Date: Tue, 28 Apr 2015 16:51:17 -0400
> 
>> Add PCI slot numbers within sysfs for sun4v hardware. Larger
>> sun4v systems contain nested PCI bridges and slots further
>> down on these bridges were not being populated within sysfs.
>> Also add ACPI style PCI slot numbers within sysfs for sun4v
>> hardware since the OF 'slot-names' information is not available
>> on all sun4v platforms.
>> 
>> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
>> 
>> ---
>> Changes in v2:
>>  - Addresses Julian Calaby's comments: moved hypervisor test
>>      outside the while loop and updated the typo in the
>>      commit comment.
> 
> This property definitely exists in sun4u systems, "Ultra 45" and "Sun
> Fire V245" at a minimum.
> 
> You can see this clearly by merely perusing the prtconf dumps in my
> 'prtconfs' GIT repository.
> 
> So it makes no sense at all the limit this code to sun4v systems.

Ok, I’ll send out a v3 patch with these changes.

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

end of thread, other threads:[~2015-05-15  3:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 20:51 [PATCH v2] sparc64: pci slots information is not populated in sysfs Eric Snowberg
2015-05-14  3:55 ` David Miller
2015-05-15  3:53 ` Eric Snowberg

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.