Skip to contentSkip to conversation

ata: sata_dwc_460ex: Don't enable interrupt if libATA core registration fails

PATCH Superseded Nikolay Borisov 3 participants 4 messages Sep 17 libata

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ata: sata_dwc_460ex: Don't enable interrupt if libATA core registration fails

Recent 4bbc16a353a9 commit changed the timing when interrupts are enabled. However it didn't account for the libATA registration step. So it's possible that interrupts are enabled when the device is not registered with libATA core.

Resolve the issue by ensuring that interrupts are enabled only if the rest of the initialization is successful.

Fixes 4bbc16a353a9 ("ata: sata_dwc_460ex: enable SATA interrupts only after IRQ handler is registered")

---

Changes since v1:
* Added proper goto label
Changes since v2:
* Rework logic so that interrupts are enabled if everything is successful and don't call phy_exit otherwise, as the driver is quite broken w.r.t to it.

 drivers/ata/sata_dwc_460ex.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/ata/sata_dwc_460ex.c +5 -3
index 8e3fc713891a..e74335dec42a 100644
@@ -1185,11 +1185,13 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	 * error_handler() to execute a dummy Softreset EH session
 	 */
 	err = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
-	if (err)
+	if (err) {
 		dev_err(dev, "failed to activate host");
+	} else {
+		/* Enable SATA Interrupts */
+		sata_dwc_enable_interrupts(hsdev);
+	}
 
-	/* Enable SATA Interrupts */
-	sata_dwc_enable_interrupts(hsdev);
 	return 0;
 
 error_out:

--
2.55.0

maintainer
#1 lore raw
Quoted 27 lines · Nikolay Borisov

Recent 4bbc16a353a9 commit changed the timing when interrupts are enabled. However it didn't account for the libATA registration step. So it's possible that interrupts are enabled when the device is not registered with libATA core.

Resolve the issue by ensuring that interrupts are enabled only if the rest of the initialization is successful.

Fixes 4bbc16a353a9 ("ata: sata_dwc_460ex: enable SATA interrupts only after IRQ handler is registered")

---

Changes since v1:
* Added proper goto label
Changes since v2:
* Rework logic so that interrupts are enabled if everything is successful and don't call phy_exit otherwise, as the driver is quite broken w.r.t to it.

 drivers/ata/sata_dwc_460ex.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/ata/sata_dwc_460ex.c +0 -0
index 8e3fc713891a..e74335dec42a 100644

drivers/ata/sata_dwc_460ex.c static int sata_dwc_probe(struct platform_device *ofdev) · line 1189

Quoted 6 lines
drivers/ata/sata_dwc_460ex.c +1 -1
@@ -1185,11 +1185,13 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	 * error_handler() to execute a dummy Softreset EH session
 	 */
 	err = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
-	if (err)
+	if (err) {
 		dev_err(dev, "failed to activate host");

Why not simply "goto err_out;" here ?

Quoted 12 lines
drivers/ata/sata_dwc_460ex.c +4 -3
+	} else {
+		/* Enable SATA Interrupts */
+		sata_dwc_enable_interrupts(hsdev);
+	}
 
-	/* Enable SATA Interrupts */
-	sata_dwc_enable_interrupts(hsdev);
 	return 0;
 
 error_out:
--

2.55.0

Signature · 2 lines
Damien Le Moal
Western Digital Research
#2 lore raw
Quoted 23 lines · Damien Le Moal
Quoted 22 lines · Nikolay Borisov

Recent 4bbc16a353a9 commit changed the timing when interrupts are enabled. However it didn't account for the libATA registration step. So it's possible that interrupts are enabled when the device is not registered with libATA core.

Resolve the issue by ensuring that interrupts are enabled only if the rest of the initialization is successful.

Fixes 4bbc16a353a9 ("ata: sata_dwc_460ex: enable SATA interrupts only after IRQ handler is registered")

---

Changes since v1:
* Added proper goto label
Changes since v2:
* Rework logic so that interrupts are enabled if everything is successful and don't call phy_exit otherwise, as the driver is quite broken w.r.t to it.

  drivers/ata/sata_dwc_460ex.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
Quoted 13 lines

drivers/ata/sata_dwc_460ex.c static int sata_dwc_probe(struct platform_device *ofdev) · line 1189

Quoted 11 lines
drivers/ata/sata_dwc_460ex.c +1 -1
index 8e3fc713891a..e74335dec42a 100644
@@ -1185,11 +1185,13 @@ static int sata_dwc_probe(struct platform_device *ofdev)
  	 * error_handler() to execute a dummy Softreset EH session
  	 */
  	err = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
-	if (err)
+	if (err) {
  		dev_err(dev, "failed to activate host");

Why not simply "goto err_out;" here ?

That was in V2 however Niklas discovered some issue w.r.t to phy_exit. https://lore.kernel.org/all/aqGFjsuIMRIy5xfv@ryzen/

Quoted 15 lines
Quoted 13 lines
drivers/ata/sata_dwc_460ex.c +4 -3
+	} else {
+		/* Enable SATA Interrupts */
+		sata_dwc_enable_interrupts(hsdev);
+	}
 
-	/* Enable SATA Interrupts */
-	sata_dwc_enable_interrupts(hsdev);
  	return 0;
 
  error_out:
--

2.55.0

maintainer
#3 lore raw
Quoted 40 lines · Nikolay Borisov
Quoted 23 lines · Damien Le Moal
Quoted 22 lines · Nikolay Borisov

Recent 4bbc16a353a9 commit changed the timing when interrupts are enabled. However it didn't account for the libATA registration step. So it's possible that interrupts are enabled when the device is not registered with libATA core.

Resolve the issue by ensuring that interrupts are enabled only if the rest of the initialization is successful.

Fixes 4bbc16a353a9 ("ata: sata_dwc_460ex: enable SATA interrupts only after IRQ handler is registered")

---

Changes since v1:
* Added proper goto label
Changes since v2:
* Rework logic so that interrupts are enabled if everything is successful and don't call phy_exit otherwise, as the driver is quite broken w.r.t to it.

  drivers/ata/sata_dwc_460ex.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
Quoted 13 lines

drivers/ata/sata_dwc_460ex.c static int sata_dwc_probe(struct platform_device *ofdev) · line 1189

Quoted 11 lines
drivers/ata/sata_dwc_460ex.c +1 -1
index 8e3fc713891a..e74335dec42a 100644
@@ -1185,11 +1185,13 @@ static int sata_dwc_probe(struct platform_device *ofdev)
  	 * error_handler() to execute a dummy Softreset EH session
  	 */
  	err = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
-	if (err)
+	if (err) {
  		dev_err(dev, "failed to activate host");

Why not simply "goto err_out;" here ?

Quoted 2 lines

That was in V2 however Niklas discovered some issue w.r.t to phy_exit.
https://lore.kernel.org/all/aqGFjsuIMRIy5xfv@ryzen/

I have since merged a series, which is queued on ibata/linux.git (for-7.4):
https://lore.kernel.org/linux-ide/[email protected]/

See:
https://lore.kernel.org/linux-ide/[email protected]/

Where, if ata_host_activate() failed after ata_host_start() returned success (which will have called call->port_start()), it will call ata_host_undo_start() which will call ->port_stop().

Thus, the Sashiko comment on your v2:
https://lore.kernel.org/linux-ide/[email protected]/

is no longer valid.

Please send your V2 again (as a V4) just so that we can get Sashiko to review it again.

Preferably use:

$ git format-patch --base libata/for-7.4

So that it adds the proper base commit that you depend on.

Kind regards,
Niklas