[PATCH v4 1/3] cdrom: gdrom: replace port I/O with MMIO accessors

From: Florian Fuchs

Date: Fri May 15 2026 - 15:53: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

Acked-by: Artur Rojek <contact@xxxxxxxxxxxxxx>
Reviewed-by: Adrian McMenamin <adrianmcmenamin@xxxxxxxxx>
Signed-off-by: Florian Fuchs <fuchsfl@xxxxxxxxx>
---
v3->v4: no functional change. Sort trailers.
v2->v3: no functional change. Added Acked-by from Artur Rojek.
Added Reviewed-by tag from Adrian McMenamin.
v1->v2: Don't use helper functions with io.*_rep(), but writesw() and
readsw() local in the respective functions

v3: https://lore.kernel.org/linux-sh/20260423194132.693271-2-fuchsfl@xxxxxxxxx/
v2: https://lore.kernel.org/linux-sh/20260419162823.2829286-2-fuchsfl@xxxxxxxxx/
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..094d55b2d004 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) &&

base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
--
2.43.0