From: Dan Carpenter <dan.carpenter@linaro.org>
To: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
Cc: linux-spi@vger.kernel.org, Doug Anderson <dianders@chromium.org>,
Stephen Boyd <swboyd@chromium.org>,
Mark Brown <broonie@kernel.org>
Subject: Re: [bug report] spi: spi-qcom-qspi: Add DMA mode support
Date: Fri, 16 Jun 2023 17:24:44 +0300 [thread overview]
Message-ID: <78fb1d2e-6fe3-4bd3-a232-ad6be35eaf0e@kadam.mountain> (raw)
In-Reply-To: <a244d741-02bb-9d74-0a6c-1f01a6eeb360@quicinc.com>
On Fri, Jun 16, 2023 at 07:42:30PM +0530, Vijaya Krishna Nivarthi wrote:
> Hello Dan,
>
>
> On 6/16/2023 6:12 PM, Dan Carpenter wrote:
> > Hello Vijaya Krishna Nivarthi,
> >
> > The patch b5762d95607e: "spi: spi-qcom-qspi: Add DMA mode support"
> > from Apr 24, 2023, leads to the following Smatch static checker
> > warning:
> >
> > drivers/spi/spi-qcom-qspi.c:368 qcom_qspi_setup_dma_desc()
> > warn: sleeping in atomic context
> >
> > drivers/spi/spi-qcom-qspi.c
> > 336 static int qcom_qspi_setup_dma_desc(struct qcom_qspi *ctrl,
> > 337 struct spi_transfer *xfer)
> > 338 {
> > 339 int ret;
> > 340 struct sg_table *sgt;
> > 341 dma_addr_t dma_ptr_sg;
> > 342 unsigned int dma_len_sg;
> > 343 int i;
> > 344
> > 345 if (ctrl->n_cmd_desc) {
> > 346 dev_err(ctrl->dev, "Remnant dma buffers n_cmd_desc-%d\n", ctrl->n_cmd_desc);
> > 347 return -EIO;
> > 348 }
> > 349
> > 350 sgt = (ctrl->xfer.dir == QSPI_READ) ? &xfer->rx_sg : &xfer->tx_sg;
> > 351 if (!sgt->nents || sgt->nents > QSPI_MAX_SG) {
> > 352 dev_warn_once(ctrl->dev, "Cannot handle %d entries in scatter list\n", sgt->nents);
> > 353 return -EAGAIN;
> > 354 }
> > 355
> > 356 for (i = 0; i < sgt->nents; i++) {
> > 357 dma_ptr_sg = sg_dma_address(sgt->sgl + i);
> > 358 if (!IS_ALIGNED(dma_ptr_sg, QSPI_ALIGN_REQ)) {
> > 359 dev_warn_once(ctrl->dev, "dma_address not aligned to %d\n", QSPI_ALIGN_REQ);
> > 360 return -EAGAIN;
> > 361 }
> > 362 }
> > 363
> > 364 for (i = 0; i < sgt->nents; i++) {
> > 365 dma_ptr_sg = sg_dma_address(sgt->sgl + i);
> > 366 dma_len_sg = sg_dma_len(sgt->sgl + i);
> > 367
> > --> 368 ret = qcom_qspi_alloc_desc(ctrl, dma_ptr_sg, dma_len_sg);
> >
> > The qcom_qspi_alloc_desc() is a sleeping allocation, but the caller
> > qcom_qspi_transfer_one() is holding spin_lock_irqsave(&ctrl->lock, flags).
>
>
> I think We should be able to move qcom_qspi_setup_dma_desc() , and thus
> qcom_qspi_alloc_desc(), out of critical section.
>
> Right now we are looking into some issues with DMA mode transfer that have
> showed up recently and will likely have a Fixes: patch next week.
>
> Can we include this change in same series?
>
> Another option is to include flags __GFP_ATOMIC in call to dma_pool_alloc()
> and upload a Fixes: patch right away.
>
> Would that work?
>
> Can you please advise?
This is from static analysis not testing. It doesn't affect me at all,
so I don't have any opinion. I imagine that fixing it next week is
fine.
regards,
dan carpenter
prev parent reply other threads:[~2023-06-16 14:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-16 12:42 [bug report] spi: spi-qcom-qspi: Add DMA mode support Dan Carpenter
2023-06-16 14:12 ` Vijaya Krishna Nivarthi
2023-06-16 14:24 ` Dan Carpenter [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=78fb1d2e-6fe3-4bd3-a232-ad6be35eaf0e@kadam.mountain \
--to=dan.carpenter@linaro.org \
--cc=broonie@kernel.org \
--cc=dianders@chromium.org \
--cc=linux-spi@vger.kernel.org \
--cc=quic_vnivarth@quicinc.com \
--cc=swboyd@chromium.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).