qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 7/9] AHCI: Rework IRQ constants
Date: Mon, 28 Aug 2017 20:28:03 -0400	[thread overview]
Message-ID: <73d55141-94d0-bc96-b101-5562caa16e50@redhat.com> (raw)
In-Reply-To: <bd435a55-7aea-2652-f67a-32e669bbfc30@amsat.org>



On 08/25/2017 10:00 AM, Philippe Mathieu-Daudé wrote:
> Hi John,
> 
> On 08/08/2017 03:33 PM, John Snow wrote:
>> Create a new enum so that we can name the IRQ bits, which will make
>> debugging
>> them a little nicer if we can print them out. Not handled in this
>> patch, but
>> this will make it possible to get a nice debug printf detailing
>> exactly which
>> status bits are set, as it can be multiple at any given time.
>>
>> As a consequence of this patch, it is no longer possible to set
>> multiple IRQ
>> codes at once, but nothing was utilizing this ability anyway.
>>
>> Signed-off-by: John Snow <jsnow@redhat.com>
>> ---
>>   hw/ide/ahci.c          | 49
>> ++++++++++++++++++++++++++++++++++++++-----------
>>   hw/ide/ahci_internal.h | 44
>> +++++++++++++++++++++++++++++++++++---------
>>   hw/ide/trace-events    |  2 +-
>>   3 files changed, 74 insertions(+), 21 deletions(-)
>>
>> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
>> index d5acceb..c5a9b69 100644
>> --- a/hw/ide/ahci.c
>> +++ b/hw/ide/ahci.c
>> @@ -56,6 +56,27 @@ static bool ahci_map_fis_address(AHCIDevice *ad);
>>   static void ahci_unmap_clb_address(AHCIDevice *ad);
>>   static void ahci_unmap_fis_address(AHCIDevice *ad);
>>   +static const char *AHCIPortIRQ_lookup[AHCI_PORT_IRQ__END] = {
>> +    [AHCI_PORT_IRQ_BIT_DHRS] = "DHRS",
>> +    [AHCI_PORT_IRQ_BIT_PSS]  = "PSS",
>> +    [AHCI_PORT_IRQ_BIT_DSS]  = "DSS",
>> +    [AHCI_PORT_IRQ_BIT_SDBS] = "SDBS",
>> +    [AHCI_PORT_IRQ_BIT_UFS]  = "UFS",
>> +    [AHCI_PORT_IRQ_BIT_DPS]  = "DPS",
>> +    [AHCI_PORT_IRQ_BIT_PCS]  = "PCS",
>> +    [AHCI_PORT_IRQ_BIT_DMPS] = "DMPS",
>> +    [8 ... 21]               = "RESERVED",
>> +    [AHCI_PORT_IRQ_BIT_PRCS] = "PRCS",
>> +    [AHCI_PORT_IRQ_BIT_IPMS] = "IPMS",
>> +    [AHCI_PORT_IRQ_BIT_OFS]  = "OFS",
>> +    [25]                     = "RESERVED",
>> +    [AHCI_PORT_IRQ_BIT_INFS] = "INFS",
>> +    [AHCI_PORT_IRQ_BIT_IFS]  = "IFS",
>> +    [AHCI_PORT_IRQ_BIT_HBDS] = "HBDS",
>> +    [AHCI_PORT_IRQ_BIT_HBFS] = "HBFS",
>> +    [AHCI_PORT_IRQ_BIT_TFES] = "TFES",
>> +    [AHCI_PORT_IRQ_BIT_CPDS] = "CPDS"
>> +};
>>     static uint32_t  ahci_port_read(AHCIState *s, int port, int offset)
>>   {
>> @@ -170,12 +191,18 @@ static void ahci_check_irq(AHCIState *s)
>>   }
>>     static void ahci_trigger_irq(AHCIState *s, AHCIDevice *d,
>> -                             int irq_type)
>> +                             enum AHCIPortIRQ irqbit)
>>   {
>> -    DPRINTF(d->port_no, "trigger irq %#x -> %x\n",
>> -            irq_type, d->port_regs.irq_mask & irq_type);
>> +    g_assert(irqbit >= 0 && irqbit < 32);
> 
> Since you now use an enum this check is no more necessary.
> 

You can actually still pass in a wrong value if you wanted to. This is
to prevent old-style IRQ masks from getting passed in by accident.

> However ...
> 
>> +    uint32_t irq = 1U << irqbit;
>> +    uint32_t irqstat = d->port_regs.irq_stat | irq;
>>   -    d->port_regs.irq_stat |= irq_type;
>> +    trace_ahci_trigger_irq(s, d->port_no,
>> +                           AHCIPortIRQ_lookup[irqbit], irq,
>> +                           d->port_regs.irq_stat, irqstat,
>> +                           irqstat & d->port_regs.irq_mask);
>> +
> 
> Why not keep using masked irqs, and iterate over AHCI_PORT_IRQ__END
> bits? Something like:
> 
>     if (TRACE_AHCI_IRQ_ENABLED) {
>         int irqbit;
>         for (irqbit = 0; irqbit < AHCI_PORT_IRQ__END; irqbit++) {
>             if (irqmask & BIT(irqbit)) {
>                 trace_ahci_trigger_irq(s, d->port_no, ...
> 

Would rather not iterate like that for the IRQ path. Generally no place
in the codebase needs to raise more than one IRQ type at a time, so why
bother allowing it?

  reply	other threads:[~2017-08-29  0:28 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-08 18:32 [Qemu-devel] [PATCH 0/9] IDE: replace printfs with tracing John Snow
2017-08-08 18:32 ` [Qemu-devel] [PATCH 1/9] IDE: replace DEBUG_IDE with tracing system John Snow
2017-08-08 20:00   ` Eric Blake
2017-08-08 20:12     ` John Snow
2017-08-08 23:20     ` Philippe Mathieu-Daudé
2017-08-22 19:03     ` John Snow
2017-08-25 13:33   ` Philippe Mathieu-Daudé
2017-08-28 23:34     ` John Snow
2017-08-08 18:32 ` [Qemu-devel] [PATCH 2/9] IDE: Add register hints to tracing John Snow
2017-08-08 20:05   ` Eric Blake
2017-08-25 13:43   ` Philippe Mathieu-Daudé
2017-08-08 18:33 ` [Qemu-devel] [PATCH 3/9] IDE: add tracing for data ports John Snow
2017-08-08 20:10   ` Eric Blake
2017-08-08 20:17     ` John Snow
2017-08-08 20:30   ` Eric Blake
2017-08-08 20:36     ` Eric Blake
2017-08-08 20:44     ` John Snow
2017-08-08 18:33 ` [Qemu-devel] [PATCH 4/9] ATAPI: Replace DEBUG_IDE_ATAPI with tracing events John Snow
2017-08-08 20:59   ` Eric Blake
2017-08-28 23:43     ` John Snow
2017-08-08 18:33 ` [Qemu-devel] [PATCH 5/9] IDE: replace DEBUG_AIO with trace events John Snow
2017-08-25 13:46   ` Philippe Mathieu-Daudé
2017-08-29  0:26     ` John Snow
2017-08-08 18:33 ` [Qemu-devel] [PATCH 6/9] AHCI: Replace DPRINTF with trace-events John Snow
2017-08-25 13:17   ` Philippe Mathieu-Daudé
2017-08-29  0:15     ` John Snow
2017-08-30  3:51       ` Philippe Mathieu-Daudé
2017-08-08 18:33 ` [Qemu-devel] [PATCH 7/9] AHCI: Rework IRQ constants John Snow
2017-08-25 14:00   ` Philippe Mathieu-Daudé
2017-08-29  0:28     ` John Snow [this message]
2017-08-30  3:24       ` Philippe Mathieu-Daudé
2017-08-08 18:33 ` [Qemu-devel] [PATCH 8/9] AHCI: pretty-print FIS to buffer instead of stderr John Snow
2017-08-08 18:33 ` [Qemu-devel] [PATCH 9/9] AHCI: remove DPRINTF macro John Snow
2017-08-25 13:48   ` Philippe Mathieu-Daudé
2017-08-29  0:33     ` John Snow
2017-08-09  1:17 ` [Qemu-devel] [PATCH 0/9] IDE: replace printfs with tracing no-reply

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=73d55141-94d0-bc96-b101-5562caa16e50@redhat.com \
    --to=jsnow@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=qemu-block@nongnu.org \
    --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).