Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1634960rwe; Fri, 2 Sep 2022 00:42:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR5PFY2edeCquEws7mnIqXfRzi8RQdjsXfbyYLkMqcMThgUoON79+O7Dfl3qM3Gk2UCYNW4b X-Received: by 2002:a05:6402:2751:b0:443:d90a:43d4 with SMTP id z17-20020a056402275100b00443d90a43d4mr32743639edd.368.1662104570361; Fri, 02 Sep 2022 00:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662104570; cv=none; d=google.com; s=arc-20160816; b=XvgM9gzBcguWIH4nJ24wHo0TGzN4Xp+eZBKq/01woPj/m0j9pfYMAzwhhNdoYWPFNB UFxQLdKsPLz7QL3yUg0jcq/k+iFGD74qbI1e2NbOErbNmFks8liX1RqroW48ytAO9WWA +MdTlU8/DBFEvnWb9zZ4eCZtKT4I+xDWzbgm2RlnNsbNwIDXYsfyoXjza/WFNxOGylit xg2GWOfVbBO3sTFLwJPMN4+KuHA2nUWGcVyK4jII0vVId6lVH6DIB21oFVkblvYxxHvu cK7mjrmAXLtzvYXOoHD7v/WtBFW4eItW+0aF5MVJDUMgxpnnMexpC+fiP+AXIqq9mfeC 0aOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:subject:user-agent:mime-version:date:message-id; bh=cvaksQ2kH8sqcz5EdOcvy9WIG8qKybx25LugllLuvVc=; b=qZuLoVi6GTxbGzBnvHovKLA7qhODeM6HGvkWCvqxM+vpnSjNRK6NC/N1/qx8pjd8q2 vEhUXxwNknq0sOd8VH1P33xboZQooefnzBfd8O2mFzhzcpbuX/eqL1Daip00QMujdd7X 4hwPAgGNX0MZfouSQT4b2HkkgfR9/77Nhs0xdCRZORP5pTQiXv2HO3bXppsxZ0iGQfry C77uUHB1Cl0XHMGNMrOvwc0Ij05qzCpgPvt84UTrvxtLQZqEOVyr3PHS7DpM8aBxOvuB btowunipFyG3PRgbr2ECY95eGbUH78OIi74FDVp9JOzk4ZKoJB/kyju6AevD7yiizgR7 XIZA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx20-20020a170906a1d400b007305f9cf344si1104953ejb.853.2022.09.02.00.42.24; Fri, 02 Sep 2022 00:42:50 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235217AbiIBHOF (ORCPT + 99 others); Fri, 2 Sep 2022 03:14:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbiIBHOE (ORCPT ); Fri, 2 Sep 2022 03:14:04 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F176DB8F04; Fri, 2 Sep 2022 00:14:01 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJpvt0T4qzkWpd; Fri, 2 Sep 2022 15:10:18 +0800 (CST) Received: from kwepemm600007.china.huawei.com (7.193.23.208) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 2 Sep 2022 15:14:00 +0800 Received: from [10.67.102.167] (10.67.102.167) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 2 Sep 2022 15:13:59 +0800 Message-ID: <9c4ca0b8-863d-1f27-9ba0-819d597aa4ce@huawei.com> Date: Fri, 2 Sep 2022 15:13:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 3/3] dmaengine: Fix client_count is countered one more incorrectly. To: Koba Ko , Vinod Koul , , References: <20220830093207.951704-1-koba.ko@canonical.com> From: Jie Hai In-Reply-To: <20220830093207.951704-1-koba.ko@canonical.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.167] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600007.china.huawei.com (7.193.23.208) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi, Koba Ko Thanks for your patch. I've had the same problem,see https://lore.kernel.org/all/20220716024453.1418259-1-haijie1@huawei.com/. The two operations of updating client_count, that is, chan->client_count++; balance_ref_count(chan); the order of which is modified by d2f4f99db3e9 ("dmaengine: Rework dma_chan_get"). I have complied and tested it on my arm64 and this patch does fix the problem. For this patch, Reviewed-by: Jie Hai Test-by: Jie Hai Best regards, Jie Hai On 2022/8/30 17:32, Koba Ko wrote: > If the passed client_count is 0, > it would be incremented by balance_ref_count first > then increment one more. > This would cause client_count to 2. > > cat /sys/class/dma/dma0chan*/in_use > 2 > 2 > 2 > > Fixes: d2f4f99db3e9 ("dmaengine: Rework dma_chan_get") > Signed-off-by: Koba Ko > --- > drivers/dma/dmaengine.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c > index 2cfa8458b51be..78f8a9f3ad825 100644 > --- a/drivers/dma/dmaengine.c > +++ b/drivers/dma/dmaengine.c > @@ -451,7 +451,8 @@ static int dma_chan_get(struct dma_chan *chan) > /* The channel is already in use, update client count */ > if (chan->client_count) { > __module_get(owner); > - goto out; > + chan->client_count++; > + return 0; > } > > if (!try_module_get(owner)) > @@ -470,11 +471,11 @@ static int dma_chan_get(struct dma_chan *chan) > goto err_out; > } > > + chan->client_count++; > + > if (!dma_has_cap(DMA_PRIVATE, chan->device->cap_mask)) > balance_ref_count(chan); > > -out: > - chan->client_count++; > return 0; > > err_out: