Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp995426pxa; Wed, 19 Aug 2020 22:54:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHYmhyyDfLo8BySwqTVYhao9A1kc3G5TqljIIbrSSIDis/PO/p5KJjGZEmBkPE++sXsZO0 X-Received: by 2002:a05:6402:1e2:: with SMTP id i2mr1374557edy.70.1597902866719; Wed, 19 Aug 2020 22:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597902866; cv=none; d=google.com; s=arc-20160816; b=Zmg/6zXTSoe97hlBSUcKNeqPtLJ3VhGU829BUHHucyO2zmj3d9Lp7aa1YiWJMBVLG/ D1L03r4L/Ox6GIviBGkpFe3q5TOM/uRVTaN6rR2AFuiTftrUppCiEjnk9Rd9/MVRzgM6 a254kGdq9C9z0DjUs4B+PgIkHSsa1utdzN8kt0H3GnoRMFMpW+eDFSuRazPXMPOuvW43 VQmY+hB0ABQapJX2Ti6iKpcxC4XMYGRp8LO9hI4sMGGJrHTu3i5bsGGl//iCImrWrh+T ifeuXSflA+M3ND1azosCO+lyS84gott9xNT8cL4LfqMccDkKn5ysE+/ydjt472IQo8lf 9EGg== 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=iMEZAZE9XpMeptQcqaunn1/DAUq6rIJz7R4yGR769wBTNrAWaRMMbkX8Hlh4UXAtKm Rhh7D2mnKfB+dN/bmxnmSgTTbeUAfKXfLVfSg+QuJG4cI0BEVu2w9OWEBTjEQW1I7i+I R47jujYKB7enhUm2sQUdLCbceIYv3F6FrwJiDm3x+mEdwFMfrK5Ro6D315QooiaLiWLa Ch0KVvAvsTekkSt5CHws8dNSLKwLVBWetXFyOn+9QaA6uDIzH4JeO0GGr2KbDsoiK9Wt M4TnjZSoX/VEyDyFs9in1eHnwte2lw6f/kR8BSBJXbooKdK9PuUQRjY40UON7XFWaSJh wn5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b="qgE/0xC/"; 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 n1si585674ejc.134.2020.08.19.22.54.03; Wed, 19 Aug 2020 22:54:26 -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="qgE/0xC/"; 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 S1727798AbgHTFvJ (ORCPT + 99 others); Thu, 20 Aug 2020 01:51:09 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:38047 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726816AbgHTFvE (ORCPT ); Thu, 20 Aug 2020 01:51:04 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597902664; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=NR00TQF2Q5NvhlGOYyoA7Yqsrftx/gbgVvITw5cWsW0=; b=qgE/0xC/T/PJk03QmO4Er9UEUlovwo/nqT6FLiuIqcBdEDcrqp/Gb6hDMEsY8hoicLm5gFqT YE8iYYavIFQlyWVHi/rEQy1AMYAlYvPxVaeufn2469Eziv3SHF3f6dvI+fQlZwaMSaoHvCK5 +1hY+hKMqxXlWeeEtXBK5L7nUgk= 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-n05.prod.us-west-2.postgun.com with SMTP id 5f3e0f48c651aed294ec68b7 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 20 Aug 2020 05:51:04 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 5166AC43387; Thu, 20 Aug 2020 05:51:03 +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 029B1C4339C; Thu, 20 Aug 2020 05:50:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 029B1C4339C 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 v9 20/24] coresight: cti: increase reference count when enabling cti Date: Thu, 20 Aug 2020 13:47:14 +0800 Message-Id: <20200820054718.20115-21-tingwei@codeaurora.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20200820054718.20115-1-tingwei@codeaurora.org> References: <20200820054718.20115-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