Currently, neither the vio_bus or vio_driver structures provide support
for a shutdown() routine.
Add support for shutdown() by allowing drivers to provide a
implementation via function pointer in their vio_driver struct and
provide a proper implementation in the driver template for the vio_bus
that calls a vio drivers shutdown() if defined.
In the case that no shutdown() is defined by a vio driver and a kexec is
in progress we implement a big hammer that calls remove() to ensure no
further DMA for the devices is possible.
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
arch/powerpc/include/asm/vio.h | 1 +
arch/powerpc/platforms/pseries/vio.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
@@ -114,6 +114,7 @@ struct vio_driver {conststructvio_device_id*id_table;int(*probe)(structvio_dev*dev,conststructvio_device_id*id);void(*remove)(structvio_dev*dev);+void(*shutdown)(structvio_dev*dev);/* A driver must have a get_desired_dma() function to*beloadedinaCMOenvironmentifitusesDMA.*/
Currently, neither the vio_bus or vio_driver structures provide support
for a shutdown() routine.
Add support for shutdown() by allowing drivers to provide a
implementation via function pointer in their vio_driver struct and
provide a proper implementation in the driver template for the vio_bus
that calls a vio drivers shutdown() if defined.
In the case that no shutdown() is defined by a vio driver and a kexec is
in progress we implement a big hammer that calls remove() to ensure no
further DMA for the devices is possible.
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
Ping... any comments, problems with this approach?
-Tyrel
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2021-04-17 12:30:27
Tyrel Datwyler [off-list ref] writes:
On 4/1/21 5:13 PM, Tyrel Datwyler wrote:
quoted
Currently, neither the vio_bus or vio_driver structures provide support
for a shutdown() routine.
Add support for shutdown() by allowing drivers to provide a
implementation via function pointer in their vio_driver struct and
provide a proper implementation in the driver template for the vio_bus
that calls a vio drivers shutdown() if defined.
In the case that no shutdown() is defined by a vio driver and a kexec is
in progress we implement a big hammer that calls remove() to ensure no
further DMA for the devices is possible.
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
Ping... any comments, problems with this approach?
The kexec part seems like a bit of a hack.
It also doesn't help for kdump, when none of the shutdown code is run.
How many drivers do we have? Can we just implement a proper shutdown for
them?
cheers
Currently, neither the vio_bus or vio_driver structures provide support
for a shutdown() routine.
Add support for shutdown() by allowing drivers to provide a
implementation via function pointer in their vio_driver struct and
provide a proper implementation in the driver template for the vio_bus
that calls a vio drivers shutdown() if defined.
In the case that no shutdown() is defined by a vio driver and a kexec is
in progress we implement a big hammer that calls remove() to ensure no
further DMA for the devices is possible.
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
Ping... any comments, problems with this approach?
The kexec part seems like a bit of a hack.
It also doesn't help for kdump, when none of the shutdown code is run.
If I understand correctly for kdump we have a reserved memory space where the
kdump kernel is loaded, but for kexec the memory region isn't reserved ahead of
time meaning we can try and load the kernel over potential memory used for DMA
by the current kernel. Please correct me if I've got that wrong.
How many drivers do we have? Can we just implement a proper shutdown for
them?
Well that is the end goal. I just don't currently have the bandwidth to do each
driver myself with a proper shutdown sequence, and thought this was a launching
off point to at least introduce the shutdown callback to the VIO bus.
Off the top of my head we have 3 storage drivers, 2 network drivers, vtpm, vmc,
pseries_rng, nx, nx842, hvcs, hvc_vio.
I can drop the kexec_in_progress hammer and just have each driver call remove()
themselves in their shutdown function. Leave it to each maintainer to decide if
remove() is enough or if there is a more lightweight quiesce sequence they
choose to implement.
-Tyrel
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2021-04-20 03:42:48
Tyrel Datwyler [off-list ref] writes:
On 4/17/21 5:30 AM, Michael Ellerman wrote:
quoted
Tyrel Datwyler [off-list ref] writes:
quoted
On 4/1/21 5:13 PM, Tyrel Datwyler wrote:
quoted
Currently, neither the vio_bus or vio_driver structures provide support
for a shutdown() routine.
Add support for shutdown() by allowing drivers to provide a
implementation via function pointer in their vio_driver struct and
provide a proper implementation in the driver template for the vio_bus
that calls a vio drivers shutdown() if defined.
In the case that no shutdown() is defined by a vio driver and a kexec is
in progress we implement a big hammer that calls remove() to ensure no
further DMA for the devices is possible.
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
Ping... any comments, problems with this approach?
The kexec part seems like a bit of a hack.
It also doesn't help for kdump, when none of the shutdown code is run.
If I understand correctly for kdump we have a reserved memory space where the
kdump kernel is loaded, but for kexec the memory region isn't reserved ahead of
time meaning we can try and load the kernel over potential memory used for DMA
by the current kernel.
That's correct.
quoted
How many drivers do we have? Can we just implement a proper shutdown for
them?
Well that is the end goal. I just don't currently have the bandwidth to do each
driver myself with a proper shutdown sequence, and thought this was a launching
off point to at least introduce the shutdown callback to the VIO bus.
Fair enough.
Off the top of my head we have 3 storage drivers, 2 network drivers, vtpm, vmc,
pseries_rng, nx, nx842, hvcs, hvc_vio.
I can drop the kexec_in_progress hammer and just have each driver call remove()
themselves in their shutdown function. Leave it to each maintainer to decide if
remove() is enough or if there is a more lightweight quiesce sequence they
choose to implement.
That's OK, you've convinced me. I'll take it as-is.
Eventually it would be good for drivers to implement shutdown in the
optimal way for their device, but that can be done incrementally.
cheers
From: Michael Ellerman <hidden> Date: 2021-04-21 13:16:45
On Thu, 1 Apr 2021 18:13:25 -0600, Tyrel Datwyler wrote:
Currently, neither the vio_bus or vio_driver structures provide support
for a shutdown() routine.
Add support for shutdown() by allowing drivers to provide a
implementation via function pointer in their vio_driver struct and
provide a proper implementation in the driver template for the vio_bus
that calls a vio drivers shutdown() if defined.
[...]