qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: <jasper.lowell@bt.com>
To: <balaton@eik.bme.hu>
Cc: jsnow@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH] hw/ide: Remove status register read side effect
Date: Sat, 22 Feb 2020 02:07:25 +0000	[thread overview]
Message-ID: <d805ea83320fdb2de626b0657e94a87bc0ea5015.camel@bt.com> (raw)
In-Reply-To: <alpine.BSF.2.22.395.2002211635360.45267@zero.eik.bme.hu>

> The chip docs don't mention any side effect, they only say that the
> DMA 
> IRQ and Error bits in the bus master IDE status reg (bits 2 and 1)
> are 
> write 1 to clear

I haven't found any documentation that mention that side effect either.
As you say, it only mentions that you should set the bit to clear.
While the side effect of clearing interrupts by reading the status
register doesn't appear to be in documentation anywhere (to my
knowledge), I do see this side effect referenced in the source code of
drivers occasionally.

In /drivers/ide/ide-io.c of the Linux kernel:
/*
 * Whack the status register, just in case
 * we have a leftover pending IRQ.
 */
(void)hwif->tp_ops->read_status(hwif);

Along with:
 *	There's nothing really useful we can do with an unexpected
interrupt,
 *	other than reading the status register (to clear it), and
logging it.

The CMD64x specific code in the Linux kernel does explicitly set the
IRQ bits in the bus master IDE status register to clear it. I'm not
sure why, so maybe someone else can chime in explaining why Linux
sometimes clears interrupts by reading the status register and other
times follows the documentation and sets the required bits. The OpenBSD
driver also appears to set the bits explicitly.

I think the reason why the Solaris 10 driver crashes fatally whereas
Linux and OpenBSD ignore the side effect is because when clearing
interrupts, Solaris 10 expects the interrupt bit to be set and checks
this. Linux and OpenBSD appear to clear it regardless of its state.

With the patch, I didn't notice any regression for OpenBSD under Sun4u
and there were improvements to the Solaris 10 boot under Sun4u.

> Unfortunately 
> this does not change my problems with other BMDMA devices on PPC.

This patch doesn't solve all the problems for Solaris 10. It gets
further in the boot process but it is still unable to mount the file
system. I suspect that there are more bugs in the IDE/CMD646 emulation.
I'm going to continue looking into it. It's still possible we are being
affected by the same bugs. Right now, I'm considering that the
unresponsive serial console under Sun4u on Solaris 10 is due to not
being able to mount the file system and pull the required assets for
the installation menu.

> this change seems to break 
> something else according to a CI test report from patchew.

The test appears to break here in /tests/qtest/ide-test.c for obvious
reasons:
/* Reading the status register clears the IRQ */
g_assert(!qtest_get_irq(qts, IDE_PRIMARY_IRQ));

Should the patch I've suggested be correct, this test would need to be
updated. This is my first patch attempt for QEMU so I'm not sure what
the process is. Should I be submitting a new V2 patch with these
changes? I won't have the opportunity to update the patch for a few
days but will continue watching the thread for reviews.

Thanks,
Jasper Lowell.


On Fri, 2020-02-21 at 16:43 +0100, BALATON Zoltan wrote:
> On Fri, 21 Feb 2020, jasper.lowell@bt.com wrote:
> > The Linux libATA API documentation mentions that on some hardware,
> > reading the status register has the side effect of clearing the
> > interrupt condition. When emulating the generic Sun4u machine
> > running
> > Solaris 10, the Solaris 10 CMD646 driver exits fatally because of
> > this
> > emulated side effect. This side effect is likely to not exist on
> > real
> > CMD646 hardware.
> 
> The chip docs don't mention any side effect, they only say that the
> DMA 
> IRQ and Error bits in the bus master IDE status reg (bits 2 and 1)
> are 
> write 1 to clear so this might be OK but this change seems to break 
> something else according to a CI test report from patchew.
> Unfortunately 
> this does not change my problems with other BMDMA devices on PPC.
> 
> Regards,
> BALATON Zoltan
> 
> > Signed-off-by: Jasper Lowell <jasper.lowell@bt.com>
> > ---
> > hw/ide/core.c | 1 -
> > 1 file changed, 1 deletion(-)
> > 
> > diff --git a/hw/ide/core.c b/hw/ide/core.c
> > index 80000eb766..82fd0632ac 100644
> > --- a/hw/ide/core.c
> > +++ b/hw/ide/core.c
> > @@ -2210,7 +2210,6 @@ uint32_t ide_ioport_read(void *opaque,
> > uint32_t addr)
> >         } else {
> >             ret = s->status;
> >         }
> > -        qemu_irq_lower(bus->irq);
> >         break;
> >     }
> > 
> > 

  reply	other threads:[~2020-02-22  2:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21  6:50 [PATCH] hw/ide: Remove status register read side effect jasper.lowell
2020-02-21  8:08 ` no-reply
2020-02-21 15:43 ` BALATON Zoltan
2020-02-22  2:07   ` jasper.lowell [this message]
2020-02-22 11:47     ` BALATON Zoltan
2020-02-22 17:50     ` BALATON Zoltan
2020-02-22 19:26     ` BALATON Zoltan
2020-02-22 19:32 ` Mark Cave-Ayland
2020-02-22 19:45   ` BALATON Zoltan
2020-02-22 20:05     ` BALATON Zoltan
2020-02-23  7:23       ` jasper.lowell
2020-02-23 15:16         ` BALATON Zoltan
2020-02-25  3:55           ` jasper.lowell
2020-02-25 15:08             ` BALATON Zoltan
2020-02-26  5:22               ` jasper.lowell
2020-02-26 11:07                 ` BALATON Zoltan
2020-02-27  5:10                   ` jasper.lowell
2020-02-27  5:56                     ` jasper.lowell
2020-02-27 11:35                       ` BALATON Zoltan
2020-03-04  0:55                         ` jasper.lowell
2020-02-27 11:38                     ` BALATON Zoltan
2020-03-04  0:58                       ` jasper.lowell
2020-03-01 18:02                 ` BALATON Zoltan
2020-03-04  3:11                   ` jasper.lowell
2020-03-04  8:48                     ` BALATON Zoltan
2020-03-04 21:07                     ` Mark Cave-Ayland
2020-03-05  0:47                       ` jasper.lowell

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=d805ea83320fdb2de626b0657e94a87bc0ea5015.camel@bt.com \
    --to=jasper.lowell@bt.com \
    --cc=balaton@eik.bme.hu \
    --cc=jsnow@redhat.com \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).