qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Bernhard Beschow <shentey@gmail.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>,
	qemu-block@nongnu.org, Beniamino Galvani <b.galvani@gmail.com>,
	Strahinja Jankovic <strahinja.p.jankovic@gmail.com>,
	Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH] hw/ide/ahci: Check for PCI device once in ahci_init()
Date: Tue, 3 Dec 2024 10:12:08 +0100	[thread overview]
Message-ID: <79005a21-00f9-4642-b93e-2ca9cde821ba@linaro.org> (raw)
In-Reply-To: <D1B09E85-E00F-4E8F-8332-51CB33A97E44@gmail.com>

On 3/12/24 07:46, Bernhard Beschow wrote:
> Am 21. November 2024 10:01:52 UTC schrieb "Philippe Mathieu-Daudé" <philmd@linaro.org>:
>> object_dynamic_cast() is expensive; IRQ helpers are certainly
>> a bad place to call it. Since the device type won't change at
>> runtime, resolve it once when the AHCI context is initialized
>> in ahci_init().
>>
>> Reported-by: Peter Xu <peterx@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> include/hw/ide/ahci.h |  2 +-
>> hw/ide/ahci.c         | 17 +++++------------
>> 2 files changed, 6 insertions(+), 13 deletions(-)


>> @@ -196,13 +192,9 @@ static void ahci_irq_raise(AHCIState *s)
>>
>> static void ahci_irq_lower(AHCIState *s)
>> {
>> -    DeviceState *dev_state = s->container;
>> -    PCIDevice *pci_dev = (PCIDevice *) object_dynamic_cast(OBJECT(dev_state),
>> -                                                           TYPE_PCI_DEVICE);
>> -
>>      trace_ahci_irq_lower(s);
>>
>> -    if (!pci_dev || !msi_enabled(pci_dev)) {
>> +    if (!s->pci_dev || !msi_enabled(s->pci_dev)) {
>>          qemu_irq_lower(s->irq);
>>      }
>> }
> 
> By always triggering the "irq" property, it might be possible to push out the above two methods to the caller, i.e. the parent PCI device. This would make this device model independent from PCI, essentially turning it into an "IP block". At the same time this eliminates the need for the dynamic casts and AFAICS would also fix the missing PCI dependency in the Kconfig file. I could send a patch.

Oh. Please go ahead, that is appreciated!

> 
> Best regards,
> Bernhard


  reply	other threads:[~2024-12-03  9:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21 10:01 [PATCH] hw/ide/ahci: Check for PCI device once in ahci_init() Philippe Mathieu-Daudé
2024-12-03  6:46 ` Bernhard Beschow
2024-12-03  9:12   ` Philippe Mathieu-Daudé [this message]
2024-12-05 11:49     ` Bernhard Beschow

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=79005a21-00f9-4642-b93e-2ca9cde821ba@linaro.org \
    --to=philmd@linaro.org \
    --cc=b.galvani@gmail.com \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shentey@gmail.com \
    --cc=strahinja.p.jankovic@gmail.com \
    /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).