From patchwork Wed Jul 29 19:52:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11691637 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26754722 for ; Wed, 29 Jul 2020 19:54:19 +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 F38842064B for ; Wed, 29 Jul 2020 19:54:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Zpbrl5yl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rhrDB1da" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F38842064B 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+patchwork-linux-arm=patchwork.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: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=tMIOyGpHyXUajm11ZogWR8jWl4/zn+G0SxqAPzqxkfY=; b=Zpbrl5ylWx2pLQSN+8yKY9ihud JzauaZrhBdc9F5R4Ju/zC1ZpBfwl49epnWCcQWptGF4Sd3pXZgNEiRM5sFiE6M/nz4RMP4diGW4LO TsCmXNfphmuF0SCD0JqSwNaxFQUs73sy0KO2HhTEx5pwcX71zQnLpZG+sW1qEp4Kby9D4TNWwJ6+y WuLEEYmpV08u6InTfWk+JFqQnWk+bbXAwjs0Jj2+MhOYpi7qzhsScky8NYUBrWNgC6/Y94tlN4QWq 6XS3S+EkcVEyqh6nZVNzlBoToE7R6eyYLpxhmq/nCPwbEqo/fO7NPy5z2bcni/KSoZmVux+nSrLYK OLP9RIqw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0s8C-0000qN-VC; Wed, 29 Jul 2020 19:52:52 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0s83-0000m8-RJ for linux-arm-kernel@lists.infradead.org; Wed, 29 Jul 2020 19:52:44 +0000 Received: by mail-wr1-x441.google.com with SMTP id a5so12776797wrm.6 for ; Wed, 29 Jul 2020 12:52:43 -0700 (PDT) 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=lWvG+TCROoTl5u/0cbIaCYcxFNRoyvs7UHh0cbm/xFE=; b=rhrDB1daZiLVIvIOFre+9ppfdBz9NGRr6IhdzeKc3o28k5Dt0ylzpSJICq1ZSG4SBp 76xPskWPSJGKHhrWXKruM0hFpwzwTssQyParJeqezSpkzoKn5HD6nZoyZ8Ih1qw4+f6X pxDP7BeEBBU4J4yKwzwOvP2uDF4l25IHRtZjPmueHv1a45ddmhLWCF3YPnbdgoF2HWnu tilmcby9+MNbaHFsUfGqq0AZ6cEFujotlfX4STKqiLpWwRpHpPb2wxfv7TpUuhcgp5yM fZC5a4V8bAyJXqx8s+0cQ+jzcyejiKck73LuHUkS0nZKWe9QdfvpV0iq/HF2OPZPmR0l 3Cxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lWvG+TCROoTl5u/0cbIaCYcxFNRoyvs7UHh0cbm/xFE=; b=oyBGl/GZqCvp1vv5ddD3pS2fsm/X+qUIASO2iRlz9PxY+0e/P2le/xbZ5+kaiPIKRK i8j7LDv5Uernng00RrAbYBGc7533gKPYjWwFsvyhT9XO7uFy50DUKxQKC4NXd2sp7wzc W0oXIX6dg3lf7Y71URLKLBrj/wk90exE4LYhadn2fAHs1R7ErlBpZuHbD9dGZg5rtwa1 d62L2wTJQ3tyW8GCr7Ek6vQKBcJ1EXsGD42kuFIPE2v1s2//7N1KZErYK62Q7WB/zYvv PKEIsQsWV712cbBDGTVpdkT66CqnFS01mE9oD3pZgj/462bpI1nZ+uvYWzPpK6LiN9s4 wocQ== X-Gm-Message-State: AOAM531b5qJiMOtTKBFX5W4GaWt3ZV819tyJHrhd22f6C2Btv+vcu2mW kzsTCV90pOvgWKAzkupWQI3h1MgHA+Cxaw== X-Google-Smtp-Source: ABdhPJwg1VSPWEyhTKdGvOz2dsEsrm/MPwJuq8ps0dw53Qbs0oLWg2tAhfZE6GVrIcPnaCTOtUAPDw== X-Received: by 2002:adf:b356:: with SMTP id k22mr85129wrd.424.1596052362272; Wed, 29 Jul 2020 12:52:42 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:c16b:5bd3:48a4:60b4]) by smtp.gmail.com with ESMTPSA id p8sm7713815wrq.9.2020.07.29.12.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 12:52:41 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org, tingwei@codeaurora.org Subject: [PATCH 1/1] coresight: cti: Fix bug clearing sysfs links on callback Date: Wed, 29 Jul 2020 20:52:33 +0100 Message-Id: <20200729195233.30369-2-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200729195233.30369-1-mike.leach@linaro.org> References: <20200729195233.30369-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_155243_930947_AAC219A7 X-CRM114-Status: GOOD ( 18.31 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 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: Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org During module unload, a coresight driver module will call back into the CTI driver to remove any links between the two devices. The current code has 2 issues:- 1) in the CTI driver the matching code is matching to the wrong device so misses all the links. 2) The callback is called too late in the unload process resulting in a crash. This fixes both the issues. Fixes: 177af8285b59 (coresight: cti: Enable CTI associated with devices) Reported-by: Tingwei Zhang Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight-core.c | 4 ++-- drivers/hwtracing/coresight/coresight-cti-core.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index a11288fbb160..c849c2afbcfb 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1254,8 +1254,6 @@ static void coresight_device_release(struct device *dev) { struct coresight_device *csdev = to_coresight_device(dev); - if (cti_assoc_ops && cti_assoc_ops->remove) - cti_assoc_ops->remove(csdev); fwnode_handle_put(csdev->dev.fwnode); kfree(csdev->refcnt); kfree(csdev); @@ -1580,6 +1578,8 @@ void coresight_unregister(struct coresight_device *csdev) { etm_perf_del_symlink_sink(csdev); /* Remove references of that device in the topology */ + if (cti_assoc_ops && cti_assoc_ops->remove) + cti_assoc_ops->remove(csdev); coresight_remove_conns(csdev); coresight_clear_default_sink(csdev); coresight_release_platform_data(csdev, csdev->pdata); diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c index 255e914b21b5..c5a4213d6623 100644 --- a/drivers/hwtracing/coresight/coresight-cti-core.c +++ b/drivers/hwtracing/coresight/coresight-cti-core.c @@ -502,7 +502,6 @@ static bool cti_add_sysfs_link(struct cti_drvdata *drvdata, link_info.orig_name = tc->con_dev_name; link_info.target = tc->con_dev; link_info.target_name = dev_name(&drvdata->csdev->dev); - link_err = coresight_add_sysfs_link(&link_info); if (link_err) dev_warn(&drvdata->csdev->dev, @@ -608,7 +607,7 @@ void cti_remove_assoc_from_csdev(struct coresight_device *csdev) ctidrv = csdev_to_cti_drvdata(csdev->ect_dev); ctidev = &ctidrv->ctidev; list_for_each_entry(tc, &ctidev->trig_cons, node) { - if (tc->con_dev == csdev->ect_dev) { + if (tc->con_dev == csdev) { cti_remove_sysfs_link(ctidrv, tc); tc->con_dev = NULL; break;