2002-09-17 19:23:20

by Bloch, Jack

[permalink] [raw]
Subject: Linux hot swap support

I have a cPCI system running a Red Hat 2.4.18-3 Kernel. am running on a
Pentium III 700Mhz machine, but we have some of our own cPCI HW. I wrote the
drivers according to the Linux Device Driver 2nd edition (i.e. hot swap
compliant). But what I am missing is :

What SW will call my device insert/device remove routines?
Do I need some 3rd party SW?


Please CC me directly on anty response. By the way I read the PDF file Hot
Pluggable Devices And The Linux Kernel, but I am still not clear on the
answerrs to the above questions.

Jack Bloch
Siemens ICN
phone (561) 923-6550
e-mail [email protected]


2002-09-17 21:07:14

by Alan

[permalink] [raw]
Subject: Re: Linux hot swap support

On Tue, 2002-09-17 at 20:28, Bloch, Jack wrote:
> I have a cPCI system running a Red Hat 2.4.18-3 Kernel. am running on a
> Pentium III 700Mhz machine, but we have some of our own cPCI HW. I wrote the
> drivers according to the Linux Device Driver 2nd edition (i.e. hot swap
> compliant). But what I am missing is :
>
> What SW will call my device insert/device remove routines?
> Do I need some 3rd party SW?

If you are using pci_module_init and related routines the hot plug
drivers will call the probe/remove routines for you. That would normally
be the PCI hotplug layer and a driver for the relevant board which
detects and adds/removes devices

2002-09-18 06:45:04

by Greg KH

[permalink] [raw]
Subject: Re: Linux hot swap support

On Tue, Sep 17, 2002 at 03:28:17PM -0400, Bloch, Jack wrote:
> I have a cPCI system running a Red Hat 2.4.18-3 Kernel. am running on a
> Pentium III 700Mhz machine, but we have some of our own cPCI HW. I wrote the
> drivers according to the Linux Device Driver 2nd edition (i.e. hot swap
> compliant). But what I am missing is :

Do your drivers tie into the existing pci_hotplug core? If so, great,
then your userspace interaction is done.

Do you have a pointer to your driver?

> What SW will call my device insert/device remove routines?

If you use the pci_hotplug core, any userspace program can call them
through pcihpfs.

> Please CC me directly on anty response. By the way I read the PDF file Hot
> Pluggable Devices And The Linux Kernel, but I am still not clear on the
> answerrs to the above questions.

Do you mean this document:
http://www.kroah.com/linux/talks/ols_2001_hotplug_paper/hotplug.ps
? That just details how individual drivers can specify the proper
information so that /sbin/hotplug will load them when hardware that they
support is recognized. It has nothing to do with the pci hotplug core,
for that you might want to take a look at:
http://linuxjournal.com/article.php?sid=5633
but to be honest, that article deals more with how to create a
filesystem for a driver. Hopefully, you can glean some insight into how
the userspace interaction works from it. If you still have questions,
please let me know..

I also have a very dumb program at:
http://www.kroah.com/linux/hotplug/
that can power up and down slots in a pci hotplug system. I have an
even simpler bash script that does the same thing around here somewhere,
if people are interested.

Hope this helps,

greg k-h

2002-09-18 20:32:59

by Greg KH

[permalink] [raw]
Subject: Re: Linux hot swap support

Cced back to lkml as I hate taking things off-line unless it's
necessary, archives are your friend.

On Wed, Sep 18, 2002 at 07:50:49AM -0400, Bloch, Jack wrote:
> Thanks for the response. In my driver init routine, I use the
> pci_module_init( ) to register my driver with the PCI subsystem. Is this
> enough?

No, that's enough to register your driver as a PCI driver. I'm guessing
your pci hotplug controller looks like a PCI device?

> What exactly is the hotplug_core and or pcihpfs?

See drivers/hotplug/pci_hotplug.h for the interface that a pci hotplug
controller driver needs to interface with (specifcly the
pci_hp_register() and pci_hp_unregister() functions are what you need).

> Do I have to implement the pci_insert_device/pci_remove_device methods
> or does the kernel simply call the probe_one/remove_one which I
> specify during my initialization.

I'm confused, are you talking about a normal PCI card driver, or a PCI
Hotplug controller driver? What exactly does your driver do? Does it
talk to a specific PCI card, or does it control power to PCI slots?

thanks,

greg k-h

2002-09-18 20:54:10

by Bloch, Jack

[permalink] [raw]
Subject: RE: Linux hot swap support

Ok, my driver is for a specific cPCI biard which we have developed here. I
want the Linux Kernel to tell me when this board is inserted and/or removed.
I am running on a 700Mhz PIII with a 2.4.18-3 Kernel (Red Hat 7.3) My driver
is written with a call to pci_module_init in the init routine wherein I
specify a probe and remove routine. According to Linux Device Drivers 2nd
edition (pages 489 - 493), As long as the HW supports hot swap, I should get
called automatically whenevr one of the devices (vendor ID device ID) which
I specified in my table gets inserted or ejected. Am I totaly wrong about
this? I am not trying to write a driver for a hotplug controller but for a
device.

Thanks in advance.

Jack Bloch
Siemens ICN
phone (561) 923-6550
e-mail [email protected]


-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Wednesday, September 18, 2002 4:38 PM
To: Bloch, Jack
Cc: [email protected]
Subject: Re: Linux hot swap support


Cced back to lkml as I hate taking things off-line unless it's
necessary, archives are your friend.

On Wed, Sep 18, 2002 at 07:50:49AM -0400, Bloch, Jack wrote:
> Thanks for the response. In my driver init routine, I use the
> pci_module_init( ) to register my driver with the PCI subsystem. Is this
> enough?

No, that's enough to register your driver as a PCI driver. I'm guessing
your pci hotplug controller looks like a PCI device?

> What exactly is the hotplug_core and or pcihpfs?

See drivers/hotplug/pci_hotplug.h for the interface that a pci hotplug
controller driver needs to interface with (specifcly the
pci_hp_register() and pci_hp_unregister() functions are what you need).

> Do I have to implement the pci_insert_device/pci_remove_device methods
> or does the kernel simply call the probe_one/remove_one which I
> specify during my initialization.

I'm confused, are you talking about a normal PCI card driver, or a PCI
Hotplug controller driver? What exactly does your driver do? Does it
talk to a specific PCI card, or does it control power to PCI slots?

thanks,

greg k-h

2002-09-18 21:00:42

by Greg KH

[permalink] [raw]
Subject: Re: Linux hot swap support

On Wed, Sep 18, 2002 at 04:59:08PM -0400, Bloch, Jack wrote:
> Ok, my driver is for a specific cPCI biard which we have developed here. I
> want the Linux Kernel to tell me when this board is inserted and/or removed.

That will already happen today. /sbin/hotplug will be called whenever a
new PCI card is added or removed, IF you have a PCI Hotplug controller
driver that works for your cPCI board.

> I am running on a 700Mhz PIII with a 2.4.18-3 Kernel (Red Hat 7.3) My driver
> is written with a call to pci_module_init in the init routine wherein I
> specify a probe and remove routine. According to Linux Device Drivers 2nd
> edition (pages 489 - 493), As long as the HW supports hot swap, I should get
> called automatically whenevr one of the devices (vendor ID device ID) which
> I specified in my table gets inserted or ejected. Am I totaly wrong about
> this? I am not trying to write a driver for a hotplug controller but for a
> device.

Yes, you are correct. But odds are there is not a PCI Hotplug
controller for your hardware, so this probably will not work. However,
your driver should work just fine to control your card.

What kind of cPCI controller do you have?

thanks,

greg k-h

2002-09-18 21:04:51

by Bloch, Jack

[permalink] [raw]
Subject: RE: Linux hot swap support

Our HW uses an AMCC S5935 PCI controller. Right now, since we own both
device and SW, we are using a simple interrupt mechanism to accomplish the
hot swap.

Jack Bloch
Siemens ICN
phone (561) 923-6550
e-mail [email protected]


-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Wednesday, September 18, 2002 5:06 PM
To: Bloch, Jack
Cc: [email protected]
Subject: Re: Linux hot swap support


On Wed, Sep 18, 2002 at 04:59:08PM -0400, Bloch, Jack wrote:
> Ok, my driver is for a specific cPCI biard which we have developed here. I
> want the Linux Kernel to tell me when this board is inserted and/or
removed.

That will already happen today. /sbin/hotplug will be called whenever a
new PCI card is added or removed, IF you have a PCI Hotplug controller
driver that works for your cPCI board.

> I am running on a 700Mhz PIII with a 2.4.18-3 Kernel (Red Hat 7.3) My
driver
> is written with a call to pci_module_init in the init routine wherein I
> specify a probe and remove routine. According to Linux Device Drivers 2nd
> edition (pages 489 - 493), As long as the HW supports hot swap, I should
get
> called automatically whenevr one of the devices (vendor ID device ID)
which
> I specified in my table gets inserted or ejected. Am I totaly wrong about
> this? I am not trying to write a driver for a hotplug controller but for a
> device.

Yes, you are correct. But odds are there is not a PCI Hotplug
controller for your hardware, so this probably will not work. However,
your driver should work just fine to control your card.

What kind of cPCI controller do you have?

thanks,

greg k-h

2002-09-18 21:25:56

by Greg KH

[permalink] [raw]
Subject: Re: Linux hot swap support

On Wed, Sep 18, 2002 at 05:09:50PM -0400, Bloch, Jack wrote:
> Our HW uses an AMCC S5935 PCI controller. Right now, since we own both
> device and SW, we are using a simple interrupt mechanism to accomplish the
> hot swap.

What do you mean "simple interrupt mechanism"? How does the OS know
that a PCI card has disappeared or show up?

thanks,

greg k-h

2002-09-18 21:32:50

by Bloch, Jack

[permalink] [raw]
Subject: RE: Linux hot swap support

At the moment, I only support removal. The way it works is as follows.

Upon system start up my device driver detects all of the boards which are
present (I support up to six). For each board it allocates the necessary I/O
lists memory needed for operation. All addresses are then mapped to user
space with a mmap interface. Now, all HW is accessible from user space. For
each device, an ISR is installed. As soon as the ejector handle for a
particular device is opened, the board (which is a Motorola 68060 based
board) issues an interrupt to me. I will shut this board down and
de-allocate any of the previously reserved resources. What is not so easy is
to perform the insert. I thought about allocating memory becessary for a
maximum configuration, but I would still need to get the insertion event.
But anyway since our device (even though it has multiple boards internally)
is seen as a monolithic device from the main controlling host, the loss of a
single board causes it to be taken out of service.

Jack Bloch
Siemens ICN
phone (561) 923-6550
e-mail [email protected]


-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Wednesday, September 18, 2002 5:31 PM
To: Bloch, Jack
Cc: [email protected]
Subject: Re: Linux hot swap support


On Wed, Sep 18, 2002 at 05:09:50PM -0400, Bloch, Jack wrote:
> Our HW uses an AMCC S5935 PCI controller. Right now, since we own both
> device and SW, we are using a simple interrupt mechanism to accomplish the
> hot swap.

What do you mean "simple interrupt mechanism"? How does the OS know
that a PCI card has disappeared or show up?

thanks,

greg k-h

2002-09-18 21:42:40

by Greg KH

[permalink] [raw]
Subject: Re: Linux hot swap support

On Wed, Sep 18, 2002 at 05:37:50PM -0400, Bloch, Jack wrote:
> At the moment, I only support removal. The way it works is as follows.
>
> Upon system start up my device driver detects all of the boards which are
> present (I support up to six). For each board it allocates the necessary I/O
> lists memory needed for operation. All addresses are then mapped to user
> space with a mmap interface. Now, all HW is accessible from user space. For
> each device, an ISR is installed. As soon as the ejector handle for a
> particular device is opened, the board (which is a Motorola 68060 based
> board) issues an interrupt to me. I will shut this board down and
> de-allocate any of the previously reserved resources. What is not so easy is
> to perform the insert. I thought about allocating memory becessary for a
> maximum configuration, but I would still need to get the insertion event.
> But anyway since our device (even though it has multiple boards internally)
> is seen as a monolithic device from the main controlling host, the loss of a
> single board causes it to be taken out of service.

Hm, you might want to take a look at the cPCI patches from Scott Murray,
he has a solution for the resource and insertion problem that will
probably work for you. You can find the patches on the pcihpd-discuss
mailing list, and I think they were also posted to lkml in the past too.
He's working on cleaning them up a bit for inclusion in the main kernel
tree.

Hope this helps,

greg k-h

2002-09-18 21:46:30

by Bloch, Jack

[permalink] [raw]
Subject: RE: Linux hot swap support

Thanks for the help, but a generic question. If my HW has a hotswap
controller (theoretically), I do not need any thrird party SW to handle the
hot swap insert/remove. Linux 2.4.18-3 Kernel should support this correct? I
should just run /sbin/hotplug pci on start up.

Jack Bloch
Siemens ICN
phone (561) 923-6550
e-mail [email protected]


-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Wednesday, September 18, 2002 5:48 PM
To: Bloch, Jack
Cc: [email protected]
Subject: Re: Linux hot swap support


On Wed, Sep 18, 2002 at 05:37:50PM -0400, Bloch, Jack wrote:
> At the moment, I only support removal. The way it works is as follows.
>
> Upon system start up my device driver detects all of the boards which are
> present (I support up to six). For each board it allocates the necessary
I/O
> lists memory needed for operation. All addresses are then mapped to user
> space with a mmap interface. Now, all HW is accessible from user space.
For
> each device, an ISR is installed. As soon as the ejector handle for a
> particular device is opened, the board (which is a Motorola 68060 based
> board) issues an interrupt to me. I will shut this board down and
> de-allocate any of the previously reserved resources. What is not so easy
is
> to perform the insert. I thought about allocating memory becessary for a
> maximum configuration, but I would still need to get the insertion event.
> But anyway since our device (even though it has multiple boards
internally)
> is seen as a monolithic device from the main controlling host, the loss of
a
> single board causes it to be taken out of service.

Hm, you might want to take a look at the cPCI patches from Scott Murray,
he has a solution for the resource and insertion problem that will
probably work for you. You can find the patches on the pcihpd-discuss
mailing list, and I think they were also posted to lkml in the past too.
He's working on cleaning them up a bit for inclusion in the main kernel
tree.

Hope this helps,

greg k-h

2002-09-18 22:07:24

by Greg KH

[permalink] [raw]
Subject: Re: Linux hot swap support

On Wed, Sep 18, 2002 at 05:51:30PM -0400, Bloch, Jack wrote:
> Thanks for the help, but a generic question. If my HW has a hotswap
> controller (theoretically), I do not need any thrird party SW to handle the
> hot swap insert/remove. Linux 2.4.18-3 Kernel should support this correct?

The kernel will support this, yes, but you need to run some kind of
userspace software to turn on or off slots. Or if you have hardware
that recognizes that the power needs to be removed or applied (through a
latch on the slot), it could all be handled with no user interaction at
all.

> I should just run /sbin/hotplug pci on start up.

No, the kernel runs /sbin/hotplug when it sees a new pci device, or when
one is removed. A user never runs it on their own.

Hope this helps,

greg k-h

2002-09-19 00:00:55

by Scott Murray

[permalink] [raw]
Subject: Re: Linux hot swap support

On Wed, 18 Sep 2002, Greg KH wrote:

> On Wed, Sep 18, 2002 at 05:37:50PM -0400, Bloch, Jack wrote:
> > At the moment, I only support removal. The way it works is as follows.
> >
> > Upon system start up my device driver detects all of the boards which are
> > present (I support up to six). For each board it allocates the necessary I/O
> > lists memory needed for operation. All addresses are then mapped to user
> > space with a mmap interface. Now, all HW is accessible from user space. For
> > each device, an ISR is installed. As soon as the ejector handle for a
> > particular device is opened, the board (which is a Motorola 68060 based
> > board) issues an interrupt to me. I will shut this board down and
> > de-allocate any of the previously reserved resources. What is not so easy is
> > to perform the insert. I thought about allocating memory becessary for a
> > maximum configuration, but I would still need to get the insertion event.
> > But anyway since our device (even though it has multiple boards internally)
> > is seen as a monolithic device from the main controlling host, the loss of a
> > single board causes it to be taken out of service.
>
> Hm, you might want to take a look at the cPCI patches from Scott Murray,
> he has a solution for the resource and insertion problem that will
> probably work for you. You can find the patches on the pcihpd-discuss
> mailing list, and I think they were also posted to lkml in the past too.
> He's working on cleaning them up a bit for inclusion in the main kernel
> tree.

>From looking at the datasheet of the AMCC S5935, it appears to not be
compliant with the PICMG 2.1 cPCI hotswap specification. That means
that it will probably take quite a bit of hardware and software hacking
to make insertion work. My patches should provide a bit of basis for
further hacking if you do want to try and build something yourself, but
if reliable hotplugging is important to your project, I'd suggest
considering a switch to a PCI controller or bridge that is PICMG 2.1
hotswap compliant.

Scott


--
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: [email protected]




2002-09-19 12:14:51

by Bloch, Jack

[permalink] [raw]
Subject: RE: Linux hot swap support

Thanks for the quick response. We are working on a new HW layout. I think
that I already got the answer to the critical question that I need. Once I
have the HW in place, I have to be sure that the 2.4.18-3 Kernel (or
greater) can support hot swap withoout any third party SW. Of course I
understand that my driver will have to be modified. This answer I already
received yesterday. Thanks very much.

Jack Bloch
Siemens ICN
phone (561) 923-6550
e-mail [email protected]


-----Original Message-----
From: Scott Murray [mailto:[email protected]]
Sent: Wednesday, September 18, 2002 8:06 PM
To: Bloch, Jack
Cc: Greg KH; Linux Kernel Mailing List
Subject: Re: Linux hot swap support


On Wed, 18 Sep 2002, Greg KH wrote:

> On Wed, Sep 18, 2002 at 05:37:50PM -0400, Bloch, Jack wrote:
> > At the moment, I only support removal. The way it works is as follows.
> >
> > Upon system start up my device driver detects all of the boards which
are
> > present (I support up to six). For each board it allocates the necessary
I/O
> > lists memory needed for operation. All addresses are then mapped to user
> > space with a mmap interface. Now, all HW is accessible from user space.
For
> > each device, an ISR is installed. As soon as the ejector handle for a
> > particular device is opened, the board (which is a Motorola 68060 based
> > board) issues an interrupt to me. I will shut this board down and
> > de-allocate any of the previously reserved resources. What is not so
easy is
> > to perform the insert. I thought about allocating memory becessary for a
> > maximum configuration, but I would still need to get the insertion
event.
> > But anyway since our device (even though it has multiple boards
internally)
> > is seen as a monolithic device from the main controlling host, the loss
of a
> > single board causes it to be taken out of service.
>
> Hm, you might want to take a look at the cPCI patches from Scott Murray,
> he has a solution for the resource and insertion problem that will
> probably work for you. You can find the patches on the pcihpd-discuss
> mailing list, and I think they were also posted to lkml in the past too.
> He's working on cleaning them up a bit for inclusion in the main kernel
> tree.

>From looking at the datasheet of the AMCC S5935, it appears to not be
compliant with the PICMG 2.1 cPCI hotswap specification. That means
that it will probably take quite a bit of hardware and software hacking
to make insertion work. My patches should provide a bit of basis for
further hacking if you do want to try and build something yourself, but
if reliable hotplugging is important to your project, I'd suggest
considering a switch to a PCI controller or bridge that is PICMG 2.1
hotswap compliant.

Scott


--
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: [email protected]