From patchwork Tue Feb 2 21:13:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 8195631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 089B4BEEE5 for ; Tue, 2 Feb 2016 21:16:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 283CF202BE for ; Tue, 2 Feb 2016 21:16:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 521A82027D for ; Tue, 2 Feb 2016 21:16:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQiHy-0001fw-Gi; Tue, 02 Feb 2016 21:15:06 +0000 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQiHU-0001D9-2H for linux-arm-kernel@lists.infradead.org; Tue, 02 Feb 2016 21:14:36 +0000 Received: by mail-pf0-x232.google.com with SMTP id n128so533928pfn.3 for ; Tue, 02 Feb 2016 13:14:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vIspG+jybIRhwMZWWbYbIvfuYBlawUQRnPLAG/C+KKU=; b=QywKbavJk9ifKNuqcA/ZnT8rORCzkq6pvYogrJZZYq8Wrs9ngv5J75wDzwVJBQMnRF zT/UFk9vRFZjCmj3DR2kK45dCD/ApWvvqizJaiugbVftCTOpmRIR9XR0ibU/zQi4HaHU pPYwzWiPXVmxT9nJoWsLqApmp2E/MWTFU00aM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vIspG+jybIRhwMZWWbYbIvfuYBlawUQRnPLAG/C+KKU=; b=VOfawBK7ewb6Vyb3ONl46JEG0QiKOEMnRech/3dkpRjPyLlU4MSusjxAsbHZJUrlGS 1eADhXxBiyS9lik2a+4T7/Ch2hFcz/MwBLEEAEuJrLegbFSLOOePg45z4+g84mok1AgU SPelw38rqRs5rVJB6zdhSwIkVM2PlPhTmKKl0u5eJA/TYYRNsU5ekJdY7bkUVTZOGCKa lZw9cQxqJVKpTBzwNgcLSh04MLkNKSoDdDDhKVWlFCarm1aahfH/daTnhihzXDv1OEFT 6SvxzlTXpBTpr3w5RGnsooqzEiAZtFP09U5+h4Y6ePr96CtrDCVjZEojmg1MSNbg/sjr WZOg== X-Gm-Message-State: AG10YOQ1RIWg6aPMvEs6beHePaaDbrdWXida7nkRzyZd/Jbe7Du0vr413gMOvvHnD12nIc1Y X-Received: by 10.98.8.153 with SMTP id 25mr43990959pfi.51.1454447659646; Tue, 02 Feb 2016 13:14:19 -0800 (PST) Received: from t430.cg.shawcable.net ([184.64.168.246]) by smtp.gmail.com with ESMTPSA id 79sm4769141pfr.22.2016.02.02.13.14.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Feb 2016 13:14:19 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 5/7] coresight: remove csdev's link from topology Date: Tue, 2 Feb 2016 14:13:59 -0700 Message-Id: <1454447641-29153-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454447641-29153-1-git-send-email-mathieu.poirier@linaro.org> References: <1454447641-29153-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160202_131436_174245_8F755074 X-CRM114-Status: GOOD ( 15.32 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In function 'coresight_unregister()', all references to the csdev that is being taken away need to be removed from the topology. Otherwise building the next coresight path from source to sink may use memory that has been released. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight.c | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index a35ca54a76c9..7e6e9ff27dd1 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -579,6 +579,50 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev) } } +static int coresight_remove_match(struct device *dev, void *data) +{ + int i; + struct coresight_device *csdev, *iterator; + struct coresight_connection *conn; + + csdev = data; + iterator = to_coresight_device(dev); + + /* No need to check oneself */ + if (csdev == iterator) + return 0; + + /* + * Circle throuch all the connection of that component. If we find + * a connection whose name matches @csdev, remove it. + */ + for (i = 0; i < iterator->nr_outport; i++) { + conn = &iterator->conns[i]; + + if (conn->child_dev == NULL) + continue; + + if (!strcmp(dev_name(&csdev->dev), conn->child_name)) { + iterator->orphan = true; + conn->child_dev = NULL; + /* No need to continue */ + break; + } + } + + /* + * Returning '0' ensures that all known component on the + * bus will be checked. + */ + return 0; +} + +static void coresight_remove_conns(struct coresight_device *csdev) +{ + bus_for_each_dev(&coresight_bustype, NULL, + csdev, coresight_remove_match); +} + /** * coresight_timeout - loop until a bit has changed to a specific state. * @addr: base address of the area of interest. @@ -717,6 +761,8 @@ EXPORT_SYMBOL_GPL(coresight_register); void coresight_unregister(struct coresight_device *csdev) { + /* Remove references of that device in the topology */ + coresight_remove_conns(csdev); device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister);