From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5C8EC433E2 for ; Mon, 14 Sep 2020 18:10:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91394214F1 for ; Mon, 14 Sep 2020 18:10:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vJxbTWUo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726091AbgINSIs (ORCPT ); Mon, 14 Sep 2020 14:08:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgINSIJ (ORCPT ); Mon, 14 Sep 2020 14:08:09 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EA49C061788 for ; Mon, 14 Sep 2020 11:08:08 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id j34so428032pgi.7 for ; Mon, 14 Sep 2020 11:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HiLz1RcLzusQXgfz36ooDNe/17JxLFBNTfE6VhS7a/0=; b=vJxbTWUocKX1FfLqSSVE7HKpizU2MWTMXsREQ2ChXEtrFCqDRhITBkAWu4HmDSFMxl O88TRzaUjISbqIb0paYVueJyG2N1gLmfwTWvi76PBn28KSd+Un42/vnZ6KrckS9SgBR5 rcvKGCxaXEmFpcSYlMyK9vss1dBeiHjeWrd3X0uh+DcutEDaL4owZJ9hlEZYreETLcR7 kAAKc693Ig1qejFLE2FFyyLxXbwrDg5UMfnfbDedEzNZayKTrzrTLIyPfm+mqLc+ulWL M4bHGwOpYFtnzkymQ8EMeNRsIdafzU75yc35/szbUXEVnJR6wvSvwly5kB6kZB5+fa+e b7Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HiLz1RcLzusQXgfz36ooDNe/17JxLFBNTfE6VhS7a/0=; b=qA4uJdB7IYmzguVt+zxWA5rVb3sULTwFwyPn0uExLiVeskbHekLU8cBrlnMjQJvDFa hMBgqNWQEoRjNlCK0rV+0tPQ5SdTlOAX7C9uhORjVaS60PcEACuxxkt6mVd+Rs6DbQer Ovy2rsKflD8GPs26XkATaJ6hx42YuFpU6fhLbqKVnLATfWpYPvPROjfyy7BnadutQ0Ax oEruk0ZVY6jiqYx6stnzQa1Yc5cJxCKVmbqbsPt5Kdrd8uXL3a5XvAw0iB7yPtrDBGRp vOR89j0e8v+KJ4qMzifGZtW2VFAdpn2YqGvyINgyH1Xk6T13INAxrbvzKUF2KSESXQqL vd7A== X-Gm-Message-State: AOAM533da1OoxyomCntvaymt3IlWFzpcWz+jGwK6f1BqIfFLHsadz3Yd XwIJ7hoQ84V5ZFE5ALlxci21UA== X-Google-Smtp-Source: ABdhPJwUskmYuzX/7PmB2Mv7QAdxGmL0bmHu5FbDXd984uW2TNPzmWobyxIfbcqU1vQzbjC0zKh12g== X-Received: by 2002:aa7:9f04:0:b029:13e:d13d:a13b with SMTP id g4-20020aa79f040000b029013ed13da13bmr13543279pfr.35.1600106888120; Mon, 14 Sep 2020 11:08:08 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j20sm10938084pfh.146.2020.09.14.11.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 11:08:07 -0700 (PDT) Date: Mon, 14 Sep 2020 12:08:05 -0600 From: Mathieu Poirier To: Tingwei Zhang Cc: Suzuki K Poulose , Alexander Shishkin , Mike Leach , 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: Re: [PATCH v10 20/24] coresight: cti: increase reference count when enabling cti Message-ID: <20200914180805.GC3238264@xps15> References: <20200821034445.967-1-tingwei@codeaurora.org> <20200821034445.967-21-tingwei@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200821034445.967-21-tingwei@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Tingwei Zhang > --- Reviewed-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 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 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14035C433E2 for ; Mon, 14 Sep 2020 18:09:44 +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 ACAD42076C for ; Mon, 14 Sep 2020 18:09:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="27k86umW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vJxbTWUo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACAD42076C 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+linux-arm-kernel=archiver.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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vxs8LA9Rb6jzBqPMwbC7Tc3APAxDThTRJUCAOxmBqK8=; b=27k86umWsctko/vQwymClD1r5 w70Xg+ZgCU4iJjQ8iBiEfXngV3X29I+L+gcZS/jhcEF363W4EvCjPdtXzien2MZtZHW9GHAbMokov mH8qnEKE7VZX+FJ2kUTD/gwCjW+2Z3zcixT7F2JCSk4C53rTjWVcfpnFzgwoCJGEwIFI0IpVLUctV epL1niH3BkMXdGl/NI0dWeevRVczBga3UFxd976NMHVBJV2NwnLNs29/Sc3s11XCB+hxW85yuYEje ALF+zmLTWzkmJo3VG5mv2Xuac7b9uTiMusSzHBBkE5T3fGn54VY7BvHBeHRpHkqiqvFzdTn7su6TP YzYpnVfCA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHstg-0000YG-DR; Mon, 14 Sep 2020 18:08:12 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHste-0000XT-1v for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 18:08:10 +0000 Received: by mail-pg1-x543.google.com with SMTP id g29so455448pgl.2 for ; Mon, 14 Sep 2020 11:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HiLz1RcLzusQXgfz36ooDNe/17JxLFBNTfE6VhS7a/0=; b=vJxbTWUocKX1FfLqSSVE7HKpizU2MWTMXsREQ2ChXEtrFCqDRhITBkAWu4HmDSFMxl O88TRzaUjISbqIb0paYVueJyG2N1gLmfwTWvi76PBn28KSd+Un42/vnZ6KrckS9SgBR5 rcvKGCxaXEmFpcSYlMyK9vss1dBeiHjeWrd3X0uh+DcutEDaL4owZJ9hlEZYreETLcR7 kAAKc693Ig1qejFLE2FFyyLxXbwrDg5UMfnfbDedEzNZayKTrzrTLIyPfm+mqLc+ulWL M4bHGwOpYFtnzkymQ8EMeNRsIdafzU75yc35/szbUXEVnJR6wvSvwly5kB6kZB5+fa+e b7Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HiLz1RcLzusQXgfz36ooDNe/17JxLFBNTfE6VhS7a/0=; b=gc2Dwy+BKrNaeyKrd2KptyDjJ/Vty5/0QEqhqVtxhFhxquxZg3Sp9FvrEEZGIYLqDv IfznYTyfGoW/Ukn79j/oU43Cdw4AR34LMt+XzlOPgjvhwSICiN4GM18VlyM5IK2kHv5t jUir7twJ2bpfYv+AUmVTmq5P92VLh6NXhbQ8E2WHEZ/G0j3AAZAjhQDZBHqsdfRWrCsf K/Oj3VK4yYjMV5UjTnw72qovk3Jo0cUb9LnXecGO2mQWSW+B0S07viu6yMPahzutAuaA UrTkRb6RvgZRfrXNF2G2bkAygqivRciuhsBtqUh2IOOJkFLTv7NGZuTclUkBKSZoJNdP 0YDw== X-Gm-Message-State: AOAM533sfxNkqkucW9CJIXtcOrnOl6B6M4A077Ok7VKHk/IXuLsqdXyx 8NOS3K5UrN+wNbh3F4omXP/7hA== X-Google-Smtp-Source: ABdhPJwUskmYuzX/7PmB2Mv7QAdxGmL0bmHu5FbDXd984uW2TNPzmWobyxIfbcqU1vQzbjC0zKh12g== X-Received: by 2002:aa7:9f04:0:b029:13e:d13d:a13b with SMTP id g4-20020aa79f040000b029013ed13da13bmr13543279pfr.35.1600106888120; Mon, 14 Sep 2020 11:08:08 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j20sm10938084pfh.146.2020.09.14.11.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 11:08:07 -0700 (PDT) Date: Mon, 14 Sep 2020 12:08:05 -0600 From: Mathieu Poirier To: Tingwei Zhang Subject: Re: [PATCH v10 20/24] coresight: cti: increase reference count when enabling cti Message-ID: <20200914180805.GC3238264@xps15> References: <20200821034445.967-1-tingwei@codeaurora.org> <20200821034445.967-21-tingwei@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200821034445.967-21-tingwei@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_140810_104488_1EE1C7CB X-CRM114-Status: GOOD ( 22.01 ) 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: tsoni@codeaurora.org, Sai Prakash Ranjan , Kim Phillips , Mao Jinlong , Suzuki K Poulose , Alexander Shishkin , Greg Kroah-Hartman , coresight@lists.linaro.org, Randy Dunlap , Mian Yousaf Kaukab , Russell King , linux-kernel@vger.kernel.org, Leo Yan , linux-arm-kernel@lists.infradead.org, Mike Leach Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > Signed-off-by: Tingwei Zhang > --- Reviewed-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 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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel