dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Price <steven.price@arm.com>
To: Rob Herring <robh+dt@kernel.org>,
	Boris Brezillon <boris.brezillon@collabora.com>
Cc: dri-devel <dri-devel@lists.freedesktop.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Subject: Re: [PATCH 3/3] drm/panfrost: Stay in the threaded MMU IRQ handler until we've handled all IRQs
Date: Wed, 3 Feb 2021 15:43:20 +0000	[thread overview]
Message-ID: <170de1a4-94f3-1cb2-cc72-6766509eebcc@arm.com> (raw)
In-Reply-To: <CAL_JsqLGfjbu1AmuqHtSCqFpkWFdZ7qPb4BWAr3d5eHzq55+0g@mail.gmail.com>

On 03/02/2021 14:45, Rob Herring wrote:
> On Mon, Feb 1, 2021 at 2:21 AM Boris Brezillon
> <boris.brezillon@collabora.com> wrote:
>>
>> Doing a hw-irq -> threaded-irq round-trip is counter-productive, stay
>> in the threaded irq handler as long as we can.
>>
>> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
>> ---
>>   drivers/gpu/drm/panfrost/panfrost_mmu.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
>> index 21e552d1ac71..65bc20628c4e 100644
>> --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
>> +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
>> @@ -580,6 +580,8 @@ static irqreturn_t panfrost_mmu_irq_handler_thread(int irq, void *data)
>>          u32 status = mmu_read(pfdev, MMU_INT_RAWSTAT);
>>          int i, ret;
>>
>> +again:
>> +
>>          for (i = 0; status; i++) {
>>                  u32 mask = BIT(i) | BIT(i + 16);
>>                  u64 addr;
>> @@ -628,6 +630,11 @@ static irqreturn_t panfrost_mmu_irq_handler_thread(int irq, void *data)
>>                  status &= ~mask;
>>          }
>>
>> +       /* If we received new MMU interrupts, process them before returning. */
>> +       status = mmu_read(pfdev, MMU_INT_RAWSTAT);
>> +       if (status)
>> +               goto again;
>> +
> 
> Can't we avoid the goto? Change the for loop like this:
> 
> i = 0;
> while (status = mmu_read(pfdev, MMU_INT_RAWSTAT)) {
>      ...
> 
>      i++;
>      if (i == 16)
>          i = 0;
> }

Well that reads from the RAWSTAT register excessively (which could be 
expensive at low GPU clock speeds), but we could do:

for(i = 0; status; i++) {
	...

	if (!status) {
		i = 0;
		status = mmu_read(pfdev, MMU_INT_RAWSTAT);
	}
}

(or similar with a while() if you prefer). Of course we could even get 
rid of the 'i' loop altogether:

status = mmu_read(pfdev, MMU_INT_RAWSTAT);
while (status) {
	int i = ffs(status | (status >> 16)) - 1;

	... existing code ...

	status &= ~mask;
	if (!status)
		status = mmu_read(pfdev, MMU_INT_RAWSTAT);
}

Steve

>>          mmu_write(pfdev, MMU_INT_MASK, ~0);
>>          return IRQ_HANDLED;
>>   };
>> --
>> 2.26.2
>>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2021-02-03 15:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01  8:21 [PATCH 0/3] drm/panfrost: MMU fixes Boris Brezillon
2021-02-01  8:21 ` [PATCH 1/3] drm/panfrost: Clear MMU irqs before handling the fault Boris Brezillon
2021-02-01 12:13   ` Steven Price
2021-02-01  8:21 ` [PATCH 2/3] drm/panfrost: Don't try to map pages that are already mapped Boris Brezillon
2021-02-01 12:13   ` Steven Price
2021-02-01  8:21 ` [PATCH 3/3] drm/panfrost: Stay in the threaded MMU IRQ handler until we've handled all IRQs Boris Brezillon
2021-02-01 12:13   ` Steven Price
2021-02-01 12:59     ` Boris Brezillon
2021-02-01 13:24       ` Steven Price
2021-02-01 13:47         ` Boris Brezillon
2021-02-03 14:45   ` Rob Herring
2021-02-03 15:43     ` Steven Price [this message]

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=170de1a4-94f3-1cb2-cc72-6766509eebcc@arm.com \
    --to=steven.price@arm.com \
    --cc=alyssa.rosenzweig@collabora.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robh+dt@kernel.org \
    --cc=robin.murphy@arm.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