Skip to contentSkip to conversation

mailbox: tegra: hsp: add noirq resume

PATCH Superseded Bitan Biswas 2 participants 6 messages Jun 14, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mailbox: tegra: hsp: add noirq resume

Add noirq resume instead of resume callback for Tegra HSP. Tegra HSP resume needs tegra_hsp_doorbell_startup() call to fix timeout error for tegra_bpmp_transfer() during genpd resume noirq on jetson-tx2.

---
 drivers/mailbox/tegra-hsp.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/mailbox/tegra-hsp.c +10 -2
index 91f1a0c..f147374 100644
@@ -771,10 +771,16 @@ static int tegra_hsp_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __maybe_unused tegra_hsp_resume(struct device *dev)
+static int __maybe_unused tegra_hsp_noirq_resume(struct device *dev)
 {
 	struct tegra_hsp *hsp = dev_get_drvdata(dev);
 	unsigned int i;
+	struct tegra_hsp_doorbell *db;
+
+	list_for_each_entry(db, &hsp->doorbells, list) {
+		if (db && db->channel.chan)
+			tegra_hsp_doorbell_startup(db->channel.chan);
+	}
 
 	for (i = 0; i < hsp->num_sm; i++) {
 		struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
@@ -786,7 +792,9 @@ static int __maybe_unused tegra_hsp_resume(struct device *dev)
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(tegra_hsp_pm_ops, NULL, tegra_hsp_resume);
+static const struct dev_pm_ops tegra_hsp_pm_ops = {
+	.resume_noirq   = tegra_hsp_noirq_resume,
+};
 
 static const struct tegra_hsp_db_map tegra186_hsp_db_map[] = {
 	{ "ccplex", TEGRA_HSP_DB_MASTER_CCPLEX, HSP_DB_CCPLEX, },
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 mailbox: tegra: avoid resume NULL mailboxes

If Tegra hsp device tree does not have 'shared irqs', mailboxes pointer is NULL. Add non-NULL HSP mailboxes check in resume callback before tegra_hsp_mailbox_startup() call and prevent NULL pointer exception.

---
 drivers/mailbox/tegra-hsp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/mailbox/tegra-hsp.c +6 -4
index f147374..a11fb1c 100644
@@ -782,11 +782,13 @@ static int __maybe_unused tegra_hsp_noirq_resume(struct device *dev)
 			tegra_hsp_doorbell_startup(db->channel.chan);
 	}
 
-	for (i = 0; i < hsp->num_sm; i++) {
-		struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
+	if (hsp->mailboxes) {
+		for (i = 0; i < hsp->num_sm; i++) {
+			struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
 
-		if (mb->channel.chan->cl)
-			tegra_hsp_mailbox_startup(mb->channel.chan);
+			if (mb->channel.chan->cl)
+				tegra_hsp_mailbox_startup(mb->channel.chan);
+		}
 	}
 
 	return 0;
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH V1 2/2] mailbox: tegra: avoid resume NULL mailboxes

Quoted 1 line · Bitan Biswas

If Tegra hsp device tree does not have 'shared irqs',

s/hsp/HSP/, otherwise looks good.

Thierry

Quoted 34 lines

mailboxes pointer is NULL. Add non-NULL HSP mailboxes check in resume callback before tegra_hsp_mailbox_startup() call and prevent NULL pointer exception.

---
 drivers/mailbox/tegra-hsp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/mailbox/tegra-hsp.c +6 -4
index f147374..a11fb1c 100644
@@ -782,11 +782,13 @@ static int __maybe_unused tegra_hsp_noirq_resume(struct device *dev)
 			tegra_hsp_doorbell_startup(db->channel.chan);
 	}
 
-	for (i = 0; i < hsp->num_sm; i++) {
-		struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
+	if (hsp->mailboxes) {
+		for (i = 0; i < hsp->num_sm; i++) {
+			struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
 
-		if (mb->channel.chan->cl)
-			tegra_hsp_mailbox_startup(mb->channel.chan);
+			if (mb->channel.chan->cl)
+				tegra_hsp_mailbox_startup(mb->channel.chan);
+		}
 	}
 
 	return 0;
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH V1 2/2] mailbox: tegra: avoid resume NULL mailboxes

Quoted 4 lines · Thierry Reding
Quoted 1 line · Bitan Biswas

If Tegra hsp device tree does not have 'shared irqs',

s/hsp/HSP/, otherwise looks good.

Shall correct.

Quoted 33 lines

Thierry

Quoted 30 lines

mailboxes pointer is NULL. Add non-NULL HSP mailboxes check in resume callback before tegra_hsp_mailbox_startup() call and prevent NULL pointer exception.

---
  drivers/mailbox/tegra-hsp.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/mailbox/tegra-hsp.c +6 -4
index f147374..a11fb1c 100644
@@ -782,11 +782,13 @@ static int __maybe_unused tegra_hsp_noirq_resume(struct device *dev)
  			tegra_hsp_doorbell_startup(db->channel.chan);
  	}
 
-	for (i = 0; i < hsp->num_sm; i++) {
-		struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
+	if (hsp->mailboxes) {
+		for (i = 0; i < hsp->num_sm; i++) {
+			struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
 
-		if (mb->channel.chan->cl)
-			tegra_hsp_mailbox_startup(mb->channel.chan);
+			if (mb->channel.chan->cl)
+				tegra_hsp_mailbox_startup(mb->channel.chan);
+		}
  	}
 
Quoted 3 lines
Quoted 3 lines
drivers/mailbox/tegra-hsp.c +0 -0
  	return 0;
Signature · 1 line
2.7.4

-Thanks,
Bitan

#4 lore raw
In reply to Bitan Biswas
Quoted 3 lines · Bitan Biswas

Add noirq resume instead of resume callback for Tegra HSP. Tegra HSP resume needs tegra_hsp_doorbell_startup() call to fix timeout error for tegra_bpmp_transfer() during genpd resume noirq on jetson-tx2.

s/jetson-tx2/Jetson TX2/?

Quoted 11 lines
---
 drivers/mailbox/tegra-hsp.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/mailbox/tegra-hsp.c +0 -0
index 91f1a0c..f147374 100644

drivers/mailbox/tegra-hsp.c static int tegra_hsp_probe(struct platform_device *pdev) · line 774

Quoted 5 lines
drivers/mailbox/tegra-hsp.c +1 -1
@@ -771,10 +771,16 @@ static int tegra_hsp_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __maybe_unused tegra_hsp_resume(struct device *dev)
+static int __maybe_unused tegra_hsp_noirq_resume(struct device *dev)

Maybe call this tegra_hsp_resume_noirq() to match the naming of the dev_pm_ops callback?

Quoted 13 lines
drivers/mailbox/tegra-hsp.c +6 -0
 {
 	struct tegra_hsp *hsp = dev_get_drvdata(dev);
 	unsigned int i;
+	struct tegra_hsp_doorbell *db;
+
+	list_for_each_entry(db, &hsp->doorbells, list) {
+		if (db && db->channel.chan)
+			tegra_hsp_doorbell_startup(db->channel.chan);
+	}
 
 	for (i = 0; i < hsp->num_sm; i++) {
 		struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];

drivers/mailbox/tegra-hsp.c static int __maybe_unused tegra_hsp_resume(struct device *dev) · line 796

Quoted 6 lines
drivers/mailbox/tegra-hsp.c +2 -1
@@ -786,7 +792,9 @@ static int __maybe_unused tegra_hsp_resume(struct device *dev)
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(tegra_hsp_pm_ops, NULL, tegra_hsp_resume);
+static const struct dev_pm_ops tegra_hsp_pm_ops = {
+	.resume_noirq   = tegra_hsp_noirq_resume,

There seems to be two extra spaces before that =.

Thierry

#5 lore raw
Quoted 6 lines · Thierry Reding
Quoted 3 lines · Bitan Biswas

Add noirq resume instead of resume callback for Tegra HSP. Tegra HSP resume needs tegra_hsp_doorbell_startup() call to fix timeout error for tegra_bpmp_transfer() during genpd resume noirq on jetson-tx2.

s/jetson-tx2/Jetson TX2/?

I shall replace the string "jetson-tx2" in commit description with "Jetson TX2".

Quoted 15 lines
Quoted 15 lines
---
  drivers/mailbox/tegra-hsp.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
drivers/mailbox/tegra-hsp.c +0 -0
index 91f1a0c..f147374 100644
@@ -771,10 +771,16 @@ static int tegra_hsp_probe(struct platform_device *pdev)
  	return 0;
  }
 
Quoted 5 lines

drivers/mailbox/tegra-hsp.c static int tegra_hsp_probe(struct platform_device *pdev) · line 774

Quoted 2 lines
drivers/mailbox/tegra-hsp.c +1 -1
-static int __maybe_unused tegra_hsp_resume(struct device *dev)
+static int __maybe_unused tegra_hsp_noirq_resume(struct device *dev)

Maybe call this tegra_hsp_resume_noirq() to match the naming of the dev_pm_ops callback?

I shall rename tegra_hsp_noirq_resume back to tegra_hsp_resume.

Quoted 17 lines
Quoted 17 lines
drivers/mailbox/tegra-hsp.c +6 -0
  {
  	struct tegra_hsp *hsp = dev_get_drvdata(dev);
  	unsigned int i;
+	struct tegra_hsp_doorbell *db;
+
+	list_for_each_entry(db, &hsp->doorbells, list) {
+		if (db && db->channel.chan)
+			tegra_hsp_doorbell_startup(db->channel.chan);
+	}
 
  	for (i = 0; i < hsp->num_sm; i++) {
  		struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
@@ -786,7 +792,9 @@ static int __maybe_unused tegra_hsp_resume(struct device *dev)
  	return 0;
  }
 
Quoted 5 lines

drivers/mailbox/tegra-hsp.c static int __maybe_unused tegra_hsp_resume(struct device *dev) · line 796

Quoted 3 lines
drivers/mailbox/tegra-hsp.c +2 -1
-static SIMPLE_DEV_PM_OPS(tegra_hsp_pm_ops, NULL, tegra_hsp_resume);
+static const struct dev_pm_ops tegra_hsp_pm_ops = {
+	.resume_noirq   = tegra_hsp_noirq_resume,

There seems to be two extra spaces before that =.

Missed extra spaces. Shall fix.

-Thanks,
Bitan