Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2345864rwn; Fri, 16 Sep 2022 08:59:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TWyTiTaYYCCq1Dy7X1yqilcamW+kQz4derjHlHC8KWvVrxDjPeVJln4eZwzOfJX4D8sxk X-Received: by 2002:aa7:de9a:0:b0:44d:8191:44c5 with SMTP id j26-20020aa7de9a000000b0044d819144c5mr4556986edv.232.1663343992430; Fri, 16 Sep 2022 08:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663343992; cv=none; d=google.com; s=arc-20160816; b=rZw/HH41H2PdXJGdOdagrMIcMeN4ncuZFiN2LVjfm2RY3qF1MSq/e3cmu+a7EhIIRH L+NX6+b1jtnWe9VLTURmaLPMq6Ogq2GtDXPLENXB3CPqP+3Ok0HlMTByfs80O57o523X Mnu0luubD0nh7u7J6QoYlhhUEjoJwRiu0o8geKnuW9Udao4+MLgbgmhQqh5CZS537K8x z+1z+aa0QhaqqdFRA00KzYjoxgJgkhHPZxPQWqNuX1fif/cwmVEmpGfYjBKuUcDxUdbg l3HYGJVSFdt27ZoLxQx/17GvmniBsCtYFxTB1NkR/dJGnkFd6V3DI9eqO0/7AMw1RN2X FxwQ== 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:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=VCJDvcEqVhms47o7ABYBVdmbRjCJWSksAz2wMuTjf4Q=; b=FTrjEZdcElewiY1PbUrzajESUq8OqBlyfbzWdz2K+xWMs4ZSc9XPm3nU07bZHVsN+D q1ZEhbkfvMFd/PzEK5/ft1kXj0xmWysuo6XuEsf/RKP8WLyHHUSrkkhg4esIVhu5P1Fp qnPd/bgeK4I1ScxG1KJDUSG4LHUWHwJ9AmTFQKHmqF6zZ7+dNxkdU9EFFx7KVhlm07Mf 2Srl3AdGsyn8ljIC58o+EWre6NglsjNT89MTCWKiHCAbGtK6sXJrVJfbpUj/H7LN51Js Xz64kQiM8JljE5DTedZ5WVUa5hkBEdb4IjVNJdQKfjSHF6KnjYxEXicVovRcR0q8Tp8D 2OJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DDA5TLib; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a05640211c700b0044202417985si2911704edw.108.2022.09.16.08.59.27; Fri, 16 Sep 2022 08:59:52 -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=@intel.com header.s=Intel header.b=DDA5TLib; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbiIPPqM (ORCPT + 99 others); Fri, 16 Sep 2022 11:46:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiIPPqK (ORCPT ); Fri, 16 Sep 2022 11:46:10 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C59AA7647E; Fri, 16 Sep 2022 08:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663343169; x=1694879169; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=D3l66SxyUdvDZAIU+8Ob0WwZcK5UxA8UNUD0uX4GNLg=; b=DDA5TLibNIvbrn7IFySQE8omBhRE//fg3AWmuYEczXkm54esrj+W/WzP 6Vd7je+yLHNBIyPpY/4oj0XD83WBH5YR8vUl8dTQrL8c23gK+UVpyCy+W bAQ/+ZuopQen8FMJTawXQG3CnFk9dnd8MccFBID5Z2IN4XAaLJYMa+q7h U7ntpAkv0b08jZBIft0Ox/wvyintH8N2hc3B/dC2FUungM2Sq78yporpY JXImvicUdSt7iGjZ8jEWBHoqQALPGQPR6tCMGZba318ye6hbLsp98ehsl XuMagdAz/7OusJ7RNu5M+aHYAUNn4ZMDzPiP/JyFhoxEApq1U9cRV4Ccr g==; X-IronPort-AV: E=McAfee;i="6500,9779,10472"; a="279399977" X-IronPort-AV: E=Sophos;i="5.93,320,1654585200"; d="scan'208";a="279399977" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2022 08:46:09 -0700 X-IronPort-AV: E=Sophos;i="5.93,320,1654585200"; d="scan'208";a="743378184" Received: from djiang5-mobl2.amr.corp.intel.com (HELO [10.212.64.121]) ([10.212.64.121]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2022 08:46:08 -0700 Message-ID: <262e809d-21e8-99ee-2245-5c28fa98afe1@intel.com> Date: Fri, 16 Sep 2022 08:46:08 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.2.2 Subject: Re: [PATCH 3/3] dmaengine: Fix client_count is countered one more incorrectly. Content-Language: en-US To: Koba Ko , Vinod Koul , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220830093207.951704-1-koba.ko@canonical.com> From: Dave Jiang In-Reply-To: <20220830093207.951704-1-koba.ko@canonical.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 On 8/30/2022 2:32 AM, 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 Reviewed-by: Dave Jiang > --- > 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: