linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Clement LE GOFFIC <clement.legoffic@foss.st.com>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: "Pierre-Yves MORDRET" <pierre-yves.mordret@foss.st.com>,
	"Alain Volmat" <alain.volmat@foss.st.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"M'boumba Cedric Madianga" <cedric.madianga@gmail.com>,
	"Wolfram Sang" <wsa@kernel.org>,
	"Pierre-Yves MORDRET" <pierre-yves.mordret@st.com>,
	linux-i2c@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH v3 2/3] i2c: stm32f7: unmap DMA mapped buffer
Date: Thu, 3 Jul 2025 11:19:05 +0200	[thread overview]
Message-ID: <01d03052-4d9b-4d71-9781-a050ee669d45@foss.st.com> (raw)
In-Reply-To: <zp3pagbojmu67o4sjm65a44ovvui5uvybs32nayvhtewfbm4el@n5lro4v5iq36>

Hi Andi,

On 7/2/25 19:08, Andi Shyti wrote:
> Hi Clement,
> 
> On Mon, Jun 30, 2025 at 02:55:14PM +0200, Clément Le Goffic wrote:
>> Fix an issue where the mapped DMA buffer was not unmapped.
> 
> "Fix an issue..." is too generic. Can you be more specific? Where
> was it mapped? Where was it left unmapped?
> 
> Please, do consider that the user needs to understand what
> happens in the patch without needing to look into the patch.

Ok sure I'll refine the commit message.

> 
>> Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support")
>> Acked-by: Alain Volmat <alain.volmat@foss.st.com>
>> Signed-off-by: Clément Le Goffic <clement.legoffic@foss.st.com>
>> ---
>>   drivers/i2c/busses/i2c-stm32f7.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
>> index e4aaeb2262d0..042386b4cabe 100644
>> --- a/drivers/i2c/busses/i2c-stm32f7.c
>> +++ b/drivers/i2c/busses/i2c-stm32f7.c
>> @@ -1554,6 +1554,8 @@ static irqreturn_t stm32f7_i2c_handle_isr_errs(struct stm32f7_i2c_dev *i2c_dev,
>>   	if (i2c_dev->use_dma) {
>>   		stm32f7_i2c_disable_dma_req(i2c_dev);
>>   		dmaengine_terminate_async(dma->chan_using);
>> +		dma_unmap_single(i2c_dev->dev, dma->dma_buf, dma->dma_len,
>> +				 dma->dma_data_dir);
>>   	}
>>   
>>   	i2c_dev->master_mode = false;
>> @@ -1622,6 +1624,8 @@ static irqreturn_t stm32f7_i2c_isr_event_thread(int irq, void *data)
>>   		if (i2c_dev->use_dma) {
>>   			stm32f7_i2c_disable_dma_req(i2c_dev);
>>   			dmaengine_terminate_async(dma->chan_using);
>> +			dma_unmap_single(i2c_dev->dev, dma->dma_buf, dma->dma_len,
>> +					 dma->dma_data_dir);
>>   		}
>>   		f7_msg->result = -ENXIO;
>>   	}
>> @@ -1642,6 +1646,8 @@ static irqreturn_t stm32f7_i2c_isr_event_thread(int irq, void *data)
>>   				dev_dbg(i2c_dev->dev, "<%s>: Timed out\n", __func__);
>>   				stm32f7_i2c_disable_dma_req(i2c_dev);
>>   				dmaengine_terminate_async(dma->chan_using);
>> +				dma_unmap_single(i2c_dev->dev, dma->dma_buf, dma->dma_len,
>> +						 dma->dma_data_dir);
> 
> Can't we use the dma_callback here, or similar? I see some
> similar patterns and I think the code can be improved.

Yes, it seems the code can be factorized.
I'll submit a new version with the factorization.

Best regards,
Clément



  reply	other threads:[~2025-07-03  9:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30 12:55 [PATCH v3 0/3] Fix STM32 I2C dma operations Clément Le Goffic
2025-06-30 12:55 ` [PATCH v3 1/3] i2c: stm32: fix the device used for the DMA map Clément Le Goffic
2025-06-30 13:05   ` Pierre Yves MORDRET
2025-07-02 16:57   ` Andi Shyti
2025-07-03  7:20     ` Clement LE GOFFIC
2025-06-30 12:55 ` [PATCH v3 2/3] i2c: stm32f7: unmap DMA mapped buffer Clément Le Goffic
2025-06-30 13:06   ` Pierre Yves MORDRET
2025-07-02 17:08   ` Andi Shyti
2025-07-03  9:19     ` Clement LE GOFFIC [this message]
2025-06-30 12:55 ` [PATCH v3 3/3] i2c: stm32f7: support i2c_*_dma_safe_msg_buf APIs Clément Le Goffic
2025-06-30 13:07   ` Pierre Yves MORDRET
2025-07-02 17:15   ` Andi Shyti
2025-07-03  9:21     ` Clement LE GOFFIC

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=01d03052-4d9b-4d71-9781-a050ee669d45@foss.st.com \
    --to=clement.legoffic@foss.st.com \
    --cc=alain.volmat@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andi.shyti@kernel.org \
    --cc=cedric.madianga@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=pierre-yves.mordret@foss.st.com \
    --cc=pierre-yves.mordret@st.com \
    --cc=sumit.semwal@linaro.org \
    --cc=wsa@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 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).