Skip to contentSkip to conversation

drm/msm: add shutdown support for display platform_driver

PATCH In review Krishna Manikandan 4 participants 9 messages Jun 1, 2020 – Aug 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/msm: add shutdown support for display platform_driver

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

Changes in v2:
- Remove NULL check from msm_pdev_shutdown (Stephen Boyd)
- Change commit text to reflect when this issue was uncovered (Sai Prakash Ranjan)

---
 drivers/gpu/drm/msm/msm_drv.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/msm/msm_drv.c +8 -0
index e4b750b..94e3963 100644
@@ -1322,6 +1322,13 @@ static int msm_pdev_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static void msm_pdev_shutdown(struct platform_device *pdev)
+{
+	struct drm_device *drm = platform_get_drvdata(pdev);
+
+	drm_atomic_helper_shutdown(drm);
+}
+
 static const struct of_device_id dt_match[] = {
 	{ .compatible = "qcom,mdp4", .data = (void *)KMS_MDP4 },
 	{ .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
@@ -1334,6 +1341,7 @@ static int msm_pdev_remove(struct platform_device *pdev)
 static struct platform_driver msm_platform_driver = {
 	.probe      = msm_pdev_probe,
 	.remove     = msm_pdev_remove,
+	.shutdown   = msm_pdev_shutdown,
 	.driver     = {
 		.name   = "msm",
 		.of_match_table = dt_match,
Signature · 1 line
1.9.1
#1 lore raw

Hi Krishna,

Quoted 5 lines · Krishna Manikandan

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

Quoted 7 lines

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

AFAICT atomics is setup in msm_drm_ops::bind and shutdown in msm_drm_ops::unbind.

Are you saying that unbind never triggers? If so, then we should really fix that instead, since this patch seems more like a workaround.

-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

Hi Emil,

Quoted 13 lines · Emil Velikov

Hi Krishna,

Quoted 10 lines · Krishna Manikandan

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

Quoted 9 lines
Quoted 2 lines

AFAICT atomics is setup in msm_drm_ops::bind and shutdown in msm_drm_ops::unbind.

Are you saying that unbind never triggers? If so, then we should really fix that instead, since this patch seems more like a workaround.

Which path do you suppose that the unbind should be called from, remove callback? Here we are talking about the drivers which are builtin, where remove callbacks are not called from the driver core during reboot/shutdown, instead shutdown callbacks are called which needs to be defined in order to trigger unbind. So AFAICS there is nothing to be fixed.

msm_pdev_shutdown()
platform_drv_shutdown()
device_shutdown()
kernel_restart_prepare()

    kernel_restart()
     __arm64_sys_reboot()

Thanks,
Sai

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw
Quoted 28 lines · Sai Prakash Ranjan

Hi Emil,

Quoted 14 lines · Emil Velikov

Hi Krishna,

Quoted 10 lines · Krishna Manikandan

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

Quoted 9 lines
Quoted 2 lines

AFAICT atomics is setup in msm_drm_ops::bind and shutdown in msm_drm_ops::unbind.

Are you saying that unbind never triggers? If so, then we should really fix that instead, since this patch seems more like a workaround.

Quoted 8 lines

Which path do you suppose that the unbind should be called from, remove callback? Here we are talking about the drivers which are builtin, where remove callbacks are not called from the driver core during reboot/shutdown,
instead shutdown callbacks are called which needs to be defined in order to
trigger unbind. So AFAICS there is nothing to be fixed.

Interesting - in drm effectively only drm panels implement .shutdown. So my naive assumption was that .remove was used implicitly by core, as part of the shutdown process. Yet that's not the case, so it seems that many drivers could use some fixes.

Then again, that's an existing problem which is irrelevant for msm. -Emil

#4 lore raw

Hi Emil,

Quoted 38 lines · Emil Velikov
Quoted 28 lines · Sai Prakash Ranjan

Hi Emil,

Quoted 14 lines · Emil Velikov

Hi Krishna,

Quoted 10 lines · Krishna Manikandan

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

Quoted 9 lines
Quoted 2 lines

AFAICT atomics is setup in msm_drm_ops::bind and shutdown in msm_drm_ops::unbind.

Are you saying that unbind never triggers? If so, then we should really fix that instead, since this patch seems more like a workaround.

Quoted 8 lines

Which path do you suppose that the unbind should be called from, remove callback? Here we are talking about the drivers which are builtin, where remove callbacks are not called from the driver core during reboot/shutdown,
instead shutdown callbacks are called which needs to be defined in order to
trigger unbind. So AFAICS there is nothing to be fixed.

Quoted 7 lines

Interesting - in drm effectively only drm panels implement .shutdown. So my naive assumption was that .remove was used implicitly by core, as part of the shutdown process. Yet that's not the case, so it seems that many drivers could use some fixes.

Then again, that's an existing problem which is irrelevant for msm. -Emil

To give more context, we are actually targeting the clients/consumers of SMMU/IOMMU here because we have to make sure that before the supplier (SMMU) shuts down, its consumers/clients need to be shutdown properly. Now the ordering of this is taken care in the SMMU driver via device_link which makes sure that consumer shutdown callbacks are called first, but we need to define shutdown callbacks for all its consumers to make sure we actually shutdown the clients or else it would invite the crashes during reboot which in this case was seen for display.

Thanks,
Sai

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#5 lore raw
Quoted 53 lines · Sai Prakash Ranjan

Hi Emil,

Quoted 41 lines · Emil Velikov
Quoted 28 lines · Sai Prakash Ranjan

Hi Emil,

Quoted 14 lines · Emil Velikov

Hi Krishna,

Quoted 10 lines · Krishna Manikandan

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

Quoted 9 lines
Quoted 2 lines

AFAICT atomics is setup in msm_drm_ops::bind and shutdown in msm_drm_ops::unbind.

Are you saying that unbind never triggers? If so, then we should really fix that instead, since this patch seems more like a workaround.

Quoted 11 lines

Which path do you suppose that the unbind should be called from, remove
callback? Here we are talking about the drivers which are builtin, where
remove callbacks are not called from the driver core during reboot/shutdown,
instead shutdown callbacks are called which needs to be defined in order
to
trigger unbind. So AFAICS there is nothing to be fixed.

Quoted 7 lines

Interesting - in drm effectively only drm panels implement .shutdown. So my naive assumption was that .remove was used implicitly by core, as part of the shutdown process. Yet that's not the case, so it seems that many drivers could use some fixes.

Then again, that's an existing problem which is irrelevant for msm. -Emil

Quoted 12 lines

To give more context, we are actually targeting the clients/consumers of SMMU/IOMMU here because we have to make sure that before the supplier (SMMU) shuts down, its consumers/clients need to be shutdown properly. Now the ordering of this is taken care in the SMMU driver via device_link
which makes sure that consumer shutdown callbacks are called first, but we
need to define shutdown callbacks for all its consumers to make sure we actually shutdown the clients or else it would invite the crashes during reboot
which in this case was seen for display.

Thank you very much for the extra details. I think other DRM drivers will be safe as-is.

-Emil

#6 lore raw
In reply to Krishna Manikandan

Hi,

Quoted 46 lines · Krishna Manikandan

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

Changes in v2:
- Remove NULL check from msm_pdev_shutdown (Stephen Boyd)
- Change commit text to reflect when this issue was uncovered (Sai Prakash Ranjan)

---
 drivers/gpu/drm/msm/msm_drv.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/msm/msm_drv.c +7 -0
index e4b750b..94e3963 100644
@@ -1322,6 +1322,13 @@ static int msm_pdev_remove(struct 
 platform_device *pdev)
 	return 0;
 }
 
+static void msm_pdev_shutdown(struct platform_device *pdev)
+{
+	struct drm_device *drm = platform_get_drvdata(pdev);
+
+	drm_atomic_helper_shutdown(drm);
+}
+
 static const struct of_device_id dt_match[] = {
 	{ .compatible = "qcom,mdp4", .data = (void *)KMS_MDP4 },
drivers/gpu/drm/msm/msm_drv.c +1 -0
 	{ .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
@@ -1334,6 +1341,7 @@ static int msm_pdev_remove(struct platform_device 
 *pdev)
 static struct platform_driver msm_platform_driver = {
 	.probe      = msm_pdev_probe,
 	.remove     = msm_pdev_remove,
+	.shutdown   = msm_pdev_shutdown,
 	.driver     = {
 		.name   = "msm",
Quoted 1 line

.of_match_table = dt_match,

Any more comments on this patch?

Thanks,
Sai

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#7 lore raw
Quoted 46 lines · Sai Prakash Ranjan

Hi,

Quoted 42 lines · Krishna Manikandan

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

Changes in v2:
- Remove NULL check from msm_pdev_shutdown (Stephen Boyd)
- Change commit text to reflect when this issue was uncovered (Sai Prakash Ranjan)

---
 drivers/gpu/drm/msm/msm_drv.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/msm/msm_drv.c +7 -0
index e4b750b..94e3963 100644
@@ -1322,6 +1322,13 @@ static int msm_pdev_remove(struct
 platform_device *pdev)
      return 0;
 }
 
+static void msm_pdev_shutdown(struct platform_device *pdev)
+{
+     struct drm_device *drm = platform_get_drvdata(pdev);
+
+     drm_atomic_helper_shutdown(drm);
+}
+
 static const struct of_device_id dt_match[] = {
      { .compatible = "qcom,mdp4", .data = (void *)KMS_MDP4 },
      { .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
drivers/gpu/drm/msm/msm_drv.c +0 -0
@@ -1334,6 +1341,7 @@ static int msm_pdev_remove(struct platform_device
 *pdev)
 static struct platform_driver msm_platform_driver = {
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +1 -0
      .probe      = msm_pdev_probe,
      .remove     = msm_pdev_remove,
+     .shutdown   = msm_pdev_shutdown,
      .driver     = {
              .name   = "msm",

.of_match_table = dt_match,

Any more comments on this patch?

sorry, I managed to overlook this earlier.. I've pulled it in to msm-next

BR,
-R

Quoted 7 lines

Thanks,
Sai

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
Quoted 57 lines · Rob Clark
Quoted 46 lines · Sai Prakash Ranjan

Hi,

Quoted 42 lines · Krishna Manikandan

Define shutdown callback for display drm driver, so as to disable all the CRTCS when shutdown notification is received by the driver.

This change will turn off the timing engine so that no display transactions are requested while mmu translations are getting disabled during reboot sequence.

Changes in v2:
- Remove NULL check from msm_pdev_shutdown (Stephen Boyd)
- Change commit text to reflect when this issue was uncovered (Sai Prakash Ranjan)

---
 drivers/gpu/drm/msm/msm_drv.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/msm/msm_drv.c +7 -0
index e4b750b..94e3963 100644
@@ -1322,6 +1322,13 @@ static int msm_pdev_remove(struct
 platform_device *pdev)
      return 0;
 }
 
+static void msm_pdev_shutdown(struct platform_device *pdev)
+{
+     struct drm_device *drm = platform_get_drvdata(pdev);
+
+     drm_atomic_helper_shutdown(drm);
+}
+
 static const struct of_device_id dt_match[] = {
      { .compatible = "qcom,mdp4", .data = (void *)KMS_MDP4 },
      { .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
drivers/gpu/drm/msm/msm_drv.c +0 -0
@@ -1334,6 +1341,7 @@ static int msm_pdev_remove(struct platform_device
 *pdev)
 static struct platform_driver msm_platform_driver = {
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +1 -0
      .probe      = msm_pdev_probe,
      .remove     = msm_pdev_remove,
+     .shutdown   = msm_pdev_shutdown,
      .driver     = {
              .name   = "msm",

.of_match_table = dt_match,

Any more comments on this patch?

Quoted 2 lines

sorry, I managed to overlook this earlier.. I've pulled it in to msm-next

No problem, thanks Rob.

-Sai

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation