mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
powerpc/pseries: Add shutdown() to vio_driver and vio_bus
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> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20210402001325.939668-1-tyreld@linux.ibm.com
This commit is contained in:
parent
af31fd0c91
commit
39d0099f94
2 changed files with 17 additions and 0 deletions
|
@ -114,6 +114,7 @@ struct vio_driver {
|
|||
const struct vio_device_id *id_table;
|
||||
int (*probe)(struct vio_dev *dev, const struct vio_device_id *id);
|
||||
void (*remove)(struct vio_dev *dev);
|
||||
void (*shutdown)(struct vio_dev *dev);
|
||||
/* A driver must have a get_desired_dma() function to
|
||||
* be loaded in a CMO environment if it uses DMA.
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <linux/mm.h>
|
||||
#include <linux/dma-map-ops.h>
|
||||
#include <linux/kobject.h>
|
||||
#include <linux/kexec.h>
|
||||
|
||||
#include <asm/iommu.h>
|
||||
#include <asm/dma.h>
|
||||
|
@ -1278,6 +1279,20 @@ static int vio_bus_remove(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void vio_bus_shutdown(struct device *dev)
|
||||
{
|
||||
struct vio_dev *viodev = to_vio_dev(dev);
|
||||
struct vio_driver *viodrv;
|
||||
|
||||
if (dev->driver) {
|
||||
viodrv = to_vio_driver(dev->driver);
|
||||
if (viodrv->shutdown)
|
||||
viodrv->shutdown(viodev);
|
||||
else if (kexec_in_progress)
|
||||
vio_bus_remove(dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* vio_register_driver: - Register a new vio driver
|
||||
* @viodrv: The vio_driver structure to be registered.
|
||||
|
@ -1617,6 +1632,7 @@ struct bus_type vio_bus_type = {
|
|||
.match = vio_bus_match,
|
||||
.probe = vio_bus_probe,
|
||||
.remove = vio_bus_remove,
|
||||
.shutdown = vio_bus_shutdown,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue