PCI Slot?

In our systems we sometimes have multiple cards of the same type. Is there a programmatic way to determine which card is in which slot?
Thanks, Michael

Check the archives, this as been asked many times with the same answer: bad design, your driver simply should not care what physical slot your board is occupying in the mother board. If you need to identify a card, that capability, via world wide name or serial number, should be available by accessing some “feature” or commnad on the card itself.

Gary G. Little

----- Original Message -----
From: “Michael Wade”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, January 5, 2011 9:11:31 AM
Subject: [ntdev] PCI Slot?

In our systems we sometimes have multiple cards of the same type. Is there a programmatic way to determine which card is in which slot?
Thanks, Michael


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Put an LED on them and flash it on the board of interest. Seriously, that’s
the only reliable way of identifying one of many identical PCI boards.

Philip D. Barila??? (303) 776-1264

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michael Wade
Sent: Wednesday, January 05, 2011 8:12 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] PCI Slot?

In our systems we sometimes have multiple cards of the same type. Is there
a programmatic way to determine which card is in which slot?
Thanks, Michael


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

As Gary and Phil have indicated this is a problem. You can get the
“slot number” from IoGetDeviceProperty but there is no mapping to
anything physical. If you really need this you have to test each slot
in every system to get a mapping. Do not assume that a machine marked
Model X will have the same mapping for all Model X machines, I consulted
for a company that got 5 Dell’s of the same model in one order with 5
different mappings!

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Michael Wade” wrote in message
news:xxxxx@ntdev:

> In our systems we sometimes have multiple cards of the same type. Is there a programmatic way to determine which card is in which slot?
> Thanks, Michael

As others mentioned earlier and as in the archive, you’re likely trying to do one of two things here: determine where the card is located for NUMA stuff (which there are API’s to handle in Win7) or identify the card for an end user to do something useful. To identify the card your HW folks need to simply attach an LED to an unused pin on the FPGA which they then hook to a register in a BAR space your driver can map. The LED should be visible from the card edge and your driver simply turns the register “on” and “off” based on an IOCTL you’ve created. You can get fancier by putting a timer into the driver that turns the LED on and off at various rates, fancier still by using a multi-color LED and attaching two registers to the LED but the idea is the same …

You’re likely tempted by the PCI bus and slot info but don’t … that varies by MB vendor, rev of the motherboard and bridge chip and also by any PCI rebalancing that has happened/ is happening/ will soon happen … treat those numbers as simply a semi-random number generator and you’ll do fine …

Thanks for the info, I was afraid of that. Our current implementation is to wiggle a line, but I was hoping that there would be a way without user
intervention. Oh well, thanks again.

On Wed, 5 Jan 2011 10:49:06 -0500 (EST), choward@ix.netcom.com wrote:

As others mentioned earlier and as in the archive, you’re likely trying to do one of two things here: determine where the card is located for NUMA stuff (which there are API’s to handle in Win7) or identify the card for an end user to do something useful. To identify the card your HW folks need to simply attach an LED to an unused pin on the FPGA which they then hook to a register in a BAR space your driver can map. The LED should be visible from the card edge and your driver simply turns the register “on” and “off” based on an IOCTL you’ve created. You can get fancier by putting a timer into the driver that turns the LED on and off at various rates, fancier still by using a multi-color LED and attaching two registers to the LED but the idea is the same …

You’re likely tempted by the PCI bus and slot info but don’t … that varies by MB vendor, rev of the motherboard and bridge chip and also by any PCI rebalancing that has happened/ is happening/ will soon happen … treat those numbers as simply a semi-random number generator and you’ll do fine …

Hmmm… not exactly sure why you say bad design. We have two cards that simulate two different IMU’s and we need to tell the user which is which.

On Wed, 5 Jan 2011 15:18:08 +0000 (UTC), “Gary G. Little” wrote:

>Check the archives, this as been asked many times with the same answer: bad design, your driver simply should not care what physical slot your board is occupying in the mother board. If you need to identify a card, that capability, via world wide name or serial number, should be available by accessing some “feature” or commnad on the card itself.
>
>Gary G. Little
>
>----- Original Message -----
>From: “Michael Wade”
>To: “Windows System Software Devs Interest List”
>Sent: Wednesday, January 5, 2011 9:11:31 AM
>Subject: [ntdev] PCI Slot?
>
>In our systems we sometimes have multiple cards of the same type. Is there a programmatic way to determine which card is in which slot?
>Thanks, Michael
>
>—
>NTDEV is sponsored by OSR
>
>For our schedule of WDF, WDM, debugging and other seminars visit:
>http://www.osr.com/seminars
>
>To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Yes, I saw that and we have talked about it. Our application is slightly different from most. We have complete control of the hardware (we develop
the entire system), so we may decide to go this route, but I hope not.
Thanks,
Michael

On Wed, 5 Jan 2011 15:32:57 +0000, “Don Burn” wrote:

>As Gary and Phil have indicated this is a problem. You can get the
>“slot number” from IoGetDeviceProperty but there is no mapping to
>anything physical. If you really need this you have to test each slot
>in every system to get a mapping. Do not assume that a machine marked
>Model X will have the same mapping for all Model X machines, I consulted
>for a company that got 5 Dell’s of the same model in one order with 5
>different mappings!
>
>
>Don Burn (MVP, Windows DKD)
>Windows Filesystem and Driver Consulting
>Website: http://www.windrvr.com
>Blog: http://msmvps.com/blogs/WinDrvr
>
>
>
>“Michael Wade” wrote in message
>news:xxxxx@ntdev:
>
>> In our systems we sometimes have multiple cards of the same type. Is there a programmatic way to determine which card is in which slot?
>> Thanks, Michael
>

Re-read Don’s post : I’d say that 5 machines from the same vendor with 5 different mappings lends itself to obfuscation and hence a bad design if you are dependent upon it. I’ve seen to many times when the first machine configured will dictate the configuration of all other machines. Expecting Card A to be in slot A in all machines simply because it was in that slot and reported as such on the first machine, is a bad assumption.

I dunno, maybe build add a cell phone vibrator to simulate a “line wiggler” on each board, or a digital led that is incremented across each board as a new board is initialized. Using the slot number is unreliable and a waste of time.

Gary G. Little

----- Original Message -----
From: “Michael Wade”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, January 5, 2011 12:16:59 PM
Subject: Re:[ntdev] PCI Slot?

Hmmm… not exactly sure why you say bad design. We have two cards that simulate two different IMU’s and we need to tell the user which is which.

On Wed, 5 Jan 2011 15:18:08 +0000 (UTC), “Gary G. Little” wrote:

>Check the archives, this as been asked many times with the same answer: bad design, your driver simply should not care what physical slot your board is occupying in the mother board. If you need to identify a card, that capability, via world wide name or serial number, should be available by accessing some “feature” or commnad on the card itself.
>
>Gary G. Little
>
>----- Original Message -----
>From: “Michael Wade”
>To: “Windows System Software Devs Interest List”
>Sent: Wednesday, January 5, 2011 9:11:31 AM
>Subject: [ntdev] PCI Slot?
>
>In our systems we sometimes have multiple cards of the same type. Is there a programmatic way to determine which card is in which slot?
>Thanks, Michael
>
>—
>NTDEV is sponsored by OSR
>
>For our schedule of WDF, WDM, debugging and other seminars visit:
>http://www.osr.com/seminars
>
>To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

You also need to be aware of PCI rebalancing (google it, or Jake can chime in) which can/ will cause the bus slot and location numbers to change pretty much anytime the machine is running, maybe long after initial start … which means even if you physically only plug the card into the first physical slot and every single time you start up the machine that slot is reported as “slot E” unless there are no PCI bridges in between the northbridge chip and that physical slot it’s only a matter of time before your slot “E” will magically change to slot “A” …

LED on the card edge is a pretty good way, have the driver keep an incrementing count for each card it attaches to program the LED with that number … report the number back as the UI number or address and you have an easy way for the user to determine the card from device manager …

In a situation like this, I’d be inclined to have a set of jumpers on the
board that can be read from a device register. Very ISA-ish.
Alternatively, having some kind of serial number in the “vendor-specific”
bytes above the PCI header would help, and having an IOCTL that reads it
would work. One of those little serial ROM chips that delivers a unique ID
(about $USD 0.05 in quantity, the last I priced them) might do this well.
Then have a way to have the app map the device name or interface GUID to
this, and as part of the setup at app level, these mappings are established.
Board id 0xNNNNNNNNNNN does X and board id 0xMMMMMMMMMMMM does Y.

This leads to a question: is AddDevice deterministic in recognizing boards,
so that it always presents the same boards in the same order on the same
machine on any boot (assuming the boards have not changed slots, but
consider if other boards might have been inserted or deleted. That is,
across all AddDevice calls, take two boards, B and C. Can I expect, if I
lave those boards plugged into the same slots, and I see the boards appear
in AddDevice in the order BC, that I will *always* see them in the order BC,
even if I have sequences ABC, BCD, XYABC, BCXYZ, etc., where the other
letters represent other boards that may or may not have been plugged in.
Remember that in this example, boards B and C remain plugged into the exact
PCI slots they were originally plugged into. [Followup question: if I saw
them in order BC, and I swap them, will I then always see them in the order
CB].
joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Wednesday, January 05, 2011 10:33 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] PCI Slot?

As Gary and Phil have indicated this is a problem. You can get the “slot
number” from IoGetDeviceProperty but there is no mapping to anything
physical. If you really need this you have to test each slot in every
system to get a mapping. Do not assume that a machine marked Model X will
have the same mapping for all Model X machines, I consulted for a company
that got 5 Dell’s of the same model in one order with 5 different mappings!

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Michael Wade” wrote in message
news:xxxxx@ntdev:

> In our systems we sometimes have multiple cards of the same type. Is
there a programmatic way to determine which card is in which slot?
> Thanks, Michael


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.

>

This leads to a question: is AddDevice deterministic in recognizing
boards,
so that it always presents the same boards in the same order on the
same
machine on any boot (assuming the boards have not changed slots, but
consider if other boards might have been inserted or deleted. That
is,
across all AddDevice calls, take two boards, B and C. Can I expect,
if I
lave those boards plugged into the same slots, and I see the boards
appear
in AddDevice in the order BC, that I will *always* see them in the
order BC,
even if I have sequences ABC, BCD, XYABC, BCXYZ, etc., where the other
letters represent other boards that may or may not have been plugged
in.
Remember that in this example, boards B and C remain plugged into the
exact
PCI slots they were originally plugged into. [Followup question: if I
saw
them in order BC, and I swap them, will I then always see them in the
order
CB].
joe

Does Windows (or the PCI bus driver?) make any effort to ensure that
AddDevice is serialised at all? I can’t see any documentation that
states that it is, so in theory AddDevice for boards B and C could be
called essentially at the same time. This might be more likely if they
were on different PCI busses.

Is each PCI bus in a computer managed by a separate instance of pci.sys?
If so, you are relying on the scheduling of the device enumeration of
each bus rather than any pre-determined enumeration order. Two adjacent
slots on a board could be on completely separate PCI busses.

Sounds like there are enough unknowns that this isn’t something you
should think about relying on…

James