All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: qemu-block@nongnu.org, philmd@redhat.com,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	qemu-devel@nongnu.org,
	Aleksandar Markovic <amarkovic@wavecomp.com>,
	John Snow <jsnow@redhat.com>,
	Artyom Tarasenko <atar4qemu@gmail.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v3 3/3] via-ide: Also emulate non 100% native mode
Date: Mon, 9 Mar 2020 23:32:05 -0400	[thread overview]
Message-ID: <20200309232733-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <alpine.BSF.2.22.395.2003092148350.94024@zero.eik.bme.hu>

On Mon, Mar 09, 2020 at 09:50:57PM +0100, BALATON Zoltan wrote:
> On Mon, 9 Mar 2020, Michael S. Tsirkin wrote:
> > On Mon, Mar 09, 2020 at 08:18:13PM +0100, BALATON Zoltan wrote:
> > > Some machines operate in "non 100% native mode" where interrupts are
> > > fixed at legacy IDE interrupts and some guests expect this behaviour
> > > without checking based on knowledge about hardware. Even Linux has
> > > arch specific workarounds for this that are activated on such boards
> > > so this needs to be emulated as well.
> > > 
> > > Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> > > ---
> > > v2: Don't use PCI_INTERRUPT_LINE in via_ide_set_irq()
> > > v3: Patch pci.c instead of local workaround for PCI reset clearing
> > >     PCI_INTERRUPT_PIN config reg
> > > 
> > >  hw/ide/via.c            | 37 +++++++++++++++++++++++++++++--------
> > >  hw/mips/mips_fulong2e.c |  2 +-
> > >  include/hw/ide.h        |  3 ++-
> > >  3 files changed, 32 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/hw/ide/via.c b/hw/ide/via.c
> > > index 096de8dba0..02d29809f2 100644
> > > --- a/hw/ide/via.c
> > > +++ b/hw/ide/via.c
> > > @@ -1,9 +1,10 @@
> > >  /*
> > > - * QEMU IDE Emulation: PCI VIA82C686B support.
> > > + * QEMU VIA southbridge IDE emulation (VT82C686B, VT8231)
> > >   *
> > >   * Copyright (c) 2003 Fabrice Bellard
> > >   * Copyright (c) 2006 Openedhand Ltd.
> > >   * Copyright (c) 2010 Huacai Chen <zltjiangshi@gmail.com>
> > > + * Copyright (c) 2019-2020 BALATON Zoltan
> > >   *
> > >   * Permission is hereby granted, free of charge, to any person obtaining a copy
> > >   * of this software and associated documentation files (the "Software"), to deal
> > > @@ -25,6 +26,8 @@
> > >   */
> > > 
> > >  #include "qemu/osdep.h"
> > > +#include "qemu/range.h"
> > > +#include "hw/qdev-properties.h"
> > >  #include "hw/pci/pci.h"
> > >  #include "migration/vmstate.h"
> > >  #include "qemu/module.h"
> > > @@ -111,11 +114,18 @@ static void via_ide_set_irq(void *opaque, int n, int level)
> > >      } else {
> > >          d->config[0x70 + n * 8] &= ~0x80;
> > >      }
> > > -
> > >      level = (d->config[0x70] & 0x80) || (d->config[0x78] & 0x80);
> > > -    n = pci_get_byte(d->config + PCI_INTERRUPT_LINE);
> > > -    if (n) {
> > > -        qemu_set_irq(isa_get_irq(NULL, n), level);
> > > +
> > > +    /*
> > > +     * Some machines operate in "non 100% native mode" where PCI_INTERRUPT_LINE
> > > +     * is not used but IDE always uses ISA IRQ 14 and 15 even in native mode.
> > > +     * Some guest drivers expect this, often without checking.
> > > +     */
> > > +    if (!(pci_get_byte(d->config + PCI_CLASS_PROG) & (n ? 4 : 1)) ||
> > > +        PCI_IDE(d)->flags & BIT(PCI_IDE_LEGACY_IRQ)) {
> > > +        qemu_set_irq(isa_get_irq(NULL, (n ? 15 : 14)), level);
> > > +    } else {
> > > +        qemu_set_irq(isa_get_irq(NULL, 14), level);
> > >      }
> > >  }
> > > 
> > > @@ -169,7 +179,8 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
> > > 
> > >      pci_config_set_prog_interface(pci_conf, 0x8f); /* native PCI ATA mode */
> > >      pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
> > > -    dev->wmask[PCI_INTERRUPT_LINE] = 0xf;
> > > +    dev->wmask[PCI_CLASS_PROG] = 5;
> > 
> > What's the story here? Why is class suddenly writeable?
> 
> The via-ide (function 1 of some VIA southbridge chips) use bits in this reg
> to set legacy compatibility mode as described in VT82C686B and VT8231
> datasheets and Linux writes this on pegasos2 board I'm emulating. See longer
> description in this message:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2020-03/msg00019.html
> 
> Regards,
> BALATON Zoltan


Pls add a code comment so people don't have to dig through mailing list
archives.

-- 
MST



  parent reply	other threads:[~2020-03-10  3:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 19:18 [PATCH v3 0/3] Implement "non 100% native mode" in via-ide BALATON Zoltan
2020-03-09 19:18 ` [PATCH v3 3/3] via-ide: Also emulate non 100% native mode BALATON Zoltan
2020-03-09 20:36   ` Michael S. Tsirkin
2020-03-09 20:50     ` BALATON Zoltan
2020-03-09 21:06       ` BALATON Zoltan
2020-03-10  3:32       ` Michael S. Tsirkin [this message]
2020-03-09 19:18 ` [PATCH v3 1/3] ide: Make room for flags in PCIIDEState and add one for legacy IRQ routing BALATON Zoltan
2020-03-09 19:18 ` [PATCH v3 2/3] pci: Honour wmask when resetting PCI_INTERRUPT_LINE BALATON Zoltan
2020-03-09 20:39   ` Michael S. Tsirkin
2020-03-09 20:54     ` BALATON Zoltan
2020-03-10  3:36       ` Michael S. Tsirkin
2020-03-10 18:15       ` Mark Cave-Ayland
2020-03-10 18:20         ` BALATON Zoltan
2020-03-09 21:16 ` [PATCH v3 0/3] Implement "non 100% native mode" in via-ide no-reply
2020-03-10 18:31 ` Mark Cave-Ayland
2020-03-10 18:36   ` BALATON Zoltan

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=20200309232733-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=amarkovic@wavecomp.com \
    --cc=atar4qemu@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=jsnow@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.