All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: gyeyoung <gye976@gmail.com>
Cc: jic23@kernel.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, dlechner@baylibre.com,
	nuno.sa@analog.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org
Subject: Re: [PATCH v3 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
Date: Thu, 17 Apr 2025 19:51:59 +0300	[thread overview]
Message-ID: <aAExr-YPkYAsSQTc@smile.fi.intel.com> (raw)
In-Reply-To: <CAKbEznvXdfszfiuXma_GWhYLwj7mR_WX_H4r6iHZWKp2=41tJw@mail.gmail.com>

On Thu, Apr 17, 2025 at 11:03:12PM +0900, gyeyoung wrote:
> On Tue, Apr 15, 2025 at 2:21 AM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:

...

> > > > > +       /*
> > > > > +        * serdev receive buffer.
> > > > > +        * When data is received from the MH-Z19B,
> > > > > +        * the 'mhz19b_receive_buf' callback function is called and fills this buffer.
> > > > > +        */
> > > > > +       char buf[9];
> > > >
> > > > Should it be DMA-safe?
> > >
> > > I'm not sure if I understood your point correctly,
> > > This code isn't DMA-safe. I'm currently understanding why DMA-safe is necessary.
> > > (but actually other drivers implementing 'serdev ops' use non-DMA-safe buffers.)
> > > I will verify this part and then send the next patch.
> >
> > Because some of the UART drivers may enable DMA by default if it's
> > available and your code won't work on them, right? But double check if
> > serdev makes it DMA-safe before use.
> 
> It seems that the serdev buf doesn't need to be DMA-safe. I looked
> into the PL011 driver as an example,
> which uses DMA, and found that the data received via DMA is firstly
> stored in the buffer within the 'uart_amba_port' structure, and then
> copied into the 'tty_bufhead' within the tty_port. Later, in serdev's
> receive_buf(), it simply copies from the tty_bufhead to into serdev
> buf. So I think there's no need to consider DMA-safe in the serdev buf
> itself.

But who will give those guarantees (note, the code is most likely may be run on
different UART controllers (PL011 is just one of many), have you checked all
supported drivers for DMA?

> would this make sense? If so, I think there is no need to change the
> code related to the buffer.

The bare minimum is to make sure this buffer occupies the cacheline.
Read about DMA safety for the cache coherency.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-04-17 16:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09  2:43 [PATCH v3 0/4] add support for winsen MHZ19B CO2 sensor Gyeyoung Baek
2025-04-09  2:43 ` Gyeyoung Baek
2025-04-09  2:43 ` [PATCH v3 1/4] dt-bindings: add winsen to the vendor prefixes Gyeyoung Baek
2025-04-09  2:43 ` [PATCH v3 2/4] dt-bindings: add device tree support for winsen MHZ19B CO2 sensor Gyeyoung Baek
2025-04-09  2:43 ` [PATCH v3 3/4] iio: chemical: add " Gyeyoung Baek
2025-04-12 15:38   ` Jonathan Cameron
2025-04-14  8:56     ` gyeyoung
2025-04-12 18:25   ` Andy Shevchenko
2025-04-14 15:49     ` gyeyoung
2025-04-14 17:21       ` Andy Shevchenko
2025-04-15  1:16         ` gyeyoung
2025-04-17 14:03         ` gyeyoung
2025-04-17 16:51           ` Andy Shevchenko [this message]
2025-04-20 10:43             ` Gyeyoung Baek
2025-04-09  2:43 ` [PATCH v3 4/4] MAINTAINERS: Add WINSEN MHZ19B Gyeyoung Baek

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=aAExr-YPkYAsSQTc@smile.fi.intel.com \
    --to=andy.shevchenko@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gye976@gmail.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@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.