Linux SPI subsystem development
 help / color / mirror / Atom feed
From: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>
To: Yongqin Liu <yongqin.liu@linaro.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	kernel@collabora.com, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Sumit Semwal <sumit.semwal@linaro.org>
Subject: Re: [PATCH] spi: Assign dummy scatterlist to unidirectional transfers
Date: Mon, 29 Jul 2024 15:40:14 -0400	[thread overview]
Message-ID: <2e56fee0-2bbb-4b7d-b955-6990b227c706@notapiano> (raw)
In-Reply-To: <CAMSo37X1GRUtuyHDL5GfQAqbH8EVjgAWR129D3uTF3CRPpLKPQ@mail.gmail.com>

On Tue, Jul 23, 2024 at 12:05:52AM +0800, Yongqin Liu wrote:
> On Thu, 30 May 2024 at 05:04, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> >
> > Wed, May 29, 2024 at 11:42:35AM -0400, Nícolas F. R. A. Prado kirjoitti:
> > > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > >
> > > Commit 8cc3bad9d9d6 ("spi: Remove unneded check for orig_nents")
> > > introduced a regression: unmapped data could now be passed to the DMA
> > > APIs, resulting in null pointer dereferences. Commit 9f788ba457b4 ("spi:
> > > Don't mark message DMA mapped when no transfer in it is") and commit
> > > da560097c056 ("spi: Check if transfer is mapped before calling DMA sync
> > > APIs") addressed the problem, but only partially. Unidirectional
> > > transactions will still result in null pointer dereference. To prevent
> > > that from happening, assign a dummy scatterlist when no data is mapped,
> > > so that the DMA API can be called and not result in a null pointer
> > > dereference.
> >
> > I feel that with this the da560097c056 ("spi: Check if transfer is mapped
> > before calling DMA sync APIs") can be reverted as unneeded. Nícolas, can
> > you check that? If it works, we better revert the unneeded checks.
> 
> FYI, just tested based on the Android Common Kernel android-mainline branch,
> with only the following two changes, the issue is not reported too:
>     9dedabe95b49 spi: Assign dummy scatterlist to unidirectional transfers
>     9f788ba457b4 spi: Don't mark message DMA mapped when no transfer in it is

Hi Yongqin,

Simply reverting commit da560097c056 ("spi: Check if transfer is mapped before
calling DMA sync APIs") caused issues on the sc7180-limozeen platform as I
mentioned in
https://lore.kernel.org/all/1ea41944-a107-4528-8e8d-559c06907e3f@notapiano/.

Instead of that, Andy landed this commit reworking the flag, which got rid of
that check anyway and provided a cleaner solution:
https://lore.kernel.org/all/20240531194723.1761567-9-andriy.shevchenko@linux.intel.com/

Thanks,
Nícolas

      reply	other threads:[~2024-07-29 19:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29 15:42 [PATCH] spi: Assign dummy scatterlist to unidirectional transfers Nícolas F. R. A. Prado
2024-05-29 17:35 ` Mark Brown
2024-05-29 21:04 ` Andy Shevchenko
2024-07-22 16:05   ` Yongqin Liu
2024-07-29 19:40     ` Nícolas F. R. A. Prado [this message]

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=2e56fee0-2bbb-4b7d-b955-6990b227c706@notapiano \
    --to=nfraprado@collabora.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=sumit.semwal@linaro.org \
    --cc=yongqin.liu@linaro.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