All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5] Fixes to DMA state check
@ 2021-10-12  6:27 Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 1/6] libata: fix checking of DMA state Reimar Döffinger
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Reimar Döffinger @ 2021-10-12  6:27 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide, Jens Axboe, hch, Paul Menzel

Patch series to add ata_dma_enabled calls instead of incorrectly
checking dev->dma_mode != 0.
Only the first patch is confirmed to have caused real issues
that it indeed fixes, rest based purely on code review.

Changes v5:
Add stable Cc to first patch, which is confirmed to fix
issues seen by users.

Changes v4:
- split per file/driver
- added Signed-off-by and Tested-by lines, improved commit messages
Changes v3:
- found and updated more cases in pata_ali, pata_amd and pata_radisys.
Changes v2:
- removed initialization change for SATA. I got confused by the
  ping-pong between libata-eh and libata-core and thought SATA did not
  set up xfermode
- reviewed other cases that used dma_mode in boolean context and those
  seemed to need changing as well, so added them to patch.
  I did not see any places that would set dma_mode to 0 ever, so I
  do think they were all indeed wrong.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/6] libata: fix checking of DMA state
  2021-10-12  6:27 [PATCH v5] Fixes to DMA state check Reimar Döffinger
@ 2021-10-12  6:27 ` Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 2/6] libata-scsi: " Reimar Döffinger
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Reimar Döffinger @ 2021-10-12  6:27 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide, Jens Axboe, hch, Paul Menzel

Checking if DMA is enabled should be done via the
ata_dma_enabled helper function, since the init state
0xff indicates disabled.
This meant that ATA_CMD_READ_LOG_DMA_EXT was used and probed
for before DMA was enabled, which caused hangs for some combinations
of controllers and devices.
It might also have caused it to be incorrectly disabled as broken,
but there have been no reports of that.

Cc: stable@vger.kernel.org
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=195895
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Tested-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
 drivers/ata/libata-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index eed65311b5d1..046faf0dbdd3 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2007,7 +2007,7 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
 
 retry:
 	ata_tf_init(dev, &tf);
-	if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id) &&
+	if (ata_dma_enabled(dev) && ata_id_has_read_log_dma_ext(dev->id) &&
 	    !(dev->horkage & ATA_HORKAGE_NO_DMA_LOG)) {
 		tf.command = ATA_CMD_READ_LOG_DMA_EXT;
 		tf.protocol = ATA_PROT_DMA;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/6] libata-scsi: fix checking of DMA state
  2021-10-12  6:27 [PATCH v5] Fixes to DMA state check Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 1/6] libata: fix checking of DMA state Reimar Döffinger
@ 2021-10-12  6:27 ` Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 3/6] pata_ali: " Reimar Döffinger
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Reimar Döffinger @ 2021-10-12  6:27 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide, Jens Axboe, hch, Paul Menzel

Checking if DMA is enabled should be done via the
ata_dma_enabled helper function, since the init state
0xff indicates disabled.
Change based on code review, not tested due to lack of hardware.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
---
 drivers/ata/libata-scsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 1fb4611f7eeb..0adea33f2137 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2981,7 +2981,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
 	ata_qc_set_pc_nbytes(qc);
 
 	/* We may not issue DMA commands if no DMA mode is set */
-	if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) {
+	if (tf->protocol == ATA_PROT_DMA && !ata_dma_enabled(dev)) {
 		fp = 1;
 		goto invalid_fld;
 	}
@@ -3131,7 +3131,7 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
 	u8 unmap = cdb[1] & 0x8;
 
 	/* we may not issue DMA commands if no DMA mode is set */
-	if (unlikely(!dev->dma_mode))
+	if (unlikely(!ata_dma_enabled(dev)))
 		goto invalid_opcode;
 
 	/*
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] pata_ali: fix checking of DMA state
  2021-10-12  6:27 [PATCH v5] Fixes to DMA state check Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 1/6] libata: fix checking of DMA state Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 2/6] libata-scsi: " Reimar Döffinger
@ 2021-10-12  6:27 ` Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 4/6] pata_amd: " Reimar Döffinger
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Reimar Döffinger @ 2021-10-12  6:27 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide, Jens Axboe, hch, Paul Menzel

Checking if DMA is enabled should be done via the
ata_dma_enabled helper function, since the init state
0xff indicates disabled.
Change based on code review, not tested due to lack of hardware.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
---
 drivers/ata/pata_ali.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 557ecf466102..b7ff63ed3bbb 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -215,7 +215,7 @@ static void ali_set_piomode(struct ata_port *ap, struct ata_device *adev)
 		struct ata_timing p;
 		ata_timing_compute(pair, pair->pio_mode, &p, T, 1);
 		ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP|ATA_TIMING_8BIT);
-		if (pair->dma_mode) {
+		if (ata_dma_enabled(pair)) {
 			ata_timing_compute(pair, pair->dma_mode, &p, T, 1);
 			ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP|ATA_TIMING_8BIT);
 		}
@@ -264,7 +264,7 @@ static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 			struct ata_timing p;
 			ata_timing_compute(pair, pair->pio_mode, &p, T, 1);
 			ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP|ATA_TIMING_8BIT);
-			if (pair->dma_mode) {
+			if (ata_dma_enabled(pair)) {
 				ata_timing_compute(pair, pair->dma_mode, &p, T, 1);
 				ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP|ATA_TIMING_8BIT);
 			}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/6] pata_amd: fix checking of DMA state
  2021-10-12  6:27 [PATCH v5] Fixes to DMA state check Reimar Döffinger
                   ` (2 preceding siblings ...)
  2021-10-12  6:27 ` [PATCH 3/6] pata_ali: " Reimar Döffinger
@ 2021-10-12  6:27 ` Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 5/6] pata_optidma: " Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 6/6] pata_radisys: " Reimar Döffinger
  5 siblings, 0 replies; 8+ messages in thread
From: Reimar Döffinger @ 2021-10-12  6:27 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide, Jens Axboe, hch, Paul Menzel

Checking if DMA is enabled should be done via the
ata_dma_enabled helper function, since the init state
0xff indicates disabled.
Change based on code review, not tested due to lack of hardware.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
---
 drivers/ata/pata_amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index c8acba162d02..154748cfcc79 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -66,7 +66,7 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse
 
 	if (peer) {
 		/* This may be over conservative */
-		if (peer->dma_mode) {
+		if (ata_dma_enabled(peer)) {
 			ata_timing_compute(peer, peer->dma_mode, &apeer, T, UT);
 			ata_timing_merge(&apeer, &at, &at, ATA_TIMING_8BIT);
 		}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/6] pata_optidma: fix checking of DMA state
  2021-10-12  6:27 [PATCH v5] Fixes to DMA state check Reimar Döffinger
                   ` (3 preceding siblings ...)
  2021-10-12  6:27 ` [PATCH 4/6] pata_amd: " Reimar Döffinger
@ 2021-10-12  6:27 ` Reimar Döffinger
  2021-10-12  6:27 ` [PATCH 6/6] pata_radisys: " Reimar Döffinger
  5 siblings, 0 replies; 8+ messages in thread
From: Reimar Döffinger @ 2021-10-12  6:27 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide, Jens Axboe, hch, Paul Menzel

Checking if DMA is enabled should be done via the
ata_dma_enabled helper function, since the init state
0xff indicates disabled.
Change based on code review, not tested due to lack of hardware.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
---
 drivers/ata/pata_optidma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index f6278d9de348..ad1090b90e52 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -153,7 +153,7 @@ static void optidma_mode_setup(struct ata_port *ap, struct ata_device *adev, u8
 	if (pair) {
 		u8 pair_addr;
 		/* Hardware constraint */
-		if (pair->dma_mode)
+		if (ata_dma_enabled(pair))
 			pair_addr = 0;
 		else
 			pair_addr = addr_timing[pci_clock][pair->pio_mode - XFER_PIO_0];
@@ -301,7 +301,7 @@ static u8 optidma_make_bits43(struct ata_device *adev)
 	};
 	if (!ata_dev_enabled(adev))
 		return 0;
-	if (adev->dma_mode)
+	if (ata_dma_enabled(adev))
 		return adev->dma_mode - XFER_MW_DMA_0;
 	return bits43[adev->pio_mode - XFER_PIO_0];
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/6] pata_radisys: fix checking of DMA state
  2021-10-12  6:27 [PATCH v5] Fixes to DMA state check Reimar Döffinger
                   ` (4 preceding siblings ...)
  2021-10-12  6:27 ` [PATCH 5/6] pata_optidma: " Reimar Döffinger
@ 2021-10-12  6:27 ` Reimar Döffinger
  5 siblings, 0 replies; 8+ messages in thread
From: Reimar Döffinger @ 2021-10-12  6:27 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide, Jens Axboe, hch, Paul Menzel

Checking if DMA is enabled should be done via the
ata_dma_enabled helper function, since the init state
0xff indicates disabled.
Change based on code review, not tested due to lack of hardware.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
---
 drivers/ata/pata_radisys.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
index 8fde4a86401b..3aca8fe3fdb6 100644
--- a/drivers/ata/pata_radisys.c
+++ b/drivers/ata/pata_radisys.c
@@ -172,8 +172,8 @@ static unsigned int radisys_qc_issue(struct ata_queued_cmd *qc)
 
 	if (adev != ap->private_data) {
 		/* UDMA timing is not shared */
-		if (adev->dma_mode < XFER_UDMA_0) {
-			if (adev->dma_mode)
+		if (adev->dma_mode < XFER_UDMA_0 || !ata_dma_enabled(adev)) {
+			if (ata_dma_enabled(adev))
 				radisys_set_dmamode(ap, adev);
 			else if (adev->pio_mode)
 				radisys_set_piomode(ap, adev);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] pata_ali: fix checking of DMA state
  2021-10-03 13:28 ` [PATCH v4] Fixes to DMA state check Reimar Döffinger
@ 2021-10-03 13:28   ` Reimar Döffinger
  0 siblings, 0 replies; 8+ messages in thread
From: Reimar Döffinger @ 2021-10-03 13:28 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide, Jens Axboe, hch, Paul Menzel

Checking if DMA is enabled should be done via the
ata_dma_enabled helper function, since the init state
0xff indicates disabled.
Change based on code review, not tested due to lack of hardware.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
---
 drivers/ata/pata_ali.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 557ecf466102..b7ff63ed3bbb 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -215,7 +215,7 @@ static void ali_set_piomode(struct ata_port *ap, struct ata_device *adev)
 		struct ata_timing p;
 		ata_timing_compute(pair, pair->pio_mode, &p, T, 1);
 		ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP|ATA_TIMING_8BIT);
-		if (pair->dma_mode) {
+		if (ata_dma_enabled(pair)) {
 			ata_timing_compute(pair, pair->dma_mode, &p, T, 1);
 			ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP|ATA_TIMING_8BIT);
 		}
@@ -264,7 +264,7 @@ static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 			struct ata_timing p;
 			ata_timing_compute(pair, pair->pio_mode, &p, T, 1);
 			ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP|ATA_TIMING_8BIT);
-			if (pair->dma_mode) {
+			if (ata_dma_enabled(pair)) {
 				ata_timing_compute(pair, pair->dma_mode, &p, T, 1);
 				ata_timing_merge(&p, &t, &t, ATA_TIMING_SETUP|ATA_TIMING_8BIT);
 			}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-10-12  6:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12  6:27 [PATCH v5] Fixes to DMA state check Reimar Döffinger
2021-10-12  6:27 ` [PATCH 1/6] libata: fix checking of DMA state Reimar Döffinger
2021-10-12  6:27 ` [PATCH 2/6] libata-scsi: " Reimar Döffinger
2021-10-12  6:27 ` [PATCH 3/6] pata_ali: " Reimar Döffinger
2021-10-12  6:27 ` [PATCH 4/6] pata_amd: " Reimar Döffinger
2021-10-12  6:27 ` [PATCH 5/6] pata_optidma: " Reimar Döffinger
2021-10-12  6:27 ` [PATCH 6/6] pata_radisys: " Reimar Döffinger
  -- strict thread matches above, loose matches on Subject: below --
2021-09-27  9:15 [PATCH] libata: " Damien Le Moal
2021-10-03 13:28 ` [PATCH v4] Fixes to DMA state check Reimar Döffinger
2021-10-03 13:28   ` [PATCH 3/6] pata_ali: fix checking of DMA state Reimar Döffinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.