Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Gustavo Silva <gustavograzs@gmail.com>
Cc: "Alex Lanzano" <lanzano.alex@gmail.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] iio: imu: bmi270: add channel for step counter
Date: Mon, 5 May 2025 14:13:57 +0100	[thread overview]
Message-ID: <20250505141357.4d1760bf@jic23-huawei> (raw)
In-Reply-To: <swswxbwejqyrekr2bvjf4p5lglodg3hlgl5ckiluxpazzl3chn@ga3uriqvmv7b>

On Sat, 26 Apr 2025 21:19:13 -0300
Gustavo Silva <gustavograzs@gmail.com> wrote:

> On Sat, Apr 26, 2025 at 02:40:20PM +0100, Jonathan Cameron wrote:
> > On Thu, 24 Apr 2025 21:14:50 -0300
> > Gustavo Silva <gustavograzs@gmail.com> wrote:
> >   
> > > Add a channel for enabling/disabling the step counter, reading the
> > > number of steps and resetting the counter.
> > > 
> > > Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>  
> > Hi Gustavo,
> > 
> > This is tripping over the somewhat theoretical requirement for
> > regmap to be provided with DMA safe buffers for bulk accesses.
> > 
> > Jonathan
> >   
> 
> Hi Jonathan,
> 
> Thanks for the review. I've got a few questions inline.
> 
> > > ---
> > >  drivers/iio/imu/bmi270/bmi270_core.c | 127 +++++++++++++++++++++++++++++++++++
> > >  1 file changed, 127 insertions(+)
> > > 
> > > diff --git a/drivers/iio/imu/bmi270/bmi270_core.c b/drivers/iio/imu/bmi270/bmi270_core.c
> > > index a86be5af5ccb1f010f2282ee31c47f284c1bcc86..f09d8dead9df63df5ae8550cf473b5573374955b 100644
> > > --- a/drivers/iio/imu/bmi270/bmi270_core.c
> > > +++ b/drivers/iio/imu/bmi270/bmi270_core.c
> > > @@ -31,6 +31,8 @@  
> >   
> > >  /* See datasheet section 4.6.14, Temperature Sensor */
> > >  #define BMI270_TEMP_OFFSET				11776
> > >  #define BMI270_TEMP_SCALE				1953125
> > > @@ -111,6 +118,7 @@ struct bmi270_data {
> > >  	struct iio_trigger *trig;
> > >  	 /* Protect device's private data from concurrent access */
> > >  	struct mutex mutex;
> > > +	int steps_enabled;  
> > 
> > Seems a little odd to have a thing called _enabled as an integer.
> > Probably better as a bool even though that will require slightly more
> > code to handle read / write.
> >   
> I agree that a bool might be more appropriate in this case. I decided to
> use an int to keep consistency with other drivers, specifically bma400
> and the iio dummy driver.
> If you prefer, I'll use a bool here and after this series submit a patch
> updating those drivers as well.

Yes. I think that would be a nice little logical improvement here and in those
drivers.  Not particularly critical though!

> 
> >   
> > >  
> > >  	/*
> > >  	 * Where IIO_DMA_MINALIGN may be larger than 8 bytes, align to
> > > @@ -282,6 +290,99 @@ static const struct  bmi270_odr_item bmi270_odr_table[] = {
> > >  	},
> > >  };
> > >  
> > > +enum bmi270_feature_reg_id {
> > > +	BMI270_SC_26_REG,
> > > +};
> > > +
> > > +struct bmi270_feature_reg {
> > > +	u8 page;
> > > +	u8 addr;
> > > +};
> > > +
> > > +static const struct bmi270_feature_reg bmi270_feature_regs[] = {
> > > +	[BMI270_SC_26_REG] = {
> > > +		.page = 6,
> > > +		.addr = 0x32,
> > > +	},
> > > +};
> > > +
> > > +static int bmi270_write_feature_reg(struct bmi270_data *data,
> > > +				    enum bmi270_feature_reg_id id,
> > > +				    u16 val)
> > > +{
> > > +	const struct bmi270_feature_reg *reg = &bmi270_feature_regs[id];
> > > +	int ret;
> > > +
> > > +	ret = regmap_write(data->regmap, BMI270_FEAT_PAGE_REG, reg->page);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	return regmap_bulk_write(data->regmap, reg->addr, &val, sizeof(val));  
> > 
> > For a regmap on top of an SPI bus. I think we are still requiring DMA safe
> > buffers until we can get confirmation that the API guarantees that isn't
> > needed.  (there is another thread going on where we are trying to get that
> > confirmation).
> > 
> > That is a pain here because this can run concurrently with buffered
> > capture and as such I think we can't just put a additional element after
> > data->data but instead need to mark that new element __aligned(IIO_DMA_MINALIGN)
> > as well (and add a comment that it can be used concurrently with data->data).
> >  
> Just to clarify, when you say data->data, are you referring to the
> bmi270_data::buffer variable? That used to be called 'data' but it was
> changed to 'buffer' in commit 16c94de2a.

Yes.  The one marked __aligned(IIO_DMA_MINALIGN)
I was looking at old code I guess!

Jonathan

  reply	other threads:[~2025-05-05 13:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-25  0:14 [PATCH 0/3] BMI270: Add support for step counter and motion events Gustavo Silva
2025-04-25  0:14 ` [PATCH 1/3] iio: imu: bmi270: add channel for step counter Gustavo Silva
2025-04-25  4:28   ` Andy Shevchenko
2025-04-26 13:40   ` Jonathan Cameron
2025-04-27  0:19     ` Gustavo Silva
2025-05-05 13:13       ` Jonathan Cameron [this message]
2025-05-07 10:35   ` kernel test robot
2025-04-25  0:14 ` [PATCH 2/3] iio: imu: bmi270: add step counter watermark event Gustavo Silva
2025-04-25  4:33   ` Andy Shevchenko
2025-04-26 23:01     ` Gustavo Silva
2025-04-26 13:47   ` Jonathan Cameron
2025-04-27  0:57     ` Gustavo Silva
2025-05-05 13:21       ` Jonathan Cameron
2025-04-25  0:14 ` [PATCH 3/3] iio: imu: bmi270: add support for motion events Gustavo Silva
2025-04-25  5:25   ` Andy Shevchenko
2025-04-26 23:06     ` Gustavo Silva
2025-04-26 14:12   ` Jonathan Cameron

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=20250505141357.4d1760bf@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gustavograzs@gmail.com \
    --cc=lanzano.alex@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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