RE: PCI Config spinlock handle - Processor Shootdown

I really strongly agree with what Mark said:

I’d recommend getting your hardware fixed first though.

With that said, there are times when you need to work around the
hardware. Touching parts of the machine that don’t belong to you is
something that you should avoid except when absolutely necessary. Even
so, I’ve had to do it a couple of times in drivers. And when you do it,
you should shoot down all the processors. The steps that I use are as
follows:

Prepare a DPC routine that spins on a barrier (declared as volatile.)
Call KeQueryActiveProcessors at passive level.
Raise to DISPATCH level.
Call KeGetCurrentProcessorNumber.
Initialize the barrier to the number of active processors minus one.
Queue the DPC on all of the other processors.

In the DPC routine:
Raise to IPI_LEVEL - 1.
InterlockedDecrement the barrier once. Since this will run on all of
the processors, other than the one that queued the DPCs, the barrier
will hit 0 when all of them have raised IRQL.
Spin waiting for the barrier to become non-zero.
Drop IRQL to DISPATCH_LEVEL and exit.

In the original function:
Spin waiting for the barrier to become 0.
Do the work that you need to do with the machine half-dead.
Set the barrier to some non-zero value to release the shot-down
processors.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: RE: PCI Config spinlock handle
From: “Shaun Ruffell”
Date: Thu, 17 Oct 2002 14:59:59 -0700
X-Message-Number: 56

When I did it…I have to admit, I didn’t take any extra pains to
support
MP systems. I just raise the IRQL and directly access the PCI Config
registers. It’s a lurking problem for me on MP systems though.

Mark R. : What is your recommended way of creating a CPU corral? I
imaging you want to create several system threads and assign a processor
affinity to them so they each run on a different processor (and then
raise
their IRQL when ready)…but nothing jumped out at me in the DDK about
how
to set the processor affinity of system threads.