net: ipa: add driver shutdown callback
authorAlex Elder <elder@linaro.org>
Thu, 19 Nov 2020 22:49:29 +0000 (16:49 -0600)
committerJakub Kicinski <kuba@kernel.org>
Sat, 21 Nov 2020 02:45:52 +0000 (18:45 -0800)
A system shutdown can happen at essentially any time, and it's
possible that the IPA driver is busy when a shutdown is underway.
IPA hardware accesses IMEM and SMEM memory regions using an IOMMU,
and at some point during shutdown, needed I/O mappings could become
invalid.  This could be disastrous for any "in flight" IPA activity.

Avoid this by defining a new driver shutdown callback that stops all
IPA activity and cleanly shuts down the driver.  It merely calls the
driver's existing remove callback, reporting the error if it returns
one.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ipa/ipa_main.c

index 4f4a7ca01d450149894d7812a0e2bf9a2b62510a..e9bd0d72f2db1a322f6a382e953c5a7714a0d731 100644 (file)
@@ -888,6 +888,15 @@ static int ipa_remove(struct platform_device *pdev)
        return 0;
 }
 
+static void ipa_shutdown(struct platform_device *pdev)
+{
+       int ret;
+
+       ret = ipa_remove(pdev);
+       if (ret)
+               dev_err(&pdev->dev, "shutdown: remove returned %d\n", ret);
+}
+
 /**
  * ipa_suspend() - Power management system suspend callback
  * @dev:       IPA device structure
@@ -945,8 +954,9 @@ static const struct dev_pm_ops ipa_pm_ops = {
 };
 
 static struct platform_driver ipa_driver = {
-       .probe  = ipa_probe,
-       .remove = ipa_remove,
+       .probe          = ipa_probe,
+       .remove         = ipa_remove,
+       .shutdown       = ipa_shutdown,
        .driver = {
                .name           = "ipa",
                .pm             = &ipa_pm_ops,