All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yajun Deng" <yajun.deng@linux.dev>
To: "Dave Jiang" <dave.jiang@intel.com>,
	vkoul@kernel.org, bhelgaas@google.com
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: ioat: fixing the wrong chancnt
Date: Sun, 13 Aug 2023 08:59:50 +0000	[thread overview]
Message-ID: <148ae07079b42d834a19b100e18070f50acbcc78@linux.dev> (raw)
In-Reply-To: <a93a087d-cfae-a135-999e-ae1976694165@intel.com>

August 11, 2023 at 11:40 PM, "Dave Jiang" <dave.jiang@intel.com> wrote:


> 
> On 8/11/23 01:16, Yajun Deng wrote:
> 
> > 
> > The chancnt would be updated in __dma_async_device_channel_register(),
> >  but it was assigned in ioat_enumerate_channels(). Therefore chancnt has
> >  the wrong value.
> >  Clear chancnt before calling dma_async_device_register().
> >  Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> > 
> 
> Thank you for the patch Yajun.
> 
> While this may work, it clobbers the chancnt read from the hardware. I think the preferable fix is to move the value read from the hardware in ioat_enumerate_channels() and its current usages to 'struct ioatdma_device' and leave dma->chancnt unchanged in that function so that zeroing it later is not needed.
>
Yes, it's even better. I noticed that chancnt is hardware related in ioat, so I just clear it before calling dma_async_device_register().It would be updated after calling dma_async_device_register(). And it would have
the same value with read in ioat_enumerate_channels().
It doesn't seem clobber the chancnt read from the hardware. 
 
> Also, have you tested this patch or is this just from visual inspection?
> 
Yes, I tested it.

➜  ~ ls /sys/class/dma
dma0chan0  dma1chan0  dma2chan0  dma3chan0

before:
➜  ~ cat /sys/kernel/debug/dmaengine/summary
dma0 (0000:00:04.0): number of channels: 2
dma1 (0000:00:04.1): number of channels: 2
dma2 (0000:00:04.2): number of channels: 2
dma3 (0000:00:04.3): number of channels: 2

after:
➜  ~ cat /sys/kernel/debug/dmaengine/summary
dma0 (0000:00:04.0): number of channels: 1
dma1 (0000:00:04.1): number of channels: 1
dma2 (0000:00:04.2): number of channels: 1
dma3 (0000:00:04.3): number of channels: 1


> And need a fixes tag.
>
I've tried to find the commit introduced, it looks like it was introduced from the source.
The following commits are related to chancnt:

0bbd5f4e97ff ("[I/OAT]: Driver for the Intel(R) I/OAT DMA engine")
device->common.chancnt = ioatdma_read8(device, IOAT_CHANCNT_OFFSET);

e38288117c50 ("ioatdma: Remove the wrappers around read(bwl)/write(bwl) in ioatdma")
device->common.chancnt = readb(device->reg_base + IOAT_CHANCNT_OFFSET);

584ec22759c0 ("ioat: move to drivers/dma/ioat/")
move driver/dma/ioatdma.c to driver/dma/ioat/

f2427e276ffe ("ioat: split ioat_dma_probe into core/version-specific routines")
dma->chancnt = readb(device->reg_base + IOAT_CHANCNT_OFFSET);

55f878ec47e3 ("dmaengine: ioatdma: fixup ioatdma_device namings")
dma->chancnt = readb(ioat_dma->reg_base + IOAT_CHANCNT_OFFSET);

It looks very historic. I'm confused about which one to choose. 
This is a bug, but it only affects /sys/kernel/debug/dmaengine/summary.
So I didn't add a fixes tag.

 
> > 
> > ---
> >  drivers/dma/ioat/init.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >  diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
> >  index c4602bfc9c74..928fc8a83a36 100644
> >  --- a/drivers/dma/ioat/init.c
> >  +++ b/drivers/dma/ioat/init.c
> >  @@ -536,8 +536,11 @@ static int ioat_probe(struct ioatdma_device *ioat_dma)
> >  > static int ioat_register(struct ioatdma_device *ioat_dma)
> >  {
> >  - int err = dma_async_device_register(&ioat_dma->dma_dev);
> >  + int err;
> >  +
> >  + ioat_dma->dma_dev.chancnt = 0;
> >  > + err = dma_async_device_register(&ioat_dma->dma_dev);
> >  if (err) {
> >  ioat_disable_interrupts(ioat_dma);
> >  dma_pool_destroy(ioat_dma->completion_pool);
> >
>

  reply	other threads:[~2023-08-13  9:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11  8:16 [PATCH] dmaengine: ioat: fixing the wrong chancnt Yajun Deng
2023-08-11 15:40 ` Dave Jiang
2023-08-13  8:59   ` Yajun Deng [this message]
2023-08-14 15:06     ` Dave Jiang

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=148ae07079b42d834a19b100e18070f50acbcc78@linux.dev \
    --to=yajun.deng@linux.dev \
    --cc=bhelgaas@google.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vkoul@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.