All of lore.kernel.org
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-block@nongnu.org, philmd@redhat.com, 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 2/2] via-ide: Also emulate non 100% native mode
Date: Sun, 1 Mar 2020 17:42:51 +0100 (CET)	[thread overview]
Message-ID: <alpine.BSF.2.22.395.2003011731130.95594@zero.eik.bme.hu> (raw)
In-Reply-To: <bdbef976-a853-7178-8163-579e4bf9e2e0@ilande.co.uk>

On Sun, 1 Mar 2020, Mark Cave-Ayland wrote:
> On 01/03/2020 11:35, Mark Cave-Ayland wrote:
>> On 29/02/2020 23:02, 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>
>>> ---
>>>  hw/ide/via.c            | 60 +++++++++++++++++++++++++++++++++++------
>>>  hw/mips/mips_fulong2e.c |  2 +-
>>>  include/hw/ide.h        |  3 ++-
>>>  3 files changed, 55 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/hw/ide/via.c b/hw/ide/via.c
>>> index 096de8dba0..17418c5822 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,14 +114,43 @@ 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 {
>>> +        n = pci_get_byte(d->config + PCI_INTERRUPT_LINE);
>>> +        if (n) {
>>> +            qemu_set_irq(isa_get_irq(NULL, n), level);
>>> +        }
>>>      }
>>>  }
>
> The other part I'm not sure about is that I can't see how via_ide_set_irq() can ever
> raise a native PCI IRQ - comparing with my experience on cmd646, should there not be
> a pci_set_irq(d, level) at the end?

According to my tests with several guests it seems the via-ide does not 
seem to use PCI interrupts as described in the previous reply, only either 
legacy IRQ14 and 15 or one ISA IRQ line set by a config reg in native mode 
(except on Pegasos2). This may be due to how it's internally connected in 
the southbridge chip it's part of or some other platform specific quirk, 
I'm not sure.

The CMD646 may be a more conformant PCI device and use PCI interrupts 
(unless that also has some kind of legacy mode and similar interconnection 
with ISA interrupts). If it's really using PCI interrupt and Solaris still 
does not get expexted IRQ then maybe the routing is not matching real 
hardware somehow? Maybe it would help finding out what interrupt the 
Solaris driver is checking to find out why it misses the IRQ.

Regards,
BALATON Zoltan


  reply	other threads:[~2020-03-01 16:43 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-29 23:02 [PATCH 0/2] Implement "non 100% native mode" in via-ide BALATON Zoltan
2020-02-29 23:02 ` [PATCH 1/2] ide: Make room for flags in PCIIDEState and add one for legacy IRQ routing BALATON Zoltan
2020-03-01 11:32   ` Mark Cave-Ayland
2020-03-01 15:27     ` BALATON Zoltan
2020-03-02  8:10       ` Markus Armbruster
2020-03-02 19:13         ` Mark Cave-Ayland
2020-03-02 23:26           ` BALATON Zoltan
2020-02-29 23:02 ` [PATCH 2/2] via-ide: Also emulate non 100% native mode BALATON Zoltan
2020-03-01 11:35   ` Mark Cave-Ayland
2020-03-01 11:41     ` Mark Cave-Ayland
2020-03-01 16:42       ` BALATON Zoltan [this message]
2020-03-01 17:54         ` Mark Cave-Ayland
2020-03-01 18:32           ` BALATON Zoltan
2020-03-01 18:53             ` BALATON Zoltan
2020-03-01 19:40               ` Mark Cave-Ayland
2020-03-01 21:30                 ` BALATON Zoltan
2020-03-02 19:00                   ` Mark Cave-Ayland
2020-03-02 21:40                     ` BALATON Zoltan
2020-03-03 20:40                       ` Mark Cave-Ayland
2020-03-04  0:22                         ` BALATON Zoltan
2020-03-04 21:04                           ` Mark Cave-Ayland
2020-03-04 22:33                             ` BALATON Zoltan
2020-03-05 18:40                               ` Mark Cave-Ayland
2020-03-05 23:35                                 ` BALATON Zoltan
2020-03-06  0:21                                   ` BALATON Zoltan
2020-03-06  7:25                                     ` Mark Cave-Ayland
2020-03-06 12:40                                       ` BALATON Zoltan
2020-03-06 18:44                                         ` Mark Cave-Ayland
2020-03-06  7:03                                   ` Mark Cave-Ayland
2020-03-06 12:06                                     ` BALATON Zoltan
2020-03-06 18:42                                       ` Mark Cave-Ayland
2020-03-06 19:38                                         ` BALATON Zoltan
2020-03-06 20:36                                           ` Mark Cave-Ayland
2020-03-06 22:59                                             ` BALATON Zoltan
2020-03-07 11:09                                               ` Mark Cave-Ayland
2020-03-07 15:56                                                 ` BALATON Zoltan
2020-03-06 12:36           ` Artyom Tarasenko
2020-03-01 16:31     ` 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=alpine.BSF.2.22.395.2003011731130.95594@zero.eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=amarkovic@wavecomp.com \
    --cc=atar4qemu@gmail.com \
    --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.