public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Nyekjaer <sean@geanix.com>
To: Alain Volmat <alain.volmat@foss.st.com>
Cc: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <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
Subject: Re: [PATCH v2] i2c: stm32f7: Add atomic_xfer method to driver
Date: Wed, 16 Aug 2023 09:02:20 +0200	[thread overview]
Message-ID: <5E10F2AD-6D7E-4F2F-ACEB-B6FD3C71C85D@geanix.com> (raw)
In-Reply-To: <20230802100709.GB2156918@gnbcxd0016.gnb.st.com>

Hi Alain,

Thanks for the review

> On 2 Aug 2023, at 12.07, Alain Volmat <alain.volmat@foss.st.com> wrote:
> 
> Hi Sean,
> 
> sorry for the delay for this review.  Thank you Andi for
> the review as well.

Also from my side :) Vacation.

> 
> Few other comments in addition to what Andi already mentioned.
> 
> On Tue, Jul 18, 2023 at 12:54:35PM +0200, Sean Nyekjaer wrote:
>> Add an atomic_xfer method to the driver so that it behaves correctly
>> when controlling a PMIC that is responsible for device shutdown.
>> 
>> The atomic_xfer method added is similar to the one from the i2c-mv64xxx
>> driver. When running an atomic_xfer a bool flag in the driver data is
>> set, the interrupt is not unmasked on transfer start, and the IRQ
>> handler is manually invoked while waiting for pending transfers to
>> complete.
>> 
>> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
>> ---
>> Changes since v1:
>> - Removed dma in atomic
>> 
>> drivers/i2c/busses/i2c-stm32f7.c | 111 ++++++++++++++++++++++---------
>> 1 file changed, 78 insertions(+), 33 deletions(-)
>> 
>> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
>> index e897d9101434..d944b8f85d1c 100644
>> --- a/drivers/i2c/busses/i2c-stm32f7.c
>> +++ b/drivers/i2c/busses/i2c-stm32f7.c
>> @@ -357,6 +357,7 @@ struct stm32f7_i2c_dev {
>> u32 dnf_dt;
>> u32 dnf;
>> struct stm32f7_i2c_alert *alert;
>> + bool atomic;
> 
> I am wondering if this atomic really needs to be within the struct.
> It could well be given as last arg of stm32f7_i2c_xfer_core and
> stm32f7_i2c_xfer functions.

Agree.

> 
> 
>> };
>> 
>> 

[ … ]

>> @@ -1670,7 +1676,22 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
>> return IRQ_HANDLED;
>> }
>> 
>> -static int stm32f7_i2c_xfer(struct i2c_adapter *i2c_adap,
>> +static int stm32f7_i2c_wait_polling(struct stm32f7_i2c_dev *i2c_dev)
>> +{
>> + ktime_t timeout = ktime_add_ms(ktime_get(), i2c_dev->adap.timeout);
>> +
>> + while (ktime_compare(ktime_get(), timeout) < 0) {
>> + udelay(5);
>> + stm32f7_i2c_isr_event(0, i2c_dev);
>> +
>> + if (try_wait_for_completion(&i2c_dev->complete))
>> + return 1;
> 
> I agree with the complete / wait_for_completion approach since it allows
> to keep most of code common by manually calling the isr_event for
> checking status bits.  However what about using completion_done instead
> of try_wait_for_completion here ? This shouldn't change much since
> anyway there is a reinit_completion at the beginning of the xfer
> function, but at least function naming feels better since not refering
> to waiting ..

I’ll take a look at the completion_done()

> 
>> + }
>> 

[ … ]

/Sean


  reply	other threads:[~2023-08-16  7:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 10:54 [PATCH v2] i2c: stm32f7: Add atomic_xfer method to driver Sean Nyekjaer
2023-07-26 21:21 ` Andi Shyti
2023-08-16  6:59   ` Sean Nyekjaer
2023-08-02 10:07 ` Alain Volmat
2023-08-16  7:02   ` Sean Nyekjaer [this message]
2023-08-16  7:22     ` Sean Nyekjaer

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=5E10F2AD-6D7E-4F2F-ACEB-B6FD3C71C85D@geanix.com \
    --to=sean@geanix.com \
    --cc=alain.volmat@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andi.shyti@kernel.org \
    --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=mcoquelin.stm32@gmail.com \
    --cc=pierre-yves.mordret@foss.st.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