From: Pierre Yves MORDRET <pierre-yves.mordret@foss.st.com>
To: Alain Volmat <alain.volmat@foss.st.com>, <wsa@kernel.org>
Cc: <alexandre.torgue@foss.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>, <fabrice.gasnier@foss.st.com>,
<amelie.delaunay@foss.st.com>
Subject: Re: [PATCH 3/4] i2c: stm32f7: stop dma transfer in case of NACK
Date: Thu, 23 Sep 2021 10:37:45 +0200 [thread overview]
Message-ID: <e1e58f07-144e-e1fa-79a0-f3396be15305@foss.st.com> (raw)
In-Reply-To: <1632151292-18503-4-git-send-email-alain.volmat@foss.st.com>
Hi Alain
Look good to me
Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
Regards
On 9/20/21 5:21 PM, Alain Volmat wrote:
> In case of receiving a NACK, the dma transfer should be stopped
> to avoid feeding data into the FIFO.
> Also ensure to properly return the proper error code and avoid
> waiting for the end of the dma completion in case of
> error happening during the transmission.
>
> Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support")
>
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
> drivers/i2c/busses/i2c-stm32f7.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index ad3459a3bc5e..50d5ae81d227 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -1493,6 +1493,7 @@ static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
> {
> struct stm32f7_i2c_dev *i2c_dev = data;
> struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
> + struct stm32_i2c_dma *dma = i2c_dev->dma;
> void __iomem *base = i2c_dev->base;
> u32 status, mask;
> int ret = IRQ_HANDLED;
> @@ -1518,6 +1519,10 @@ static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
> dev_dbg(i2c_dev->dev, "<%s>: Receive NACK (addr %x)\n",
> __func__, f7_msg->addr);
> writel_relaxed(STM32F7_I2C_ICR_NACKCF, base + STM32F7_I2C_ICR);
> + if (i2c_dev->use_dma) {
> + stm32f7_i2c_disable_dma_req(i2c_dev);
> + dmaengine_terminate_all(dma->chan_using);
> + }
> f7_msg->result = -ENXIO;
> }
>
> @@ -1533,7 +1538,7 @@ static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
> /* Clear STOP flag */
> writel_relaxed(STM32F7_I2C_ICR_STOPCF, base + STM32F7_I2C_ICR);
>
> - if (i2c_dev->use_dma) {
> + if (i2c_dev->use_dma && !f7_msg->result) {
> ret = IRQ_WAKE_THREAD;
> } else {
> i2c_dev->master_mode = false;
> @@ -1546,7 +1551,7 @@ static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
> if (f7_msg->stop) {
> mask = STM32F7_I2C_CR2_STOP;
> stm32f7_i2c_set_bits(base + STM32F7_I2C_CR2, mask);
> - } else if (i2c_dev->use_dma) {
> + } else if (i2c_dev->use_dma && !f7_msg->result) {
> ret = IRQ_WAKE_THREAD;
> } else if (f7_msg->smbus) {
> stm32f7_i2c_smbus_rep_start(i2c_dev);
>
--
--
~ Py MORDRET
--
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-09-23 8:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 15:21 [PATCH 0/4] i2c: stm32: various fixes & dmaengine updates Alain Volmat
2021-09-20 15:21 ` [PATCH 1/4] i2c: stm32f7: flush TX FIFO upon transfer errors Alain Volmat
2021-09-23 8:35 ` Pierre Yves MORDRET
2021-11-29 12:12 ` Wolfram Sang
2021-09-20 15:21 ` [PATCH 2/4] i2c: stm32f7: recover the bus on access timeout Alain Volmat
2021-09-23 8:37 ` Pierre Yves MORDRET
2021-11-29 12:17 ` Wolfram Sang
2021-11-29 12:33 ` Alain Volmat
2021-11-29 12:52 ` Wolfram Sang
2021-11-30 8:56 ` Alain Volmat
2021-11-30 9:27 ` Wolfram Sang
2021-11-30 9:27 ` Wolfram Sang
2021-09-20 15:21 ` [PATCH 3/4] i2c: stm32f7: stop dma transfer in case of NACK Alain Volmat
2021-09-23 8:37 ` Pierre Yves MORDRET [this message]
2021-11-30 9:27 ` Wolfram Sang
2021-09-20 15:21 ` [PATCH 4/4] i2c: stm32f7: use proper DMAENGINE API for termination Alain Volmat
2021-09-23 8:38 ` Pierre Yves MORDRET
2021-11-30 9:28 ` Wolfram Sang
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=e1e58f07-144e-e1fa-79a0-f3396be15305@foss.st.com \
--to=pierre-yves.mordret@foss.st.com \
--cc=alain.volmat@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=amelie.delaunay@foss.st.com \
--cc=fabrice.gasnier@foss.st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--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).