[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200914180805.GC3238264@xps15>
Date: Mon, 14 Sep 2020 12:08:05 -0600
From: Mathieu Poirier <mathieu.poirier@...aro.org>
To: Tingwei Zhang <tingwei@...eaurora.org>
Cc: Suzuki K Poulose <suzuki.poulose@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Mike Leach <mike.leach@...aro.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Leo Yan <leo.yan@...aro.org>,
Randy Dunlap <rdunlap@...radead.org>,
Russell King <linux@...linux.org.uk>,
Kim Phillips <kim.phillips@....com>,
Mian Yousaf Kaukab <ykaukab@...e.de>, tsoni@...eaurora.org,
Sai Prakash Ranjan <saiprakash.ranjan@...eaurora.org>,
Mao Jinlong <jinlmao@...eaurora.org>,
coresight@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v10 20/24] coresight: cti: increase reference count when
enabling cti
On Fri, Aug 21, 2020 at 11:44:41AM +0800, Tingwei Zhang wrote:
> 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 <mike.leach@...aro.org>
> Signed-off-by: Tingwei Zhang <tingwei@...eaurora.org>
> ---
Reviewed-by: Mathieu Poirier <mathieu.poirier@...aro.org>
> 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
>
Powered by blists - more mailing lists