[PATCH v2 1/2] cdrom: gdrom: replace port I/O with MMIO accessors
From: Florian Fuchs
Date: Sun Apr 19 2026 - 12:30:45 EST
GDROM_DATA_REG is a memory-mapped data register, but the driver uses
outsw() and insw() only for this register. Replace this with MMIO
accessors readsw() / writesw().
Before, it oopsed accessing the data register, as the io_port_base
P2SEG gets added to the argument in outsw() / insw(), which leads to an
unusable drive:
BUG: unable to handle kernel paging request at 405f7080
PC: [<8c28d5b4>] gdrom_spicommand+0x6c/0xb0
Signed-off-by: Florian Fuchs <fuchsfl@xxxxxxxxx>
---
v1->v2: Don't use helper functions with io.*_rep(), but writesw() and
readsw() local in the respective functions
v1: https://lore.kernel.org/linux-sh/20260405082330.4104672-2-fuchsfl@xxxxxxxxx/
---
drivers/cdrom/gdrom.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 4ba4dd06cbf4..89938d9b2825 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -198,7 +198,7 @@ static void gdrom_spicommand(void *spi_string, int buflen)
gdrom_getsense(NULL);
return;
}
- outsw(GDROM_DATA_REG, cmd, 6);
+ writesw((void __iomem *)GDROM_DATA_REG, cmd, 6);
}
@@ -282,7 +282,7 @@ static int gdrom_readtoc_cmd(struct gdromtoc *toc, int session)
err = -EINVAL;
goto cleanup_readtoc;
}
- insw(GDROM_DATA_REG, toc, tocsize/2);
+ readsw((void __iomem *)GDROM_DATA_REG, toc, tocsize / 2);
if (gd.status & 0x01)
err = -EINVAL;
@@ -433,7 +433,7 @@ static int gdrom_getsense(short *bufstring)
GDROM_DEFAULT_TIMEOUT);
if (gd.pending)
goto cleanup_sense;
- insw(GDROM_DATA_REG, &sense, sense_command->buflen/2);
+ readsw((void __iomem *)GDROM_DATA_REG, &sense, sense_command->buflen / 2);
if (sense[1] & 40) {
pr_info("Drive not ready - command aborted\n");
goto cleanup_sense;
@@ -612,7 +612,7 @@ static blk_status_t gdrom_readdisk_dma(struct request *req)
cpu_relax();
gd.pending = 1;
gd.transfer = 1;
- outsw(GDROM_DATA_REG, &read_command->cmd, 6);
+ writesw((void __iomem *)GDROM_DATA_REG, read_command->cmd, 6);
timeout = jiffies + HZ / 2;
/* Wait for any pending DMA to finish */
while (__raw_readb(GDROM_DMA_STATUS_REG) &&
--
2.43.0