[PATCH v2 1/4] gpu/host1x: Add init/deinit callbacks to host1x driver framework
Dmitry Osipenko
digetx at gmail.com
Tue Nov 30 23:09:54 UTC 2021
Add init/deinit callbacks to host1x driver framework which allow to
perform early pre-initialization required by Tegra DRM driver.
Cc: <stable at vger.kernel.org> # 5.13+
Signed-off-by: Dmitry Osipenko <digetx at gmail.com>
---
drivers/gpu/host1x/bus.c | 15 +++++++++++++++
include/linux/host1x.h | 4 ++++
2 files changed, 19 insertions(+)
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 0d81eede1217..25d688e5c742 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -479,8 +479,18 @@ static int host1x_device_add(struct host1x *host1x,
device->dev.dma_parms = &device->dma_parms;
dma_set_max_seg_size(&device->dev, UINT_MAX);
+ if (driver->init) {
+ err = driver->init(device);
+ if (err < 0) {
+ kfree(device);
+ return err;
+ }
+ }
+
err = host1x_device_parse_dt(device, driver);
if (err < 0) {
+ if (driver->deinit)
+ driver->deinit(device);
kfree(device);
return err;
}
@@ -512,11 +522,16 @@ static int host1x_device_add(struct host1x *host1x,
static void host1x_device_del(struct host1x *host1x,
struct host1x_device *device)
{
+ struct host1x_driver *driver = device->driver;
+
if (device->registered) {
device->registered = false;
device_del(&device->dev);
}
+ if (driver->deinit)
+ driver->deinit(device);
+
put_device(&device->dev);
}
diff --git a/include/linux/host1x.h b/include/linux/host1x.h
index e8dc5bc41f79..5e5ba33af4ae 100644
--- a/include/linux/host1x.h
+++ b/include/linux/host1x.h
@@ -346,6 +346,8 @@ struct host1x_device;
* @driver: core driver
* @subdevs: table of OF device IDs matching subdevices for this driver
* @list: list node for the driver
+ * @init: called when the host1x logical driver is registered
+ * @deinit: called when the host1x logical driver is unregistered
* @probe: called when the host1x logical device is probed
* @remove: called when the host1x logical device is removed
* @shutdown: called when the host1x logical device is shut down
@@ -356,6 +358,8 @@ struct host1x_driver {
const struct of_device_id *subdevs;
struct list_head list;
+ int (*init)(struct host1x_device *device);
+ void (*deinit)(struct host1x_device *device);
int (*probe)(struct host1x_device *device);
int (*remove)(struct host1x_device *device);
void (*shutdown)(struct host1x_device *device);
--
2.33.1
More information about the dri-devel
mailing list