Re: [PATCH] PCI: add PCI Express Port Bus Driver subsystem

2005-01-31 Thread Greg KH
On Mon, Jan 24, 2005 at 12:10:25PM -0800, long wrote:
> On Tuesday, January 18, 2005 5:03 PM Greg KH wrote:
> >> >
> >> >That would be great, but it doesn't show up that way on my box.  All
> >> >of
> >> >the portX devices are in /sys/devices/ which is what I don't think
> >> >you
> >> >want.  I would love for them to have the parent of the pci_dev
> >> >structure
> >> >:)
> >> 
> >> Agree. Thanks for your inputs. The patch below include the changes
> >> based on your previous post.
> >
> >Hm, that seems like a pretty big patch just to add a pointer to a parent
> >device :)
> >
> >What really does this patch do?  What does the sysfs tree now look like?
> 
> Before changes:
> 
> The patch makes the parent of the device pointing to the pci_dev
> structure. The parents portX devices are in /sys/devices which
> should be removed based on your suggestions. Below is /sys/devices
> before any changes made.
> 
> /sys/devices
>   |
>   __ ide0 
>   |
>   __ pci:00
>   |
>   __ pnp0
>   |
>   __ port1
>   |   |
>   |   __ port1.00
>   |   |
>   |   __ port1.01
>   |   .
>   |   .
>   |   .
>   |
>   __ port2
>   |
>   __ port3
>   |
>   __ system
> 
> After changes:
> 
> The parents portX devices are no longer necessary because port1.00
> and port1.01 devices shoud have the parent of the pci_dev structure
> (based on your suggestion). The patch does the following changes:
> 
> - remove code creating and handling the parent portX devices.
> - rename portX.YZ to pcieYZ (for example port1.00 renamed to pcie00)
>   since portX is no longer needed.
> - make pcieYZ have the parent of the pci_dev structure.
> 
> Below is /sys/devices after changes made to the patch.
> 
> /sys/devices
>   |
>   __ ide0 
>   |
>   __ pci:00
>   |   |
>   |   __ :00:00.0
>   |   |
>   |   __ :00:04.0
>   |   |   |
>   |   .   __ class
>   |   .   |
>   |   .   __ pcie00
>   |   |
>   |   __ pcie01
>   |   .
>   |   .   
>   |   .
>   |
>   __ platform
>   |
>   __ pnp0
>   |
>   __ system
> 
> 
> Please let me know what you think of the changes.

Ok, that makes more sense now.  I've applied your patch, thanks.

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re:[PATCH] PCI: add PCI Express Port Bus Driver subsystem

2005-01-24 Thread long
On Tuesday, January 18, 2005 5:03 PM Greg KH wrote:
>> >
>> >That would be great, but it doesn't show up that way on my box.  All
>> >of
>> >the portX devices are in /sys/devices/ which is what I don't think
>> >you
>> >want.  I would love for them to have the parent of the pci_dev
>> >structure
>> >:)
>> 
>> Agree. Thanks for your inputs. The patch below include the changes
>> based on your previous post.
>
>Hm, that seems like a pretty big patch just to add a pointer to a parent
>device :)
>
>What really does this patch do?  What does the sysfs tree now look like?

Before changes:

The patch makes the parent of the device pointing to the pci_dev
structure. The parents portX devices are in /sys/devices which
should be removed based on your suggestions. Below is /sys/devices
before any changes made.

/sys/devices
|
__ ide0 
|
__ pci:00
|
__ pnp0
|
__ port1
|   |
|   __ port1.00
|   |
|   __ port1.01
|   .
|   .
|   .
|
__ port2
|
__ port3
|
__ system

After changes:

The parents portX devices are no longer necessary because port1.00
and port1.01 devices shoud have the parent of the pci_dev structure
(based on your suggestion). The patch does the following changes:

- remove code creating and handling the parent portX devices.
- rename portX.YZ to pcieYZ (for example port1.00 renamed to pcie00)
  since portX is no longer needed.
- make pcieYZ have the parent of the pci_dev structure.

Below is /sys/devices after changes made to the patch.

/sys/devices
|
__ ide0 
|
__ pci:00
|   |
|   __ :00:00.0
|   |
|   __ :00:04.0
|   |   |
|   .   __ class
|   .   |
|   .   __ pcie00
|   |
|   __ pcie01
|   .
|   .   
|   .
|
__ platform
|
__ pnp0
|
__ system


Please let me know what you think of the changes.

Thanks,
Long
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] PCI: add PCI Express Port Bus Driver subsystem

2005-01-18 Thread Greg KH
On Tue, Jan 18, 2005 at 05:59:44PM -0800, long wrote:
> On Tue Jan 18 11:41:01 2005 Greg KH wrote:
> >> >
> >> >
> >> > This puts all of the pcie "port" structures in /sys/devices/  Shouldn't
> >> > you make the parent of the device you create point to the pci_dev
> >> > structure that's passed into this function?  That would make the sysfs
> >> > tree a lot saner I think.
> >> 
> >> The patch makes the parent of the device point to the pci_dev structure
> >> that is passed into this function. If you think it is cleaner that the
> >> patch should not, I will update the patch to reflect your input.
> >
> >That would be great, but it doesn't show up that way on my box.  All of
> >the portX devices are in /sys/devices/ which is what I don't think you
> >want.  I would love for them to have the parent of the pci_dev structure
> >:)
> 
> Agree. Thanks for your inputs. The patch below include the changes based
> on your previous post.

Hm, that seems like a pretty big patch just to add a pointer to a parent
device :)

What really does this patch do?  What does the sysfs tree now look like?

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re:[PATCH] PCI: add PCI Express Port Bus Driver subsystem

2005-01-18 Thread long
On Tue Jan 18 11:41:01 2005 Greg KH wrote:
>> >
>> >
>> > This puts all of the pcie "port" structures in /sys/devices/  Shouldn't
>> > you make the parent of the device you create point to the pci_dev
>> > structure that's passed into this function?  That would make the sysfs
>> > tree a lot saner I think.
>> 
>> The patch makes the parent of the device point to the pci_dev structure
>> that is passed into this function. If you think it is cleaner that the
>> patch should not, I will update the patch to reflect your input.
>
>That would be great, but it doesn't show up that way on my box.  All of
>the portX devices are in /sys/devices/ which is what I don't think you
>want.  I would love for them to have the parent of the pci_dev structure
>:)

Agree. Thanks for your inputs. The patch below include the changes based
on your previous post.

Signed-off-by: T. Long Nguyen <[EMAIL PROTECTED]>

-
diff -urpN greg-patch/drivers/pci/pcie/portdrv_bus.c 
greg-patch-update/drivers/pci/pcie/portdrv_bus.c
--- greg-patch/drivers/pci/pcie/portdrv_bus.c   2005-01-18 15:59:38.0 
-0500
+++ greg-patch-update/drivers/pci/pcie/portdrv_bus.c2005-01-18 
16:03:47.0 -0500
@@ -14,8 +14,6 @@
 
 #include 
 
-static int generic_probe (struct device *dev) {return 0;}
-static int generic_remove (struct device *dev) { return 0;}
 static int pcie_port_bus_match(struct device *dev, struct device_driver *drv);
 static int pcie_port_bus_suspend(struct device *dev, u32 state);
 static int pcie_port_bus_resume(struct device *dev);
@@ -27,23 +25,14 @@ struct bus_type pcie_port_bus_type = {
.resume = pcie_port_bus_resume, 
 };
 
-struct device_driver pcieport_generic_driver = {
-   .name = "pcieport",
-   .bus = &pcie_port_bus_type,
-   .probe = generic_probe,
-   .remove = generic_remove,
-};
-
 static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
 {
struct pcie_device *pciedev;
struct pcie_port_service_driver *driver;
 
-   if (drv->bus != &pcie_port_bus_type || 
-   dev->bus != &pcie_port_bus_type ||
-   drv == &pcieport_generic_driver) {
+   if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type)
return 0;
-   }
+   
pciedev = to_pcie_device(dev);
driver = to_service_driver(drv);
if (   (driver->id_table->vendor != PCI_ANY_ID && 
diff -urpN greg-patch/drivers/pci/pcie/portdrv_core.c 
greg-patch-update/drivers/pci/pcie/portdrv_core.c
--- greg-patch/drivers/pci/pcie/portdrv_core.c  2005-01-18 15:59:38.0 
-0500
+++ greg-patch-update/drivers/pci/pcie/portdrv_core.c   2005-01-18 
16:06:51.0 -0500
@@ -17,8 +17,6 @@
 
 extern int pcie_mch_quirk; /* MSI-quirk Indicator */
 
-extern struct device_driver pcieport_generic_driver;
-
 static int pcie_port_probe_service(struct device *dev)
 {
struct pcie_device *pciedev;
@@ -103,6 +101,7 @@ static int pcie_port_resume_service(stru
  */
 static void release_pcie_device(struct device *dev)
 {
+   printk(KERN_DEBUG "Free Port Service[%s]\n", dev->bus_id);
kfree(to_pcie_device(dev)); 
 }
 
@@ -217,18 +216,18 @@ static int get_port_device_capability(st
return services;
 }
 
-static void pcie_device_init(struct pcie_device *parent, 
-   struct pcie_device *dev, 
-   int port_type, int service_type)
+static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev, 
+   int port_type, int service_type, int irq, int irq_mode)
 {
struct device *device;
 
-   if (parent) {
-   dev->id.vendor = parent->port->vendor;
-   dev->id.device = parent->port->device;
-   dev->id.port_type = port_type;
-   dev->id.service_type = (1 << service_type);
-   }
+   dev->port = parent;
+   dev->interrupt_mode = irq_mode;
+   dev->irq = irq;
+   dev->id.vendor = parent->vendor;
+   dev->id.device = parent->device;
+   dev->id.port_type = port_type;
+   dev->id.service_type = (1 << service_type);
 
/* Initialize generic device interface */
device = &dev->device;
@@ -240,35 +239,23 @@ static void pcie_device_init(struct pcie
device->driver = NULL;
device->driver_data = NULL; 
device->release = release_pcie_device;  /* callback to free pcie dev */
-   sprintf(&device->bus_id[0], "%s.%02x", parent->device.bus_id, 
-   get_descriptor_id(port_type, service_type));
-   device->parent = ((parent == NULL) ? NULL : &parent->device);
+   sprintf(&device->bus_id[0], "pcie%02x", 
+   get_descriptor_id(port_type, service_type));
+   device->parent = &parent->dev;
 }
 
-static struct pcie_device* alloc_pcie_device(
-   struct pcie_device *parent, struct pci_dev *bridge, 
+static str

Re: [PATCH] PCI: add PCI Express Port Bus Driver subsystem

2005-01-18 Thread Greg KH
On Tue, Jan 18, 2005 at 11:28:57AM -0800, long wrote:
> On Mon, 17 Jan 2005 15:49:08 -0800 Greg KH wrote:
> > > +int pcie_port_device_register(struct pci_dev *dev)
> > > +{
> > > + struct pcie_device *parent;
> > > + int status, type, capabilities, irq_mode, i;
> > > + int vectors[PCIE_PORT_DEVICE_MAXSERVICES];
> > > + u16 reg16;
> > > +
> > > + /* Get port type */
> > > + pci_read_config_word(dev, 
> > > + pci_find_capability(dev, PCI_CAP_ID_EXP) + 
> > > + PCIE_CAPABILITIES_REG, ®16);
> > > + type = (reg16 >> 4) & PORT_TYPE_MASK;
> > > +
> > > + /* Now get port services */
> > > + capabilities = get_port_device_capability(dev);
> > > + irq_mode = assign_interrupt_mode(dev, vectors, capabilities);
> > > +
> > > + /* Allocate parent */
> > > + parent = alloc_pcie_device(NULL, dev, type, 0, dev->irq, irq_mode);
> > > + if (!parent) 
> > > + return -ENOMEM;
> > > + 
> > > + status = device_register(&parent->device);
> > > + if (status) {
> > > + kfree(parent);
> > > + return status;
> > > + }
> >
> >
> > This puts all of the pcie "port" structures in /sys/devices/  Shouldn't
> > you make the parent of the device you create point to the pci_dev
> > structure that's passed into this function?  That would make the sysfs
> > tree a lot saner I think.
> 
> The patch makes the parent of the device point to the pci_dev structure
> that is passed into this function. If you think it is cleaner that the
> patch should not, I will update the patch to reflect your input.

That would be great, but it doesn't show up that way on my box.  All of
the portX devices are in /sys/devices/ which is what I don't think you
want.  I would love for them to have the parent of the pci_dev structure
:)

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re:[PATCH] PCI: add PCI Express Port Bus Driver subsystem

2005-01-18 Thread long
On Mon, 17 Jan 2005 15:49:08 -0800 Greg KH wrote:
> > +int pcie_port_device_register(struct pci_dev *dev)
> > +{
> > +   struct pcie_device *parent;
> > +   int status, type, capabilities, irq_mode, i;
> > +   int vectors[PCIE_PORT_DEVICE_MAXSERVICES];
> > +   u16 reg16;
> > +
> > +   /* Get port type */
> > +   pci_read_config_word(dev, 
> > +   pci_find_capability(dev, PCI_CAP_ID_EXP) + 
> > +   PCIE_CAPABILITIES_REG, ®16);
> > +   type = (reg16 >> 4) & PORT_TYPE_MASK;
> > +
> > +   /* Now get port services */
> > +   capabilities = get_port_device_capability(dev);
> > +   irq_mode = assign_interrupt_mode(dev, vectors, capabilities);
> > +
> > +   /* Allocate parent */
> > +   parent = alloc_pcie_device(NULL, dev, type, 0, dev->irq, irq_mode);
> > +   if (!parent) 
> > +   return -ENOMEM;
> > +   
> > +   status = device_register(&parent->device);
> > +   if (status) {
> > +   kfree(parent);
> > +   return status;
> > +   }
>
>
> This puts all of the pcie "port" structures in /sys/devices/  Shouldn't
> you make the parent of the device you create point to the pci_dev
> structure that's passed into this function?  That would make the sysfs
> tree a lot saner I think.

The patch makes the parent of the device point to the pci_dev structure
that is passed into this function. If you think it is cleaner that the
patch should not, I will update the patch to reflect your input.

Thanks,
Long 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] PCI: add PCI Express Port Bus Driver subsystem

2005-01-17 Thread Greg KH
On Mon, Jan 17, 2005 at 02:01:52PM -0800, Greg KH wrote:
> +int pcie_port_device_register(struct pci_dev *dev)
> +{
> + struct pcie_device *parent;
> + int status, type, capabilities, irq_mode, i;
> + int vectors[PCIE_PORT_DEVICE_MAXSERVICES];
> + u16 reg16;
> +
> + /* Get port type */
> + pci_read_config_word(dev, 
> + pci_find_capability(dev, PCI_CAP_ID_EXP) + 
> + PCIE_CAPABILITIES_REG, ®16);
> + type = (reg16 >> 4) & PORT_TYPE_MASK;
> +
> + /* Now get port services */
> + capabilities = get_port_device_capability(dev);
> + irq_mode = assign_interrupt_mode(dev, vectors, capabilities);
> +
> + /* Allocate parent */
> + parent = alloc_pcie_device(NULL, dev, type, 0, dev->irq, irq_mode);
> + if (!parent) 
> + return -ENOMEM;
> + 
> + status = device_register(&parent->device);
> + if (status) {
> + kfree(parent);
> + return status;
> + }


This puts all of the pcie "port" structures in /sys/devices/  Shouldn't
you make the parent of the device you create point to the pci_dev
structure that's passed into this function?  That would make the sysfs
tree a lot saner I think.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] PCI: add PCI Express Port Bus Driver subsystem

2005-01-17 Thread Greg KH
ChangeSet 1.2329.2.1, 2005/01/14 15:56:18-08:00, [EMAIL PROTECTED]

[PATCH] PCI: add PCI Express Port Bus Driver subsystem

Signed-off-by: T. Long Nguyen <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 Documentation/PCIEBUS-HOWTO.txt   |  217 ++
 arch/i386/Kconfig |2 
 drivers/Makefile  |1 
 drivers/pci/hotplug/Kconfig   |   21 -
 drivers/pci/hotplug/pciehp.h  |3 
 drivers/pci/hotplug/pciehp_core.c |   83 --
 drivers/pci/hotplug/pciehp_hpc.c  |   21 -
 drivers/pci/pcie/Kconfig  |   38 +++
 drivers/pci/pcie/Makefile |7 
 drivers/pci/pcie/portdrv.h|   42 +++
 drivers/pci/pcie/portdrv_bus.c|   88 +++
 drivers/pci/pcie/portdrv_core.c   |  453 ++
 drivers/pci/pcie/portdrv_pci.c|  138 +++
 include/linux/pcieport_if.h   |   74 ++
 14 files changed, 1123 insertions(+), 65 deletions(-)


diff -Nru a/Documentation/PCIEBUS-HOWTO.txt b/Documentation/PCIEBUS-HOWTO.txt
--- /dev/null   Wed Dec 31 16:00:00 196900
+++ b/Documentation/PCIEBUS-HOWTO.txt   2005-01-17 13:56:37 -08:00
@@ -0,0 +1,217 @@
+   The PCI Express Port Bus Driver Guide HOWTO
+   Tom L Nguyen [EMAIL PROTECTED]
+   11/03/2004
+
+1. About this guide
+
+This guide describes the basics of the PCI Express Port Bus driver
+and provides information on how to enable the service drivers to
+register/unregister with the PCI Express Port Bus Driver.
+
+2. Copyright 2004 Intel Corporation
+
+3. What is the PCI Express Port Bus Driver
+
+A PCI Express Port is a logical PCI-PCI Bridge structure. There
+are two types of PCI Express Port: the Root Port and the Switch
+Port. The Root Port originates a PCI Express link from a PCI Express
+Root Complex and the Switch Port connects PCI Express links to
+internal logical PCI buses. The Switch Port, which has its secondary
+bus representing the switch's internal routing logic, is called the
+switch's Upstream Port. The switch's Downstream Port is bridging from
+switch's internal routing bus to a bus representing the downstream
+PCI Express link from the PCI Express Switch.
+
+A PCI Express Port can provide up to four distinct functions,
+referred to in this document as services, depending on its port type.
+PCI Express Port's services include native hotplug support (HP),
+power management event support (PME), advanced error reporting
+support (AER), and virtual channel support (VC). These services may
+be handled by a single complex driver or be individually distributed
+and handled by corresponding service drivers.
+
+4. Why use the PCI Express Port Bus Driver?
+
+In existing Linux kernels, the Linux Device Driver Model allows a
+physical device to be handled by only a single driver. The PCI
+Express Port is a PCI-PCI Bridge device with multiple distinct
+services. To maintain a clean and simple solution each service
+may have its own software service driver. In this case several
+service drivers will compete for a single PCI-PCI Bridge device.
+For example, if the PCI Express Root Port native hotplug service
+driver is loaded first, it claims a PCI-PCI Bridge Root Port. The
+kernel therefore does not load other service drivers for that Root
+Port. In other words, it is impossible to have multiple service
+drivers load and run on a PCI-PCI Bridge device simultaneously
+using the current driver model.
+
+To enable multiple service drivers running simultaneously requires
+having a PCI Express Port Bus driver, which manages all populated
+PCI Express Ports and distributes all provided service requests
+to the corresponding service drivers as required. Some key
+advantages of using the PCI Express Port Bus driver are listed below:
+
+   - Allow multiple service drivers to run simultaneously on
+ a PCI-PCI Bridge Port device.
+
+   - Allow service drivers implemented in an independent
+ staged approach.
+   
+   - Allow one service driver to run on multiple PCI-PCI Bridge
+ Port devices. 
+
+   - Manage and distribute resources of a PCI-PCI Bridge Port
+ device to requested service drivers.
+
+5. Configuring the PCI Express Port Bus Driver vs. Service Drivers
+
+5.1 Including the PCI Express Port Bus Driver Support into the Kernel
+
+Including the PCI Express Port Bus driver depends on whether the PCI
+Express support is included in the kernel config. The kernel will
+automatically include the PCI Express Port Bus driver as a kernel
+driver when the PCI Express support is enabled in the kernel.
+
+5.2 Enabling Service Driver Support
+
+PCI device drivers are implemented based on Linux Device Driver Model.
+All service drivers are PCI device drivers. As discussed above, it is
+impossible to load any service driver once the kernel has loaded the
+PCI Express Port Bus Driver. To meet the PCI Express Port Bus Driver
+M