Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp20884imm; Tue, 5 Jun 2018 14:15:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIc9cz+jJEDMjGahQZPMMkD8faqW8zI9GPVWGo7XUF5nRycLOZO3qF4kzWzSEwgbJHsWfWL X-Received: by 2002:a63:7d51:: with SMTP id m17-v6mr198869pgn.245.1528233332776; Tue, 05 Jun 2018 14:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528233332; cv=none; d=google.com; s=arc-20160816; b=ipZNKcdu+0jsNV499hXGhci0HLIdp/xas13xCCuoPaJbgNH77xOUUevUQQfwJJ+AL2 +AmbnjMzHSpHIVEQ9AtUi0qmTTNZMZQLyQGzkPaDzUFkkfJhjUOuNi+FbHTRk3Yn9Y4h gs1H2oynTIV3qH36ENKkR23WD5EFLYaM+h4y4PMJTlhkJfNNXo2/Fg0m4w1+1EvAJ15u vq5mRLzWF/GesMTQIEQxQTzy5iSwvsVrJKIBQycHjd/azZcD9EpFWAsuUkml6zikNjS9 hJSBA/8pD/dDy2tVdHe3IZGcxmdgOsuASzroD/zl/+oVYbYlCDgFTNzN2EXCsyGXLbkY 2Feg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=n7vMsnVdVJE2moStHbC1tiOcF553++gngM0zKKeFQQc=; b=UxHBLl8sSp6kAjm7Jqz06WtHOXXal9ECQ5EZwTd/GsRxa4nTY8HTmwScVGFPcld2iC LZW95azgm/TAHGvJH78vpLGQEoRGXJZ8XgmMcWNU3+Zw9mXsUSJ6Wx0oFrwunIVYNoAV bLLNmPhnuTC/r1JSa5ymQdSNL+s1Z9VDA5sd7q0qxYhUyA4fs+yL/v/+SpGWMXPVQ456 DmODWhOcTHfkg2lJXqlYCk8KCM2rIkNjRNmi8wkNFD3I+EcqVk7fFvwrxQycxJ1Glcg/ xN9CIpyL/hIIyBaKQiWIXygLunG8ddbmYVa5M6RorD8omwBZqpzqM0EM7+IuiYzw5C74 xvWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14-v6si7054054pgt.185.2018.06.05.14.15.18; Tue, 05 Jun 2018 14:15:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752467AbeFEVOv (ORCPT + 99 others); Tue, 5 Jun 2018 17:14:51 -0400 Received: from foss.arm.com ([217.140.101.70]:34034 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666AbeFEVOu (ORCPT ); Tue, 5 Jun 2018 17:14:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DCD211435; Tue, 5 Jun 2018 14:14:49 -0700 (PDT) Received: from [10.37.8.39] (unknown [10.37.8.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8195F3F59D; Tue, 5 Jun 2018 14:14:44 -0700 (PDT) Subject: Re: [PATCH v4 05/14] coresight: get/put module in coresight_build/release_path To: Kim Phillips , Mathieu Poirier Cc: Leo Yan , Greg Kroah-Hartman , Alexander Shishkin , Alex Williamson , Andrew Morton , David Howells , Eric Auger , Eric Biederman , Gargi Sharma , Geert Uytterhoeven , Kefeng Wang , Kirill Tkhai , Mike Rapoport , Oleg Nesterov , Pavel Tatashin , Rik van Riel , Robin Murphy , Russell King , Thierry Reding , Todd Kjos , Randy Dunlap , linux-arm-kernel , Linux Kernel Mailing List References: <20180605210710.22227-1-kim.phillips@arm.com> <20180605210710.22227-6-kim.phillips@arm.com> From: Suzuki K Poulose Message-ID: Date: Tue, 5 Jun 2018 22:14:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180605210710.22227-6-kim.phillips@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/05/2018 10:07 PM, Kim Phillips wrote: > Increment the refcnt for driver modules in current use by calling > module_get in coresight_build_path and module_put in release_path. > > This prevents driver modules from being unloaded when they are in use, > either in sysfs or perf mode. > > Cc: Mathieu Poirier > Cc: Leo Yan > Cc: Alexander Shishkin > Cc: Randy Dunlap > Cc: Suzuki K Poulose > Cc: Greg Kroah-Hartman > Cc: Russell King > Signed-off-by: Kim Phillips > --- > drivers/hwtracing/coresight/coresight.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c > index 338f1719641c..1c941351f1d1 100644 > --- a/drivers/hwtracing/coresight/coresight.c > +++ b/drivers/hwtracing/coresight/coresight.c > @@ -465,6 +465,12 @@ static int _coresight_build_path(struct coresight_device *csdev, > > node->csdev = csdev; > list_add(&node->link, path); > + > + if (!try_module_get(csdev->dev.parent->driver->owner)) { > + dev_err(&csdev->dev, "could not get coresight driver module\n"); > + return -ENODEV; > + } > + Kim, It would be safer to do the check before we actually add the device to the path above. That way, we don't add an unavailable device to the path, which will be "released" in the release_path below. Otherwise looks good to me. > pm_runtime_get_sync(csdev->dev.parent); > > return 0; > @@ -510,6 +516,9 @@ void coresight_release_path(struct list_head *path) > csdev = nd->csdev; > > pm_runtime_put_sync(csdev->dev.parent); > + > + module_put(csdev->dev.parent->driver->owner); > + > list_del(&nd->link); > kfree(nd); > } > Suzuki