From patchwork Tue Jun 5 21:07:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 10449261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 65C4960234 for ; Tue, 5 Jun 2018 21:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57E6F29C82 for ; Tue, 5 Jun 2018 21:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BDD329CB7; Tue, 5 Jun 2018 21:14:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF21029C82 for ; Tue, 5 Jun 2018 21:14:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=NSLHGii0KaRMY7xzF58sCam83WkqemyLX+vv/QXAi38=; b=VRJZe1odh4sJZkt2WCPMbT8bTy OjLXl7jh8ZM+uMxUZPMvnuvGLLx9F2Q9ps1QxiEtSBltkW+B544ndNXbnhDLrk8D/t1T+skGfF9YT mqcvk3g2mbhXLPgzkctQa9MyL6ZFmxPQFBXSqRuXde52CyoDQOQtbdIDhkzWCAcKZHpjsg94cMy4A gbA664BmrJ7X0IkBM9UP1/Q/7dsssseZuDGkGyBlsjiZmlDcoEAdVc/xkXjZSVJhupZcaVgRI2zQg lDv5Ijvcv+mJzpt8r6JiXOdQspxAuy8m7m6FA3m86NA88LE2K3UL7gBog1f3xdkcijJkJ5rf/Aofb YQ4rIqzA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQJHO-0004Bg-Ge; Tue, 05 Jun 2018 21:14:10 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQJBP-0007sy-PV for linux-arm-kernel@lists.infradead.org; Tue, 05 Jun 2018 21:08:20 +0000 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 2C0CE164F; Tue, 5 Jun 2018 14:07:39 -0700 (PDT) Received: from localhost.localdomain (unknown [10.118.17.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 154563F59D; Tue, 5 Jun 2018 14:07:38 -0700 (PDT) From: Kim Phillips To: Mathieu Poirier Subject: [PATCH v4 05/14] coresight: get/put module in coresight_build/release_path Date: Tue, 5 Jun 2018 16:07:01 -0500 Message-Id: <20180605210710.22227-6-kim.phillips@arm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180605210710.22227-1-kim.phillips@arm.com> References: <20180605210710.22227-1-kim.phillips@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180605_140759_990986_5BF5A80C X-CRM114-Status: GOOD ( 12.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kefeng Wang , Kim Phillips , Geert Uytterhoeven , Alexander Shishkin , Gargi Sharma , David Howells , Russell King , Pavel Tatashin , Thierry Reding , Rik van Riel , Suzuki K Poulose , Eric Auger , Alex Williamson , Mike Rapoport , linux-arm-kernel , Greg Kroah-Hartman , Randy Dunlap , Oleg Nesterov , Linux Kernel Mailing List , Kirill Tkhai , Eric Biederman , Leo Yan , Andrew Morton , Robin Murphy , Todd Kjos MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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; + } + 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); }