Skip to contentSkip to conversation

ata: pata_marvell: Check the 'bmdma_addr' beforing reading

PATCH In review Zheyu Ma 3 participants 5 messages Apr 21, 2022 – Apr 25, 2022

Subsystems (2)
lore
Share & tools
lore

Zheyu Ma

author
#0 lore raw

PATCH v2 1/1 ata: pata_marvell: Check the 'bmdma_addr' beforing reading

Before detecting the cable type on the dma bar, the driver should check whether the 'bmdma_addr' is zero, which means the adapter does not support DMA, otherwise we will get the following error:

[    5.146634] Bad IO access at port 0x1 (return inb(port))
[    5.147206] WARNING: CPU: 2 PID: 303 at lib/iomap.c:44 ioread8+0x4a/0x60
[    5.150856] RIP: 0010:ioread8+0x4a/0x60
[    5.160238] Call Trace:
[    5.160470]  <TASK>
[    5.160674]  marvell_cable_detect+0x6e/0xc0 [pata_marvell]
[    5.161728]  ata_eh_recover+0x3520/0x6cc0
[    5.168075]  ata_do_eh+0x49/0x3c0

---Changes in v2:
- Delete the useless 'else'

---
 drivers/ata/pata_marvell.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/ata/pata_marvell.c +2 -0
index 0c5a51970fbf..014ccb0f45dc 100644
@@ -77,6 +77,8 @@ static int marvell_cable_detect(struct ata_port *ap)
 	switch(ap->port_no)
 	{
 	case 0:
+		if (!ap->ioaddr.bmdma_addr)
+			return ATA_CBL_PATA_UNK;
 		if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1)
 			return ATA_CBL_PATA40;
 		return ATA_CBL_PATA80;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 13 lines · Zheyu Ma

Before detecting the cable type on the dma bar, the driver should check whether the 'bmdma_addr' is zero, which means the adapter does not support DMA, otherwise we will get the following error:

[    5.146634] Bad IO access at port 0x1 (return inb(port))
[    5.147206] WARNING: CPU: 2 PID: 303 at lib/iomap.c:44 ioread8+0x4a/0x60
[    5.150856] RIP: 0010:ioread8+0x4a/0x60
[    5.160238] Call Trace:
[    5.160470]  <TASK>
[    5.160674]  marvell_cable_detect+0x6e/0xc0 [pata_marvell]
[    5.161728]  ata_eh_recover+0x3520/0x6cc0
[    5.168075]  ata_do_eh+0x49/0x3c0
Quoted 3 lines

---Changes in v2:
- Delete the useless 'else'

Note for future contributions: The change log should be placed *after* the "---" that comes before the "diff" line below. Otherwise, the change log pollutes the commit message.

I fixed that and applied to for-5.18-fixes. Thanks.

Quoted 17 lines
---
  drivers/ata/pata_marvell.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/ata/pata_marvell.c +2 -0
index 0c5a51970fbf..014ccb0f45dc 100644
@@ -77,6 +77,8 @@ static int marvell_cable_detect(struct ata_port *ap)
  	switch(ap->port_no)
  	{
  	case 0:
+		if (!ap->ioaddr.bmdma_addr)
+			return ATA_CBL_PATA_UNK;
  		if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1)
  			return ATA_CBL_PATA40;
  		return ATA_CBL_PATA80;
Signature · 2 lines
Damien Le Moal
Western Digital Research
author
#2 lore raw
Quoted 15 lines · Damien Le Moal
Quoted 13 lines · Zheyu Ma

Before detecting the cable type on the dma bar, the driver should check whether the 'bmdma_addr' is zero, which means the adapter does not support DMA, otherwise we will get the following error:

[    5.146634] Bad IO access at port 0x1 (return inb(port))
[    5.147206] WARNING: CPU: 2 PID: 303 at lib/iomap.c:44 ioread8+0x4a/0x60
[    5.150856] RIP: 0010:ioread8+0x4a/0x60
[    5.160238] Call Trace:
[    5.160470]  <TASK>
[    5.160674]  marvell_cable_detect+0x6e/0xc0 [pata_marvell]
[    5.161728]  ata_eh_recover+0x3520/0x6cc0
[    5.168075]  ata_do_eh+0x49/0x3c0
Quoted 7 lines
Quoted 3 lines

---Changes in v2:
- Delete the useless 'else'

Note for future contributions: The change log should be placed *after* the "---" that comes before the "diff" line below. Otherwise, the change log pollutes the commit message.

Thank you for the reminder, I'll pay attention to this problem next time!

Zheyu Ma

#3 lore raw
In reply to Damien Le Moal
Quoted 18 lines · Damien Le Moal
Quoted 13 lines · Zheyu Ma

Before detecting the cable type on the dma bar, the driver should check whether the 'bmdma_addr' is zero, which means the adapter does not support DMA, otherwise we will get the following error:

[    5.146634] Bad IO access at port 0x1 (return inb(port))
[    5.147206] WARNING: CPU: 2 PID: 303 at lib/iomap.c:44 ioread8+0x4a/0x60
[    5.150856] RIP: 0010:ioread8+0x4a/0x60
[    5.160238] Call Trace:
[    5.160470]  <TASK>
[    5.160674]  marvell_cable_detect+0x6e/0xc0 [pata_marvell]
[    5.161728]  ata_eh_recover+0x3520/0x6cc0
[    5.168075]  ata_do_eh+0x49/0x3c0
Quoted 3 lines

---Changes in v2:
- Delete the useless 'else'

Quoted 5 lines

Note for future contributions: The change log should be placed *after* the "---" that comes before the "diff" line below. Otherwise, the change log pollutes the commit message.

I fixed that and applied to for-5.18-fixes. Thanks.

I completely overlooked that this needs a CC stable...

Greg,

Could you please pickup this commit for stable ?
In Linus tree/rc4, it is:

aafa9f958342 ("ata: pata_marvell: Check the 'bmdma_addr' beforing reading")

Thanks !

Quoted 20 lines
Quoted 18 lines
---
  drivers/ata/pata_marvell.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/ata/pata_marvell.c +2 -0
index 0c5a51970fbf..014ccb0f45dc 100644
@@ -77,6 +77,8 @@ static int marvell_cable_detect(struct ata_port *ap)
  	switch(ap->port_no)
  	{
  	case 0:
+		if (!ap->ioaddr.bmdma_addr)
+			return ATA_CBL_PATA_UNK;
  		if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1)
  			return ATA_CBL_PATA40;
  		return ATA_CBL_PATA80;
Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer
#4 lore raw
Quoted 25 lines · Damien Le Moal
Quoted 18 lines · Damien Le Moal
Quoted 13 lines · Zheyu Ma

Before detecting the cable type on the dma bar, the driver should check whether the 'bmdma_addr' is zero, which means the adapter does not support DMA, otherwise we will get the following error:

[    5.146634] Bad IO access at port 0x1 (return inb(port))
[    5.147206] WARNING: CPU: 2 PID: 303 at lib/iomap.c:44 ioread8+0x4a/0x60
[    5.150856] RIP: 0010:ioread8+0x4a/0x60
[    5.160238] Call Trace:
[    5.160470]  <TASK>
[    5.160674]  marvell_cable_detect+0x6e/0xc0 [pata_marvell]
[    5.161728]  ata_eh_recover+0x3520/0x6cc0
[    5.168075]  ata_do_eh+0x49/0x3c0
Quoted 3 lines

---Changes in v2:
- Delete the useless 'else'

Quoted 5 lines

Note for future contributions: The change log should be placed *after* the "---" that comes before the "diff" line below. Otherwise, the change log pollutes the commit message.

I fixed that and applied to for-5.18-fixes. Thanks.

Quoted 8 lines

I completely overlooked that this needs a CC stable...

Greg,

Could you please pickup this commit for stable ?
In Linus tree/rc4, it is:

aafa9f958342 ("ata: pata_marvell: Check the 'bmdma_addr' beforing reading")

Now queued up, thanks.

greg k-h