Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1746529pxa; Thu, 20 Aug 2020 20:50:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBfBWkMYS7+4A35ajjT6IvinXZRBMoljv9kaJYrBQktZX1BW1ddK7oBG0eHB8z06G9pdD/ X-Received: by 2002:a05:6402:b45:: with SMTP id bx5mr1011099edb.22.1597981803355; Thu, 20 Aug 2020 20:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597981803; cv=none; d=google.com; s=arc-20160816; b=QiE7UeL7uYOo6Z6xKs9TmaHLeIS1aNB9Izoln9g+hMrtG+u/3VpFekaZzV9Gx1S5jo my+1hbZ2BCCb7+vMuIEm8qCvU+EhFhcUlp+VIVUHtm2HQwrTGxfCWbx8yekPEHs3Sk9q 7H9csC1PZF7louZ/KKzoIc9yPeOlj89Wq+9wFbZoPTANtz7maWi9pEIGlzL7hGjVIJjP 8GAtiCiCPlQ8W+gxE/V3y7Z5yyIz6J2AmGm4HmypE7R7UvZW4OO9w9ge0Zu3aTt8IDC0 gApzbAg7G8aQCeX4fHiKwttt+TcFn0O0AmGrAxJaH0tujv4S1smxpnMGShwnT4WUPuhO Y7dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=NR00TQF2Q5NvhlGOYyoA7Yqsrftx/gbgVvITw5cWsW0=; b=DiKiHuGSU9lRXcVm3rO5QcLUZhORe2L3yLtSCGzqNwFy9pzuK5F6v29eGwJfgE4KcS 7hlhI59yoP/stU19jZGb4QYMlYIv38bUUNOl7qFhsNbqin8L5yh9FnBIe3ewx8uaJFCw ttQbegbenPNxaLMTe6NLoeVkbkLXSkPKx+wpH7FkEueFXXDQTzb/9/26R4UQfG+LsUE0 D6GGCejulHyuDF3s31XejXNEkEvJxivUKTu1/J7yjwPK3l4OFtLbf0onWpLc/AtOXOLF Lupi5bIu5EMD73KAOzGzj3Y1YwFtYqMy/r4K/xwnsMkGwgV+b/6NEYAhoHHAcAdpKW6q od8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=OKwkvFPJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lm15si371252ejb.129.2020.08.20.20.49.40; Thu, 20 Aug 2020 20:50:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=OKwkvFPJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbgHUDsv (ORCPT + 99 others); Thu, 20 Aug 2020 23:48:51 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:30017 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727074AbgHUDsu (ORCPT ); Thu, 20 Aug 2020 23:48:50 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597981729; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=NR00TQF2Q5NvhlGOYyoA7Yqsrftx/gbgVvITw5cWsW0=; b=OKwkvFPJI/x/jg7U6tvTCqx86hzi2driJIUzfb7LgukUFIr4koLEOy8K7fEY/0nWxnnt2OLS PzUqp7lBvQOgrkGlQs7qyPKtsN+LTBpxoz8RJXiOfpwTF/Lr/2qeMU7RB35+yk827XMa4DdW KX72voDHimZecAXUgwed/2DtEcY= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 5f3f44130dab4fdee212e817 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 21 Aug 2020 03:48:35 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8B504C433A0; Fri, 21 Aug 2020 03:48:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from tingweiz-gv.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tingwei) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4C208C433C6; Fri, 21 Aug 2020 03:48:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4C208C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=tingwei@codeaurora.org From: Tingwei Zhang To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Mike Leach Cc: Tingwei Zhang , Greg Kroah-Hartman , Leo Yan , Randy Dunlap , Russell King , Kim Phillips , Mian Yousaf Kaukab , tsoni@codeaurora.org, Sai Prakash Ranjan , Mao Jinlong , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 20/24] coresight: cti: increase reference count when enabling cti Date: Fri, 21 Aug 2020 11:44:41 +0800 Message-Id: <20200821034445.967-21-tingwei@codeaurora.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20200821034445.967-1-tingwei@codeaurora.org> References: <20200821034445.967-1-tingwei@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 d354fd57474e..6c9f6930b8b8 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; } } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project