From: Florian Fuchs <fuchsfl@gmail.com>
To: Adrian McMenamin <adrianmcmenamin@gmail.com>
Cc: linux-sh@vger.kernel.org,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
Artur Rojek <contact@artur-rojek.eu>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] cdrom: gdrom: replace port I/O with MMIO accessors
Date: Mon, 6 Apr 2026 11:05:31 +0200 [thread overview]
Message-ID: <adN3W5qr-XhusNmq@lithos> (raw)
In-Reply-To: <CACwZE5QeuDnEOGar6-0tfkhO2s8UuvdcjMMf7ubFhVUeh=7JcA@mail.gmail.com>
On 05 Apr 14:16, Adrian McMenamin wrote:
> On Sun, 5 Apr 2026 at 09:23, Florian Fuchs <fuchsfl@gmail.com> wrote:
> >
> > GDROM_DATA_REG is a memory-mapped data register, but the driver uses
> > outsw() and insw() only for this register. Replace this with local
> > helpers using MMIO accessors ioread16_rep() / iowrite16_rep().
> >
> > 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@gmail.com>
> > ---
> > The original Oops can be reproduced just by mounting a disc, like:
> > mount -t iso9660 -o ro /dev/gdrom /mnt
> > ---
> > drivers/cdrom/gdrom.c | 18 ++++++++++++++----
> > 1 file changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
> > index 4ba4dd06cbf4..dccf41fa5d0a 100644
> > --- a/drivers/cdrom/gdrom.c
> > +++ b/drivers/cdrom/gdrom.c
> > @@ -171,6 +171,16 @@ static void gdrom_identifydevice(void *buf)
> > data[c] = __raw_readw(GDROM_DATA_REG);
> > }
> >
> > +static void gdrom_fifo_readw(void *buf, unsigned int words)
> > +{
> > + ioread16_rep((void __iomem *)GDROM_DATA_REG, buf, words);
> > +}
> > +
> > +static void gdrom_fifo_writew(const void *buf, unsigned int words)
> > +{
> > + iowrite16_rep((void __iomem *)GDROM_DATA_REG, buf, words);
> > +}
> > +
> > static void gdrom_spicommand(void *spi_string, int buflen)
> > {
> > short *cmd = spi_string;
> > @@ -198,7 +208,7 @@ static void gdrom_spicommand(void *spi_string, int buflen)
> > gdrom_getsense(NULL);
> > return;
> > }
> > - outsw(GDROM_DATA_REG, cmd, 6);
> > + gdrom_fifo_writew(cmd, 6);
> > }
> >
>
>
> This is one of those "how did this ever work to begin with" bugs when
> examined today - bur rather than introduce new local functions can we
> not just use either readsw(p, d, l)/writesw(p, d, l) or
> __raw_writew(p,d,l) and __raw_read(p,d,l) directly?
>
> Adrian
Yeah, totally, I put them inline. I first had a loop with the __raw.*
functions, that made more sense to extract.
Will send it, Thanks!
Florian
next prev parent reply other threads:[~2026-04-06 9:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-05 8:23 [PATCH 0/2] cdrom: gdrom: fix block I/O and capacity setting Florian Fuchs
2026-04-05 8:23 ` [PATCH 1/2] cdrom: gdrom: replace port I/O with MMIO accessors Florian Fuchs
2026-04-05 13:16 ` Adrian McMenamin
2026-04-06 9:05 ` Florian Fuchs [this message]
2026-04-05 8:23 ` [PATCH 2/2] cdrom: gdrom: update gendisk capacity on open Florian Fuchs
2026-04-05 13:24 ` Adrian McMenamin
2026-04-06 9:20 ` Florian Fuchs
2026-04-06 10:00 ` Adrian McMenamin
2026-04-06 10:21 ` Adrian McMenamin
2026-04-06 15:12 ` Florian Fuchs
2026-04-05 14:09 ` [PATCH 0/2] cdrom: gdrom: fix block I/O and capacity setting John Paul Adrian Glaubitz
2026-04-06 0:58 ` Florian Fuchs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adN3W5qr-XhusNmq@lithos \
--to=fuchsfl@gmail.com \
--cc=adrianmcmenamin@gmail.com \
--cc=contact@artur-rojek.eu \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.