Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1946485rdg; Sun, 13 Aug 2023 02:55:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTSInW0d6flqPFHmsCIfo8W+enE9Y1Gb/gsA4JodMhNZfa4nzqQbQLOoS2cgALUuxLV627 X-Received: by 2002:a17:907:b0c:b0:99b:6c47:1145 with SMTP id h12-20020a1709070b0c00b0099b6c471145mr5474705ejl.32.1691920507782; Sun, 13 Aug 2023 02:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691920507; cv=none; d=google.com; s=arc-20160816; b=zHbZnBAOYyhy/rD5Ava+dVJwyX1visXVsOrESbuguku+s/6uFZkso99tZ2kdvJYv7B EMSQSunp4WWFZ+7vO9ho+aZDvMLtnllNglbUBmh0QUNBjRkc0vhzG1DBDbYwINhTagmQ DesJHIMEOsbB8ajgxNcX2g9huKbSzqkmPe2KB94R2R/NN2L1m9VfONNcs9lb94lqWzoY wgp9tMg7V0jGeweLG2QCGKATCdBtrzLVV/AvUrRXXIfhGxK6YsTdQhCeB4oNyfJv2+Hv ekE7G2HDU3UPj2Zv+BcM4GZC2zK1wDBO5gwmTTjVrXs0/lhj9cQRjeKgb4lU/1BfEXBx 1BwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:cc:to:subject :tls-required:message-id:from:content-transfer-encoding:date :dkim-signature:mime-version; bh=kH0Tgl//HjNeN/p7nkuMFtG502p+KcTS1aQfN0Rp/3M=; fh=/t+jJSEeYpURVtjnAktODcVAWa5wDgqIPdloQ5ZG/lw=; b=1Af0b7yj01XeJTLkZ5PD86RWp5+5olRnB9EMWEULYItkTPF+qK1kKIvFOQEFj4fCXJ MrZmveFxh2uqp4feeeTW6QgZ+BFtPlOGe4Ye3kylmMhPQ6/E8nzrNciRCLuxiI+WOgR9 PoIkrYG2Vclw57XjiktsmHIEcdY4+D8hU3XNxaGgS2mTYndOUK5hfsXFMPbTMkzCxsos bh6JnDYc0FankXvT3rFvhZUiDo141F+FFvtQVQmEwr4DCRllEbMVBEYU60GaIGYF/iZD rhZJS6thF+66A3ChGZGsnF5C8sp86FsYhRC4cd2fAj9dY9Sn/+RWMPWJveHWmlXhe3DY zFBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bvQn4RPV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h17-20020a170906719100b0099cc01fb28csi6015562ejk.780.2023.08.13.02.54.43; Sun, 13 Aug 2023 02:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bvQn4RPV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230454AbjHMI7x (ORCPT + 99 others); Sun, 13 Aug 2023 04:59:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbjHMI7v (ORCPT ); Sun, 13 Aug 2023 04:59:51 -0400 Received: from out-82.mta0.migadu.com (out-82.mta0.migadu.com [91.218.175.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E37AD10E5 for ; Sun, 13 Aug 2023 01:59:53 -0700 (PDT) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1691917191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kH0Tgl//HjNeN/p7nkuMFtG502p+KcTS1aQfN0Rp/3M=; b=bvQn4RPVVD+mB8DmdcRQnSw0kAJQwL/wL2FPZThJJYTKLA75N3q0U0l6AlMIDX+wrmVxna 0kRh/Fgsc8L82h69RksAjXrVcXGZmjuspwrvGWKhnsuyMQERZbfTDnZ4X0SZV+N8/+gHiy Ns0vUlEAjv83hLxbO+XDJCbxtlz62Xg= Date: Sun, 13 Aug 2023 08:59:50 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Yajun Deng" Message-ID: <148ae07079b42d834a19b100e18070f50acbcc78@linux.dev> TLS-Required: No Subject: Re: [PATCH] dmaengine: ioat: fixing the wrong chancnt To: "Dave Jiang" , vkoul@kernel.org, bhelgaas@google.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: <20230811081645.1768047-1-yajun.deng@linux.dev> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org August 11, 2023 at 11:40 PM, "Dave Jiang" wrote: >=20 >=20On 8/11/23 01:16, Yajun Deng wrote: >=20 >=20>=20 >=20> 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 > >=20 >=20 > Thank you for the patch Yajun. >=20 >=20While 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_devi= ce' 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.=20 =20 > Also, have you tested this patch or is this just from visual inspection= ? >=20 Yes,=20I tested it. =E2=9E=9C ~ ls /sys/class/dma dma0chan0 dma1chan0 dma2chan0 dma3chan0 before: =E2=9E=9C ~ 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: =E2=9E=9C ~ 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=EF=BC=9A 0bbd5f4e97ff ("[I/OAT]: Driver for the Intel(R) I/OAT DMA engine") device->common.chancnt =3D ioatdma_read8(device, IOAT_CHANCNT_OFFSET); e38288117c50 ("ioatdma: Remove the wrappers around read(bwl)/write(bwl) i= n ioatdma") device->common.chancnt =3D 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 rout= ines") dma->chancnt =3D readb(device->reg_base + IOAT_CHANCNT_OFFSET); 55f878ec47e3 ("dmaengine: ioatdma: fixup ioatdma_device namings") dma->chancnt =3D readb(ioat_dma->reg_base + IOAT_CHANCNT_OFFSET); It looks very historic. I'm confused about which one to choose.=20 This=20is a bug, but it only affects /sys/kernel/debug/dmaengine/summary. So I didn't add a fixes tag. =20 >=20>=20 >=20> --- > > 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 *io= at_dma) > > > static int ioat_register(struct ioatdma_device *ioat_dma) > > { > > - int err =3D dma_async_device_register(&ioat_dma->dma_dev); > > + int err; > > + > > + ioat_dma->dma_dev.chancnt =3D 0; > > > + err =3D dma_async_device_register(&ioat_dma->dma_dev); > > if (err) { > > ioat_disable_interrupts(ioat_dma); > > dma_pool_destroy(ioat_dma->completion_pool); > > >