Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp994351pxa; Wed, 19 Aug 2020 22:51:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3Tso6r8yQQ9yLtYY/Mj2M/zx3TKqKFudcV9PupvkBcn+BuoJd8YYN1WobWhcrsZ689mgl X-Received: by 2002:a05:6402:1545:: with SMTP id p5mr1318736edx.388.1597902712727; Wed, 19 Aug 2020 22:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597902712; cv=none; d=google.com; s=arc-20160816; b=EPWPq3sifXkLR3l0rB+CI1rPAxiXJeipd2o51zDd4lYcjOftAHoKPIjTcUrVxaUksF oua7jqMcsUrfAQnAGu+hqAIg9F+SqHhhSE5oye6/Lpz1M2NlsiIgNqyknpF1/H6psf+D O9TpF+ydgiWM4iccdh+SDHIW2xqdPo2ebFQf7YHUqanJ2qnWpZcqaGr/tSGKL6yy1cmM RTkoetSSakfyCRKjDlsHI/Ow9W1KRuXvi0WOj+9p/SOxj9MpmmqwQkJwjbo3oUvXyx+R j1DxTpSQB/weUbDWwWfJiyLN/p/l5gQR3iQ8fkNZjG9XSMQ851MVQEuD16I2vRU7L62b w9Xw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=Q6t9APC//ACItqFnRnuBLNww/gxsRtJrwgW0lkmg6so=; b=dn/We3On8rDHh+ARkO8GJW5Gf19qog3NlXwkpzYWmfs7EpPz34iKtXsqEhzgy7SKME Zov3rcIvMn1PXUKGQTotZt5KCeQLd3Jn855mVAHyKLlxyAjTrjTD0BS5qXLu0vDceGrI 0J2FYEM7p73PVRrY+cB7dkQxfgDg6o7aFM3DBjHgd0zjUAvA8nYFV9VDui3tIRvDHZhQ IaY2AkT+r1jPXX3/BtCtYC2bwJcNulJgPo4oczUJG4FDUjEy9Ih/cxrtabl7BZR7mbqE OXddNuRboWzt/lCepDzaC7X4daZ0fQP6UavCs84clyQgplP5zv3Au6cb/QzxOcX3HatD OnJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=iC5qoNAS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s27si975144edi.266.2020.08.19.22.51.29; Wed, 19 Aug 2020 22:51:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=iC5qoNAS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbgHTFu4 (ORCPT + 99 others); Thu, 20 Aug 2020 01:50:56 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:13055 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbgHTFuz (ORCPT ); Thu, 20 Aug 2020 01:50:55 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597902654; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=Q6t9APC//ACItqFnRnuBLNww/gxsRtJrwgW0lkmg6so=; b=iC5qoNAS8vdzyrTlk1Gb0RySxNkIp8OsIWKVOtWc9zYhM2iztYEhi4SMVDuPmxnTlm8C7CZb 6Bx/KtBEFphpPxsw8WYg21qCM+IxW2mrzngsU4mgaiwVsrkZrAbQqIMEVMKIbgk7zI/EROEQ 1UvB8MWcPs64srwDysiJ8J3SuQo= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-west-2.postgun.com with SMTP id 5f3e0f38f32ee2c46a263524 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 20 Aug 2020 05:50:48 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id F333FC433AF; Thu, 20 Aug 2020 05:50:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from tingweiz-gv.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tingwei) by smtp.codeaurora.org (Postfix) with ESMTPSA id E2607C43387; Thu, 20 Aug 2020 05:50:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E2607C43387 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=tingwei@codeaurora.org From: Tingwei Zhang To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Mike Leach Cc: Greg Kroah-Hartman , Leo Yan , Randy Dunlap , Russell King , Kim Phillips , Mian Yousaf Kaukab , tsoni@codeaurora.org, Sai Prakash Ranjan , Mao Jinlong , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei Zhang Subject: [PATCH v9 18/24] coresight: cti: Fix bug clearing sysfs links on callback Date: Thu, 20 Aug 2020 13:47:12 +0800 Message-Id: <20200820054718.20115-19-tingwei@codeaurora.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20200820054718.20115-1-tingwei@codeaurora.org> References: <20200820054718.20115-1-tingwei@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Leach 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 Signed-off-by: Tingwei Zhang Acked-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-cti.c | 2 +- drivers/hwtracing/coresight/coresight.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c index 1c34db7d1b1b..6bb06c5715db 100644 --- a/drivers/hwtracing/coresight/coresight-cti.c +++ b/drivers/hwtracing/coresight/coresight-cti.c @@ -608,7 +608,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; diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index c2174fed263b..6c09be15d60c 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.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); @@ -1590,6 +1588,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); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project