From patchwork Fri Jan 6 15:23:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 40169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp879532wrt; Fri, 6 Jan 2023 07:25:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXsW9dbs1CeHRanR7ivskY1pQhtda8QwIXsZpH8dDdVkNtLQMzKBMAWmV+7nNb29myYr4Zze X-Received: by 2002:a05:6a00:288f:b0:581:fddb:749c with SMTP id ch15-20020a056a00288f00b00581fddb749cmr28392499pfb.5.1673018720708; Fri, 06 Jan 2023 07:25:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673018720; cv=none; d=google.com; s=arc-20160816; b=rcHBn+/eE5gzWc9x+M4PYJeDwVqct7h3hHBWKQi4aT8HalQB/o3o17lmEJoFhQ+yLV vufzkkN9K2tE0Hwf3V0VDqCG1NtcY1URcHlW7pjEFJY7LcwTCvj5nWaMRhaYEjKAExdM sXYAHjLLtf6Xb6U+acr1ItFeV34Sj8EeMRY4KHea+wk7GestxbIt3SNF/U4Vy6vgQtdq nIc/jfCA6pBUK1boYSSb0qAjpxx3iGVBLCm5dPWd6H8ePoq+nNo2s2EWNRYAYUwHg5vr Ihgq+sY+U0qJnGWRwWURCGrxsEzxWDKMsJpCYOt/Iyjj25wCQpaICCD18PEnxRIzmZjS ObaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vZgwaGsG68bVOS27H11rwRjuZNB/vkzG/qm1T65bKjY=; b=XPuPVwPemp5at05GyXQMM7J2Yj6c7zHyGwSOSQJwwc5y7MxzkBsjBGfyAHOQNXFlOf 3ITHwIRhTsNatnB8yjWad8wJMMvXcYjnjJqdsz+5b3Ebdikg9F5k6EkPFiiqhOBIAGrd hpqSZ67uC/vFg2S9WlR9WYiNA5m7NE09tcTYmxpcn9+krnilgOT/4bsBms/W3jJ6ni8b CIS9FQo0zdnD2P8sUgcfOkzNuyqkgxdlmYXwRExyOcVWpl/t3ZYU4qa61Umgr2/AXyrc pymP1/TLijN1K0GiETr5OIQuOqsDYn+5KdQrj2tkTv85ZqtUQyG2AUP2cndEEPAk3B6a 0EJA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b22-20020a056a000cd600b0056de69b0c7esi1649803pfv.284.2023.01.06.07.25.07; Fri, 06 Jan 2023 07:25:20 -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 S232291AbjAFPXs (ORCPT + 99 others); Fri, 6 Jan 2023 10:23:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232331AbjAFPXn (ORCPT ); Fri, 6 Jan 2023 10:23:43 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E650B45649 for ; Fri, 6 Jan 2023 07:23:41 -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 8552812FC; Fri, 6 Jan 2023 07:24:23 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 220673F71A; Fri, 6 Jan 2023 07:23:40 -0800 (PST) From: James Clark To: coresight@lists.linaro.org, quic_jinlmao@quicinc.com, suzuki.poulose@arm.com, mike.leach@linaro.org Cc: James Clark , Mathieu Poirier , Leo Yan , Alexander Shishkin , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] coresight: cti: Prevent negative values of enable count Date: Fri, 6 Jan 2023 15:23:28 +0000 Message-Id: <20230106152331.1374973-2-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106152331.1374973-1-james.clark@arm.com> References: <20230106152331.1374973-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754287277630373603?= X-GMAIL-MSGID: =?utf-8?q?1754287277630373603?= Writing 0 to the enable control repeatedly results in a negative value for enable_req_count. After this, writing 1 to the enable control appears to not work until the count returns to positive. Change it so that it's impossible for enable_req_count to be < 0. Returning an error will also allow us to decide whether to call runtime_pm_put() or not in the following commit. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-cti-core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c index d2cf4f4848e1..838872f2484d 100644 --- a/drivers/hwtracing/coresight/coresight-cti-core.c +++ b/drivers/hwtracing/coresight/coresight-cti-core.c @@ -151,9 +151,16 @@ static int cti_disable_hw(struct cti_drvdata *drvdata) { struct cti_config *config = &drvdata->config; struct coresight_device *csdev = drvdata->csdev; + int ret = 0; spin_lock(&drvdata->spinlock); + /* don't allow negative refcounts, return an error */ + if (!atomic_read(&drvdata->config.enable_req_count)) { + ret = -EINVAL; + goto cti_not_disabled; + } + /* check refcount - disable on 0 */ if (atomic_dec_return(&drvdata->config.enable_req_count) > 0) goto cti_not_disabled; @@ -171,12 +178,12 @@ static int cti_disable_hw(struct cti_drvdata *drvdata) coresight_disclaim_device_unlocked(csdev); CS_LOCK(drvdata->base); spin_unlock(&drvdata->spinlock); - return 0; + return ret; /* not disabled this call */ cti_not_disabled: spin_unlock(&drvdata->spinlock); - return 0; + return ret; } void cti_write_single_reg(struct cti_drvdata *drvdata, int offset, u32 value) From patchwork Fri Jan 6 15:23:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 40171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp879956wrt; Fri, 6 Jan 2023 07:26:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXu1CRvPMdh/+HMkpi2phjNHsxc7CYIKFRK2kGbt8cxzlgy0h/UiiDvvatqSRZ3W1H8a8uz3 X-Received: by 2002:a05:6a20:4b1e:b0:a3:dc4e:74f9 with SMTP id fp30-20020a056a204b1e00b000a3dc4e74f9mr63629458pzb.19.1673018776171; Fri, 06 Jan 2023 07:26:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673018776; cv=none; d=google.com; s=arc-20160816; b=uBEG0xxWRcQQzywzyCFms7ovdcCjTiuRSFHATgF1MW/Idwru4Kr9OnUy4o7ewe3sED FnNaM9reOhWlV7DUOCdqqHpQeNyWxxBnNNu/HX73M83eFyBjGs9M/2Zchf+TqKIRORu5 XfXCEk1EwCf/EBTjs/fwuCixkZGWXS6JMy2U27LL/KgO6R1yYLih6+uHst/aMM8woLZK PwyYNVwGt1HI7cz46la32I9yalIaZd2jqrad6g/aBJdFX4l+1LuQ2DAPdRT6FystIokN CMa72NknjLGCEpZ2UDdsuxrDUylh8rNqxLUkXPMqQrUSsG7U35e2p42ch8LlbnBg3iSy aKvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=On1VhKFXiyUifKiYiOeeQs/2CXAvl2DCG+iNNigzgzM=; b=MV3x6leDN+iLXU4WkKaDtsJVntCIw2/kGxOkUPf/iHJbl+P6LTG75NGYt23iTjYVtd rXmSofb9cCKhp2a2JcxJ1S8qSrtLiIT1vUvADGeukbSbneef45EWVjfgaKuAOCcQNbxT BW93YrOFSgyOMs7EMKhbhSK7rsOpiFA0ApyzLLb3i3nKxQ+WrboffWS0vMCXVbL30uAK rG2VFSkgvJo05Xej/S4WGU7gD+TEE1pKV/+GXjz/YVnw9LUM0B98jPXQve2S15uSnoVd NMteK1WkLZM8G8j6Jqk31+9bP9C0NqvC65peaeztpEhYnHtpfHN/tLrdJIRDgRRKi+6C YUMg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 79-20020a630252000000b004792f347556si1884311pgc.623.2023.01.06.07.25.39; Fri, 06 Jan 2023 07:26:16 -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 S234465AbjAFPXw (ORCPT + 99 others); Fri, 6 Jan 2023 10:23:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230442AbjAFPXp (ORCPT ); Fri, 6 Jan 2023 10:23:45 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3390845666 for ; Fri, 6 Jan 2023 07:23:44 -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 C8C6A143D; Fri, 6 Jan 2023 07:24:25 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 654243F71A; Fri, 6 Jan 2023 07:23:42 -0800 (PST) From: James Clark To: coresight@lists.linaro.org, quic_jinlmao@quicinc.com, suzuki.poulose@arm.com, mike.leach@linaro.org Cc: James Clark , Mathieu Poirier , Leo Yan , Alexander Shishkin , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] coresight: cti: Add PM runtime call in enable_store Date: Fri, 6 Jan 2023 15:23:29 +0000 Message-Id: <20230106152331.1374973-3-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106152331.1374973-1-james.clark@arm.com> References: <20230106152331.1374973-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754287273721936916?= X-GMAIL-MSGID: =?utf-8?q?1754287336404539748?= From: Mao Jinlong 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. Fixes: 6746eae4bbad ("coresight: cti: Fix hang in cti_disable_hw()") Signed-off-by: Mao Jinlong [Change to only call pm_runtime_put if a disable happened] Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-cti-sysfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c index 6d59c815ecf5..71e7a8266bb3 100644 --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c @@ -108,10 +108,19 @@ 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); + if (!ret) + pm_runtime_put(dev->parent); + } + if (ret) return ret; return size; From patchwork Fri Jan 6 15:23:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 40170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp879948wrt; Fri, 6 Jan 2023 07:26:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwco5L1OnCgWKnvJ/tR5sd6tePO8YcYHlOnVctnqtRx27AOMHLCaNpONG5UqHO66EIKfd9 X-Received: by 2002:a17:902:f08a:b0:189:efe8:1e with SMTP id p10-20020a170902f08a00b00189efe8001emr53676523pla.68.1673018775132; Fri, 06 Jan 2023 07:26:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673018775; cv=none; d=google.com; s=arc-20160816; b=sPU/fttpTGEUyUpB+pUi6gUr+XHufPUxcBKjZO83PfrXl64Jcm0wSxN1ZnrZaWLwDc MLovWOKMQt6vl6y2y5CzJtrD3AKsrYIT6xyaNnJBbGvGIOjuZT3NibjEb+VoIyLRakIw nfHGeXs/99QXifn/EAdmNCQ2+zrswCy0cpxREuslcni54cJU0uEpu/BMnrAgp0kTAjsE 356+VqZ+ZfJ61YcwnpvH7fyVSCf1yNkqlbk+p9qEmH48/lob1z0sUaY6O1k7W1OxggdH Lm0tKU/gGtX1J6oqb5dDUxL4EbiZgAswT1ymB1hwuoYZCia5B6U9coWkGIeocH/BFPcd wEmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=un/+3nd+MF+10pVy1TiuQXO/nIH4zE4iSKe+sAsEbD4=; b=nFAwNf6O2hGi9teLn3ikmWClssEgNwknexpCFYzGBe3RVLOqPrrfopA+OsNhU7qTsW Mve89SGuiF7zS/Fk7YVabhJAH7Qi6KqNBKZHUZ9J4zFyQfyTFIcuKCnXfRAIF2WWH0wY hg9bL99CWQ93vGa+csIjLW9WohUeJP10kaIMnT6i1w2GtFmW33JH34xopSNLO5VE9cjs ncUSc7y3m9nIi81a3LdMSvMO6EOrtu0FTbgKjc8Gv02yRZTsNKwChFV1vw2ktRkh5f5E a2wMQ7Kn0ue0vyhJzmcYSf1CYk6Prcc8znKkJYsyhRRm0/ykP9vtzqC71V/IMCoLSs6F s+1w== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix9-20020a170902f80900b00189655d51f5si1130258plb.260.2023.01.06.07.25.48; Fri, 06 Jan 2023 07:26:15 -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 S233812AbjAFPYF (ORCPT + 99 others); Fri, 6 Jan 2023 10:24:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbjAFPXr (ORCPT ); Fri, 6 Jan 2023 10:23:47 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F4AB6ECAC for ; Fri, 6 Jan 2023 07:23:46 -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 14DAC15A1; Fri, 6 Jan 2023 07:24:28 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A5D943F71A; Fri, 6 Jan 2023 07:23:44 -0800 (PST) From: James Clark To: coresight@lists.linaro.org, quic_jinlmao@quicinc.com, suzuki.poulose@arm.com, mike.leach@linaro.org Cc: James Clark , Mathieu Poirier , Leo Yan , Alexander Shishkin , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] coresight: cti: Remove atomic type from enable_req_count Date: Fri, 6 Jan 2023 15:23:30 +0000 Message-Id: <20230106152331.1374973-4-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106152331.1374973-1-james.clark@arm.com> References: <20230106152331.1374973-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754287335213509711?= X-GMAIL-MSGID: =?utf-8?q?1754287335213509711?= enable_req_count is only ever accessed inside the spinlock, so to avoid confusion that there are concurrent accesses and simplify the code, change it to an int. One access outside of the spinlock is in enable_show() which appears to allow partially written data to be displayed between enable_req_count, powered and enabled so move this one inside the spin lock too. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-cti-core.c | 14 +++++++------- drivers/hwtracing/coresight/coresight-cti-sysfs.c | 2 +- drivers/hwtracing/coresight/coresight-cti.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c index 838872f2484d..277c890a1f1f 100644 --- a/drivers/hwtracing/coresight/coresight-cti-core.c +++ b/drivers/hwtracing/coresight/coresight-cti-core.c @@ -107,12 +107,12 @@ static int cti_enable_hw(struct cti_drvdata *drvdata) cti_write_all_hw_regs(drvdata); config->hw_enabled = true; - atomic_inc(&drvdata->config.enable_req_count); + drvdata->config.enable_req_count++; spin_unlock_irqrestore(&drvdata->spinlock, flags); return rc; cti_state_unchanged: - atomic_inc(&drvdata->config.enable_req_count); + drvdata->config.enable_req_count++; /* cannot enable due to error */ cti_err_not_enabled: @@ -129,7 +129,7 @@ static void cti_cpuhp_enable_hw(struct cti_drvdata *drvdata) config->hw_powered = true; /* no need to do anything if no enable request */ - if (!atomic_read(&drvdata->config.enable_req_count)) + if (!drvdata->config.enable_req_count) goto cti_hp_not_enabled; /* try to claim the device */ @@ -156,13 +156,13 @@ static int cti_disable_hw(struct cti_drvdata *drvdata) spin_lock(&drvdata->spinlock); /* don't allow negative refcounts, return an error */ - if (!atomic_read(&drvdata->config.enable_req_count)) { + if (!drvdata->config.enable_req_count) { ret = -EINVAL; goto cti_not_disabled; } /* check refcount - disable on 0 */ - if (atomic_dec_return(&drvdata->config.enable_req_count) > 0) + if (--drvdata->config.enable_req_count > 0) goto cti_not_disabled; /* no need to do anything if disabled or cpu unpowered */ @@ -239,7 +239,7 @@ static void cti_set_default_config(struct device *dev, /* Most regs default to 0 as zalloc'ed except...*/ config->trig_filter_enable = true; config->ctigate = GENMASK(config->nr_ctm_channels - 1, 0); - atomic_set(&config->enable_req_count, 0); + config->enable_req_count = 0; } /* @@ -696,7 +696,7 @@ static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd, drvdata->config.hw_enabled = false; /* check enable reference count to enable HW */ - if (atomic_read(&drvdata->config.enable_req_count)) { + if (drvdata->config.enable_req_count) { /* check we can claim the device as we re-power */ if (coresight_claim_device(csdev)) goto cti_notify_exit; diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c index 71e7a8266bb3..e528cff9d4e2 100644 --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c @@ -84,8 +84,8 @@ static ssize_t enable_show(struct device *dev, bool enabled, powered; struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); - enable_req = atomic_read(&drvdata->config.enable_req_count); spin_lock(&drvdata->spinlock); + enable_req = drvdata->config.enable_req_count; powered = drvdata->config.hw_powered; enabled = drvdata->config.hw_enabled; spin_unlock(&drvdata->spinlock); diff --git a/drivers/hwtracing/coresight/coresight-cti.h b/drivers/hwtracing/coresight/coresight-cti.h index acf7b545e6b9..8b106b13a244 100644 --- a/drivers/hwtracing/coresight/coresight-cti.h +++ b/drivers/hwtracing/coresight/coresight-cti.h @@ -141,7 +141,7 @@ struct cti_config { int nr_trig_max; /* cti enable control */ - atomic_t enable_req_count; + int enable_req_count; bool hw_enabled; bool hw_powered;