From patchwork Thu Apr 4 03:35:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10884813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 095EE17E1 for ; Thu, 4 Apr 2019 03:37:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E31E928A26 for ; Thu, 4 Apr 2019 03:37:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6CAC28A28; Thu, 4 Apr 2019 03:37:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D32E28A27 for ; Thu, 4 Apr 2019 03:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=IxcoyieEQkenOC69aVZBX5U2HaGtv/8YQmKevVsd95U=; b=RRDNllm+iO/5ftwbht1OGVWwwI QfIlANovnuwZPto/tbHmPIcCyYgmSwTclRNpd1Llr+vLOf3ofYqVzcrKBtx1ZW132nG1ujtTsVTlB 4pUuf0Z+JaXiEph0XFnHf6JFVNUIolHUNbc0ohEPs87hpMv4lQ7WMFSUgo/cGaNAZnwB6Fma44E7N oJ3tlqbUKal4BJ4kE8RYlPGA0U6LjnKveESO2b6wAdXUepWtcR7+BBNjdf+Nx+QqGbUH0MFkxbQJG HMrtXufcLWqiHBfHq0HowmeJgBeUXUAUxX7VQnaEZVEd/UZ2p8ezy8qIPaeg0Oncibcoiz23MVvbA LBq/xAJg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBtBf-0004MQ-HF; Thu, 04 Apr 2019 03:37:11 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBtAk-0003D0-PS for linux-arm-kernel@lists.infradead.org; Thu, 04 Apr 2019 03:36:47 +0000 Received: by mail-pl1-x641.google.com with SMTP id w24so446552plp.2 for ; Wed, 03 Apr 2019 20:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xiLcmlCMJ/zn0zkvhqy9D58gyT8D1Vy0Vdw39LfItT8=; b=SMDcOjybVXwz7wdBlpqH1BT0/eZjjAPZeypnxqWiRKROmfscHf+iNCaY66vQARxiWa Ibc+l3pFlOKq23HYZrXxCIuEshc9ftWes8AK/YNY0pMTHDxnYf2SMZ8gq5Sx+xyEa4Bm CKgYtizPTT0hA2s3kz+4G10zIdcwJOd60JmdXV8gmwW+5z11y3VkzOgwiHFwnJBYfQMu fKIqJx4kn+oNqruuVZ2eBJZ1z94plzBRWK1o2ejb+vePaDcalOirTw5bbQMkSngSRpst YynmPkGCq2hyozQ7WN3Q3pN+GpwzBDamTlGj3q7Z+R62+cCjTJJSqeGy8/2SxiMupkR6 8NFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xiLcmlCMJ/zn0zkvhqy9D58gyT8D1Vy0Vdw39LfItT8=; b=fw7qP3QMSTf785G5ZGCKUHnYZ8dneL6iexGnyy2Wa5xpkwOOf00xNx9ZCmTfhHCNDi Sqm3L3hAViSxcpUEfFJ8km9OkfFLtnTebkroeVyPyfqbnse3pYhWcTEw+sWvpzPlriDp JK9k1dDxcBOPB7/cPpPuOzb39dfZ3Y/chJQIyUZhHPG5dg2iIvz1iIyJHwMCg9LKNTb6 /GsuLZfnknT30IfXve7TB/vk/A17Or9zlAeKDqgEgfhb9NFNnM46eGGjtmV24CR2DmlV TSHuEr0mpPIn1yU4kCQJOSzpQIAVe4es5PBFTsXR1DjQe8fx/3ShN75oQjfeAXkAQQL9 qWxQ== X-Gm-Message-State: APjAAAUuasA7Ng8A9mSPyn57CX0IqL4ZjA9jRvwfD4D1haN34gtjQorW NJA997tvtHnZ6fV5AtHl4bJfU0Q/G7o= X-Google-Smtp-Source: APXvYqxdcioGEwtl0wmEqPe48OV/nikIhd55XEe1yLomC6Q9GNFK9nVQi0i5vzJ3NuXkkoZgqBo6LQ== X-Received: by 2002:a17:902:e684:: with SMTP id cn4mr3754075plb.71.1554348974114; Wed, 03 Apr 2019 20:36:14 -0700 (PDT) Received: from xps15.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id u5sm12212780pfm.121.2019.04.03.20.36.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 20:36:13 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 07/20] coresight: Properly address errors in sink::disable() functions Date: Wed, 3 Apr 2019 21:35:28 -0600 Message-Id: <20190404033541.14072-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190404033541.14072-1-mathieu.poirier@linaro.org> References: <20190404033541.14072-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190403_203615_411746_1A6C1252 X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, peterz@infradead.org, mike.leach@arm.com, leo.yan@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When disabling a sink the reference counter ensures the operation goes through if nobody else is using it. As such if drvdata::mode is already set do CS_MODE_DISABLED, it is an error and should be reported as such. Signed-off-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etb10.c | 9 ++++----- drivers/hwtracing/coresight/coresight-tmc-etf.c | 9 ++++----- drivers/hwtracing/coresight/coresight-tmc-etr.c | 9 ++++----- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 5af50a852e87..52b7d95ab498 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -341,11 +341,10 @@ static int etb_disable(struct coresight_device *csdev) return -EBUSY; } - /* Disable the ETB only if it needs to */ - if (drvdata->mode != CS_MODE_DISABLED) { - etb_disable_hw(drvdata); - drvdata->mode = CS_MODE_DISABLED; - } + /* Complain if we (somehow) got out of sync */ + WARN_ON_ONCE(drvdata->mode == CS_MODE_DISABLED); + etb_disable_hw(drvdata); + drvdata->mode = CS_MODE_DISABLED; spin_unlock_irqrestore(&drvdata->spinlock, flags); dev_dbg(drvdata->dev, "ETB disabled\n"); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index d50a608a60f1..30f868676540 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -297,11 +297,10 @@ static int tmc_disable_etf_sink(struct coresight_device *csdev) return -EBUSY; } - /* Disable the TMC only if it needs to */ - if (drvdata->mode != CS_MODE_DISABLED) { - tmc_etb_disable_hw(drvdata); - drvdata->mode = CS_MODE_DISABLED; - } + /* Complain if we (somehow) got out of sync */ + WARN_ON_ONCE(drvdata->mode == CS_MODE_DISABLED); + tmc_etb_disable_hw(drvdata); + drvdata->mode = CS_MODE_DISABLED; spin_unlock_irqrestore(&drvdata->spinlock, flags); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index f90bca971367..86e748d09dc3 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1416,11 +1416,10 @@ static int tmc_disable_etr_sink(struct coresight_device *csdev) return -EBUSY; } - /* Disable the TMC only if it needs to */ - if (drvdata->mode != CS_MODE_DISABLED) { - tmc_etr_disable_hw(drvdata); - drvdata->mode = CS_MODE_DISABLED; - } + /* Complain if we (somehow) got out of sync */ + WARN_ON_ONCE(drvdata->mode == CS_MODE_DISABLED); + tmc_etr_disable_hw(drvdata); + drvdata->mode = CS_MODE_DISABLED; spin_unlock_irqrestore(&drvdata->spinlock, flags);