From patchwork Mon Sep 28 16:35:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11804103 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B7926CB for ; Mon, 28 Sep 2020 16:43:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EADAF214D8 for ; Mon, 28 Sep 2020 16:43:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="S1AvNnrt"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ilWQBABA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EADAF214D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=dV+47Qa2B86Z1EFjV4KDKcgPRflLSHOIhWy9RwUO1y0=; b=S1AvNnrt3VY7vmIcTohhDEM85 X935cdpav4laqjhuT07adgncChuUVk710E5BPwHrPWgaHLLIPa151lGoC//MbjEGgcuMXXCROVFCJ eh2xUkSJrG2mVFc3gGGB7v+MnEuZAbekloVNFJjhr9WXyY6/tC0o9CwBRa4R+nABWezi0uYgy1vCD AIkPoYbylP8wipwPPdauTHMqAlokQjW1ErUdz5fYjoeMwp3V7w1jJLFg4ygBryu86pVthsWpiYzWB CJF6nuffDuhv6hP3qucF8CTp1BDYoIOVgqjSCNhTAI/aQlmt7llh6Bo+46Ocw2fDdwUrwNU8Ft/8u KCYdfWHiQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMwCb-0002gx-8R; Mon, 28 Sep 2020 16:40:37 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMw7m-0000eB-2A for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2020 16:35:45 +0000 Received: by mail-pf1-x441.google.com with SMTP id f18so1502810pfa.10 for ; Mon, 28 Sep 2020 09:35:37 -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 :mime-version:content-transfer-encoding; bh=IMd2wxbWSskBrQ2C+X7YA5Ufqq005IN1/YwGk6ozQGg=; b=ilWQBABA6kMOrJoh/CKJlyxmjAFWLqWaWPFEc1dIuByBNPZQa0yfmTbHaUIGnrkmQG IPLjyH+PiMWw0+FjN1+lWtjTZmVOk+nUf5MG2YNuJTJ2pbtyslBYfrrCx+Tbm1i+6/k+ vT0XPbNzxe98Ox53FByw8fSCLG/r/DQcrRugYVyVq+vJXOeQLlnVH52ZDu2TpKjFxk8P zrov+AQ277aJmWzONeUS6xBhiu8j3F5g3nDUZv9zMdot3nIwRBSfEfIHZyQaxr2U2WT2 uixCS/wxyRkw4WhfL21r0+hBkhw5/5ifToK6bnvfGLaQ+rfFMdaeeAB0KWZVsA1Pubnr qf4g== 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:mime-version:content-transfer-encoding; bh=IMd2wxbWSskBrQ2C+X7YA5Ufqq005IN1/YwGk6ozQGg=; b=jClJELVnbNn9WFa57quCcrEdePF9VboUqLGgeNSswnPO0kBr5I2PYrnF3iPz6effq7 Os0BdV4dTsGdczkAuzEXsnWHeecvripPVZ/oOlYBjhlv0K3jPZKna3Q09ODZ+VMZnOal jja9tM6vCObPOGBEg23fohdDlAiE2sLiqvZt9GBMW2o4BOu2dzEoMuQGQNCsY4163IWs nZpB2EdTkPAXW8Wf505EkQu/sML642UPQQ7eN1+fyVfbO64a1mAlaHNIi734WVQKZaEB 3mVpJpAiSVZ6erjGlZniD7VP5SsR5cMvxlptJihAGgraICpzID0OfU3hS0CanKOlVyXs ZRtQ== X-Gm-Message-State: AOAM531YZuasp5rAiv+yBvAVqP+/k3ZcSLZMvSEF2ssy3BI0+JY3mQIy hX2MfM4BXZedq8YsMGmv8xte4w== X-Google-Smtp-Source: ABdhPJz2khhedvAGxqkeK5cUNSNg/eSDC0o9IXllj+NsVS2MWD18lzl8cv2QMY2GEcKzuAdlruZGow== X-Received: by 2002:a63:144d:: with SMTP id 13mr827354pgu.153.1601310936257; Mon, 28 Sep 2020 09:35:36 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id f19sm2345640pfd.45.2020.09.28.09.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 09:35:35 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 20/25] coresight: cti: Increase reference count when enabling cti Date: Mon, 28 Sep 2020 10:35:08 -0600 Message-Id: <20200928163513.70169-21-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928163513.70169-1-mathieu.poirier@linaro.org> References: <20200928163513.70169-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200928_123538_154347_75049605 X-CRM114-Status: GOOD ( 14.96 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tingwei Zhang CTI device is enabled when associated coresight device is enabled. Increase the module and device reference count for CTI device when it's enabled. This can prevent CTI device be removed or module be unloaded when CTI device is enabled by an active trace session. Signed-off-by: Mike Leach Signed-off-by: Tingwei Zhang Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 711beb92166a..546c97045afe 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -241,19 +241,30 @@ coresight_control_assoc_ectdev(struct coresight_device *csdev, bool enable) { int ect_ret = 0; struct coresight_device *ect_csdev = csdev->ect_dev; + struct module *mod; if (!ect_csdev) return 0; if ((!ect_ops(ect_csdev)->enable) || (!ect_ops(ect_csdev)->disable)) return 0; + mod = ect_csdev->dev.parent->driver->owner; if (enable) { - ect_ret = ect_ops(ect_csdev)->enable(ect_csdev); - if (!ect_ret) - csdev->ect_enabled = true; + if (try_module_get(mod)) { + ect_ret = ect_ops(ect_csdev)->enable(ect_csdev); + if (ect_ret) { + module_put(mod); + } else { + get_device(ect_csdev->dev.parent); + csdev->ect_enabled = true; + } + } else + ect_ret = -ENODEV; } else { if (csdev->ect_enabled) { ect_ret = ect_ops(ect_csdev)->disable(ect_csdev); + put_device(ect_csdev->dev.parent); + module_put(mod); csdev->ect_enabled = false; } }