All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@linux.dev>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Michal Simek <michal.simek@amd.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Vinod Koul <vkoul@kernel.org>,
	dmaengine@vger.kernel.org
Subject: Re: [PATCH 2/3] dma: xilinx_dpdma: Remove unnecessary use of irqsave/restore
Date: Thu, 28 Mar 2024 11:00:24 -0400	[thread overview]
Message-ID: <d6a8c1c8-258a-447b-b6cd-199f33199388@linux.dev> (raw)
In-Reply-To: <0652c82f-b0a2-4881-ac51-38399b180ad4@ideasonboard.com>

On 3/27/24 08:27, Tomi Valkeinen wrote:
> Hi,
> 
> On 08/03/2024 23:00, Sean Anderson wrote:
>> xilinx_dpdma_chan_done_irq and xilinx_dpdma_chan_vsync_irq are always
>> called with IRQs disabled from xilinx_dpdma_irq_handler. Therefore we
>> don't need to save/restore the IRQ flags.
> 
> I think this is fine, but a few thoughts:
> 
> - Is spin_lock clearly faster than the irqsave variant, or is this a pointless optimization? It's safer to just use irqsave variant, instead of making sure the code is always called from the expected contexts.

It's not an optimization. Technically this will save a few instructions,
but...

> - Is this style documented/recommended anywhere? Going through docs, I only found docs telling to use irqsave when mixing irq and non-irq contexts.

The purpose is mainly to make it clear that this is meant to be called
in IRQ context. With irqsave, there's an implication that this could be
called in non-IRQ context, which it never is.

> - Does this cause issues on PREEMPT_RT?

Why would it?

--Sean

> 
>  Tomi
> 
>> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
>> ---
>>
>>   drivers/dma/xilinx/xilinx_dpdma.c | 10 ++++------
>>   1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
>> index eb0637d90342..36bd4825d389 100644
>> --- a/drivers/dma/xilinx/xilinx_dpdma.c
>> +++ b/drivers/dma/xilinx/xilinx_dpdma.c
>> @@ -1043,9 +1043,8 @@ static int xilinx_dpdma_chan_stop(struct xilinx_dpdma_chan *chan)
>>   static void xilinx_dpdma_chan_done_irq(struct xilinx_dpdma_chan *chan)
>>   {
>>       struct xilinx_dpdma_tx_desc *active;
>> -    unsigned long flags;
>>   -    spin_lock_irqsave(&chan->lock, flags);
>> +    spin_lock(&chan->lock);
>>         xilinx_dpdma_debugfs_desc_done_irq(chan);
>>   @@ -1057,7 +1056,7 @@ static void xilinx_dpdma_chan_done_irq(struct xilinx_dpdma_chan *chan)
>>                "chan%u: DONE IRQ with no active descriptor!\n",
>>                chan->id);
>>   -    spin_unlock_irqrestore(&chan->lock, flags);
>> +    spin_unlock(&chan->lock);
>>   }
>>     /**
>> @@ -1072,10 +1071,9 @@ static void xilinx_dpdma_chan_vsync_irq(struct  xilinx_dpdma_chan *chan)
>>   {
>>       struct xilinx_dpdma_tx_desc *pending;
>>       struct xilinx_dpdma_sw_desc *sw_desc;
>> -    unsigned long flags;
>>       u32 desc_id;
>>   -    spin_lock_irqsave(&chan->lock, flags);
>> +    spin_lock(&chan->lock);
>>         pending = chan->desc.pending;
>>       if (!chan->running || !pending)
>> @@ -1108,7 +1106,7 @@ static void xilinx_dpdma_chan_vsync_irq(struct  xilinx_dpdma_chan *chan)
>>       spin_unlock(&chan->vchan.lock);
>>     out:
>> -    spin_unlock_irqrestore(&chan->lock, flags);
>> +    spin_unlock(&chan->lock);
>>   }
>>     /**
> 

WARNING: multiple messages have this Message-ID (diff)
From: Sean Anderson <sean.anderson@linux.dev>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Michal Simek <michal.simek@amd.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Vinod Koul <vkoul@kernel.org>,
	dmaengine@vger.kernel.org
Subject: Re: [PATCH 2/3] dma: xilinx_dpdma: Remove unnecessary use of irqsave/restore
Date: Thu, 28 Mar 2024 11:00:24 -0400	[thread overview]
Message-ID: <d6a8c1c8-258a-447b-b6cd-199f33199388@linux.dev> (raw)
In-Reply-To: <0652c82f-b0a2-4881-ac51-38399b180ad4@ideasonboard.com>

On 3/27/24 08:27, Tomi Valkeinen wrote:
> Hi,
> 
> On 08/03/2024 23:00, Sean Anderson wrote:
>> xilinx_dpdma_chan_done_irq and xilinx_dpdma_chan_vsync_irq are always
>> called with IRQs disabled from xilinx_dpdma_irq_handler. Therefore we
>> don't need to save/restore the IRQ flags.
> 
> I think this is fine, but a few thoughts:
> 
> - Is spin_lock clearly faster than the irqsave variant, or is this a pointless optimization? It's safer to just use irqsave variant, instead of making sure the code is always called from the expected contexts.

It's not an optimization. Technically this will save a few instructions,
but...

> - Is this style documented/recommended anywhere? Going through docs, I only found docs telling to use irqsave when mixing irq and non-irq contexts.

The purpose is mainly to make it clear that this is meant to be called
in IRQ context. With irqsave, there's an implication that this could be
called in non-IRQ context, which it never is.

> - Does this cause issues on PREEMPT_RT?

Why would it?

--Sean

> 
>  Tomi
> 
>> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
>> ---
>>
>>   drivers/dma/xilinx/xilinx_dpdma.c | 10 ++++------
>>   1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
>> index eb0637d90342..36bd4825d389 100644
>> --- a/drivers/dma/xilinx/xilinx_dpdma.c
>> +++ b/drivers/dma/xilinx/xilinx_dpdma.c
>> @@ -1043,9 +1043,8 @@ static int xilinx_dpdma_chan_stop(struct xilinx_dpdma_chan *chan)
>>   static void xilinx_dpdma_chan_done_irq(struct xilinx_dpdma_chan *chan)
>>   {
>>       struct xilinx_dpdma_tx_desc *active;
>> -    unsigned long flags;
>>   -    spin_lock_irqsave(&chan->lock, flags);
>> +    spin_lock(&chan->lock);
>>         xilinx_dpdma_debugfs_desc_done_irq(chan);
>>   @@ -1057,7 +1056,7 @@ static void xilinx_dpdma_chan_done_irq(struct xilinx_dpdma_chan *chan)
>>                "chan%u: DONE IRQ with no active descriptor!\n",
>>                chan->id);
>>   -    spin_unlock_irqrestore(&chan->lock, flags);
>> +    spin_unlock(&chan->lock);
>>   }
>>     /**
>> @@ -1072,10 +1071,9 @@ static void xilinx_dpdma_chan_vsync_irq(struct  xilinx_dpdma_chan *chan)
>>   {
>>       struct xilinx_dpdma_tx_desc *pending;
>>       struct xilinx_dpdma_sw_desc *sw_desc;
>> -    unsigned long flags;
>>       u32 desc_id;
>>   -    spin_lock_irqsave(&chan->lock, flags);
>> +    spin_lock(&chan->lock);
>>         pending = chan->desc.pending;
>>       if (!chan->running || !pending)
>> @@ -1108,7 +1106,7 @@ static void xilinx_dpdma_chan_vsync_irq(struct  xilinx_dpdma_chan *chan)
>>       spin_unlock(&chan->vchan.lock);
>>     out:
>> -    spin_unlock_irqrestore(&chan->lock, flags);
>> +    spin_unlock(&chan->lock);
>>   }
>>     /**
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-03-28 15:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08 21:00 [PATCH 0/3] dma: xilinx_dpdma: Fix locking Sean Anderson
2024-03-08 21:00 ` Sean Anderson
2024-03-08 21:00 ` [PATCH 1/3] " Sean Anderson
2024-03-08 21:00   ` Sean Anderson
2024-03-27 11:57   ` Tomi Valkeinen
2024-03-27 11:57     ` Tomi Valkeinen
2024-03-08 21:00 ` [PATCH 2/3] dma: xilinx_dpdma: Remove unnecessary use of irqsave/restore Sean Anderson
2024-03-08 21:00   ` Sean Anderson
2024-03-27 12:27   ` Tomi Valkeinen
2024-03-27 12:27     ` Tomi Valkeinen
2024-03-28 15:00     ` Sean Anderson [this message]
2024-03-28 15:00       ` Sean Anderson
2024-03-28 16:37       ` Tomi Valkeinen
2024-03-28 16:37         ` Tomi Valkeinen
2024-03-08 21:00 ` [PATCH 3/3] dma: Add lockdep asserts to virt-dma Sean Anderson
2024-03-08 21:00   ` Sean Anderson
2024-03-27 12:29   ` Tomi Valkeinen
2024-03-27 12:29     ` Tomi Valkeinen
2024-04-07 16:38 ` [PATCH 0/3] dma: xilinx_dpdma: Fix locking Vinod Koul
2024-04-07 16:38   ` Vinod Koul

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=d6a8c1c8-258a-447b-b6cd-199f33199388@linux.dev \
    --to=sean.anderson@linux.dev \
    --cc=dmaengine@vger.kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=vkoul@kernel.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 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.