Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13221482rwl; Wed, 4 Jan 2023 05:22:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtavrSbRtKBsQuWPTzRPJNaf1anOiB7qFv2tEsXMGb/O4pqITmgSc5fcvoTthbX2nlCX0XM X-Received: by 2002:a17:906:4a0c:b0:7c1:3018:73b6 with SMTP id w12-20020a1709064a0c00b007c1301873b6mr40840461eju.61.1672838524863; Wed, 04 Jan 2023 05:22:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672838524; cv=none; d=google.com; s=arc-20160816; b=p6fU1Vt9NwgO932yaCY8yupJFvRHPZGIhuKIvPZjon34KvSFrRziCU79sraqVWMYU+ Gx2NeWxKta4OsrOfeIykDcZzDTJWvHH5TN4o+tiotTO2AZUgmqCgkc0bi2RsEhnjhs+Z VEIB00+w+VODTfAUKvQNwNTv9SSFGy2ckImfZswvskwolna2bFgAtQoHwEaQtcDaqWIp t7hkrYYUaPk0J3VpkOg1s4BG2qNsyh/ed6CV4EmXX9tWYUgozHazF/gAcNt0EDrTG+k2 fAriANThUsGe6Tw+XRQbnGsE8EbVZMPufUSUSGNZ6zbvtuG3bk6AaiUESB1wPx3uQJwq dKpw== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=JUT9HGpRkmw+Gu4SUL3LF9PpNopvotrcRkLnvrSpx3g=; b=Sp1bUxSgbWw39RlzbabzjnWGI82IukGoxRNNZP4NCWP9EcwZDZHNXNy6hku+ZqzXqZ lvKSz10vPVKjVNJNEE4UNec8soYr1wFc0rJOMtw+NQq8VAJ8HftHQdTNbHhs+1pdGVIv OoyNljSr2v8VXmhssgFu9VZ4MlD1fOkiyj6Ejvbw9qj1uAieCZ6S0iVNtHRt3jiG4Bla nvlmFJbQwc3jZJaB3CI7UDKTBDYNbcEr1jNAhrtCaa1i/E6ILPSDnbkhdX1aDRb+EpKg FVUp590YR4muDY/pY6gYBM/5lhbSEPgjuaJCfZ2sdiZj8C33tvoYPNGDbccLyt5bVkHp 20bA== 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=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa35-20020a17090786a300b007813594dc31si29539504ejc.523.2023.01.04.05.21.51; Wed, 04 Jan 2023 05:22:04 -0800 (PST) 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=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239068AbjADNOY (ORCPT + 57 others); Wed, 4 Jan 2023 08:14:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239496AbjADNNm (ORCPT ); Wed, 4 Jan 2023 08:13:42 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A7A03B911; Wed, 4 Jan 2023 05:11:17 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD30D1063; Wed, 4 Jan 2023 05:11:58 -0800 (PST) Received: from [10.57.42.13] (unknown [10.57.42.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1B8B53F587; Wed, 4 Jan 2023 05:11:14 -0800 (PST) Message-ID: <9a86f7cd-2dce-f27a-af21-d64318ca3ef7@arm.com> Date: Wed, 4 Jan 2023 13:11:13 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH] coresight: cti: Add PM runtime call in enable_store Content-Language: en-US To: Mao Jinlong Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei , Yuanfang Zhang , Tao Zhang , Hao Zhang , linux-arm-msm@vger.kernel.org, Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , Alexander Shishkin , Suzuki K Poulose References: <20221224141700.20891-1-quic_jinlmao@quicinc.com> From: James Clark In-Reply-To: <20221224141700.20891-1-quic_jinlmao@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,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 24/12/2022 14:17, Mao Jinlong wrote: > In commit 6746eae4bbad ("coresight: cti: Fix hang in cti_disable_hw()") > PM runtime calls are removed from cti_enable_hw/cti_disable_hw. When > enabling CTI by writing enable sysfs node, clock for accessing CTI > register won't be enabled. Device will crash due to register access > issue. Add PM runtime call in enable_store to fix this issue. > > Signed-off-by: Mao Jinlong > --- > drivers/hwtracing/coresight/coresight-cti-sysfs.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c > index 6d59c815ecf5..b1ed424ae043 100644 > --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c > +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c > @@ -108,10 +108,17 @@ static ssize_t enable_store(struct device *dev, > if (ret) > return ret; > > - if (val) > + if (val) { > + ret = pm_runtime_resume_and_get(dev->parent); > + if (ret) > + return ret; > ret = cti_enable(drvdata->csdev); > - else > + if (ret) > + pm_runtime_put(dev->parent); > + } else { > ret = cti_disable(drvdata->csdev); > + pm_runtime_put(dev->parent); Hi Jinlong, This new pm_runtime_put() causes this when writing 0 to enable: [ 483.253814] coresight-cti 23020000.cti: Runtime PM usage count underflow! Maybe we can modify cti_disable_hw() to return a value to indicate that the disable actually happened, and only then call pm_runtime_put(). I suppose you could also check in the store function if it was already enabled first, but then I don't know what kind of locking that would need? cti_disable_hw() already seems to have a couple of locks, so maybe the return value solution is easiest. Thanks James