Skip to contentSkip to conversation

cdx: register shutdown callback for cdx controller

PATCH Superseded Abhijit Gangurde 3 participants 3 messages Oct 17, 2024 – Nov 11, 2024 AMD cdx bus driver

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cdx: register shutdown callback for cdx controller

register shutdown callback for cdx controller platform device to handle graceful connection closure of rpmsg transport. Also, handle shutdown of cdx bus device by disabling the bus.

---
 drivers/cdx/cdx.c                       | 5 ++++-
 drivers/cdx/controller/cdx_controller.c | 6 ++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cdx/cdx.c +4 -1
index 07371cb653d3..655a056bca4e 100644
@@ -338,8 +338,11 @@ static void cdx_shutdown(struct device *dev)
 {
 	struct cdx_driver *cdx_drv = to_cdx_driver(dev->driver);
 	struct cdx_device *cdx_dev = to_cdx_device(dev);
+	struct cdx_controller *cdx = cdx_dev->cdx;
 
-	if (cdx_drv && cdx_drv->shutdown)
+	if (cdx_dev->is_bus && cdx_dev->enabled && cdx->ops->bus_disable)
+		cdx->ops->bus_disable(cdx, cdx_dev->bus_num);
+	else if (cdx_drv && cdx_drv->shutdown)
 		cdx_drv->shutdown(cdx_dev);
 }
 
drivers/cdx/controller/cdx_controller.c +6 -0
index 7c1ea5373b12..9aad5a9b328c 100644
@@ -261,6 +261,11 @@ static void xlnx_cdx_remove(struct platform_device *pdev)
 	kfree(cdx_mcdi);
 }
 
+static void xlnx_cdx_shutdown(struct platform_device *pdev)
+{
+	cdx_destroy_rpmsg(pdev);
+}
+
 static const struct of_device_id cdx_match_table[] = {
 	{.compatible = "xlnx,versal-net-cdx",},
 	{ },
@@ -276,6 +281,7 @@ static struct platform_driver cdx_pdriver = {
 		   },
 	.probe = xlnx_cdx_probe,
 	.remove_new = xlnx_cdx_remove,
+	.shutdown = xlnx_cdx_shutdown,
 };
 
 static int __init cdx_controller_init(void)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Abhijit Gangurde

register shutdown callback for cdx controller platform device to handle graceful connection closure of rpmsg transport. Also, handle shutdown of cdx bus device by disabling the bus.

When you say "also" that implies it should be a separate patch, right?

And why send this to me and not to the cdx maintainers?

thanks,

greg k-h

maintainer
#2 lore raw
In reply to Abhijit Gangurde
Quoted 20 lines

-----Original Message-----
From: Abhijit Gangurde <[email protected]>

register shutdown callback for cdx controller platform device to handle graceful connection closure of rpmsg transport.
Also, handle shutdown of cdx bus device by disabling the bus.

---
 drivers/cdx/cdx.c                       | 5 ++++-
 drivers/cdx/controller/cdx_controller.c | 6 ++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cdx/cdx.c index 07371cb653d3..655a056bca4e renamed from drivers/cdx/cdx.c +0 -0

100644

drivers/cdx/cdx.c static void cdx_shutdown(struct device *dev) { · line 345

Quoted 9 lines
drivers/cdx/cdx.c +4 -1
@@ -338,8 +338,11 @@ static void cdx_shutdown(struct device *dev)  {
 	struct cdx_driver *cdx_drv = to_cdx_driver(dev->driver);
 	struct cdx_device *cdx_dev = to_cdx_device(dev);
+	struct cdx_controller *cdx = cdx_dev->cdx;
 
-	if (cdx_drv && cdx_drv->shutdown)
+	if (cdx_dev->is_bus && cdx_dev->enabled && cdx->ops->bus_disable)
+		cdx->ops->bus_disable(cdx, cdx_dev->bus_num);
+	else if (cdx_drv && cdx_drv->shutdown)
 		cdx_drv->shutdown(cdx_dev);

Please drop else from here.

Also, as suggested by Greg, please split this patch into 2 separate patches for device shutdown and controller shutdown.