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: 61044 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp985489lbb; Tue, 2 Feb 2016 13:16:06 -0800 (PST) X-Received: by 10.66.101.36 with SMTP id fd4mr51042541pab.76.1454447766128; Tue, 02 Feb 2016 13:16:06 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id qm16si4033734pab.112.2016.02.02.13.16.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Feb 2016 13:16:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org 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-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c00:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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+patch=linaro.org@lists.infradead.org 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(+) -- 2.1.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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);