From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20DEEC433F5 for ; Mon, 21 Feb 2022 11:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nBIYgHj0/tg3Ly+2MrOgCeZgi3o8rFIm8hTwEHsjmc4=; b=lywPWRb9k1/TQr 7knWU9cpoH2EPi5Ioz1jVAPz3KYK28XGo91cSpYzGo4qPks0a0d4cRL+AoHfWlNPQlVmzcS8YN2Fx baTTjvgpoNvrXKOJq8ifoXCj0B7VjDuQK1UbGZpn50sVNlvOVrzogyOqchGRRJ+g0AOVImWkZvur/ jEXgU2VuU8oD8cAfe0ig3CfhM3FkeO4u1ZLFnblbaRXERHk/2wfyU59l1WSPxrrkVGSLZSkF6Ie4e 8AZUjwaS1bmcK7rsB2nl5Z4LI3EJ+0f4ELMEOudCTQvMin3hFBG5WY/CeBRSpr/IQWYoyksmDNtQt Q46EC5DnJvxQc28Nc8oA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nM7Ds-005SNF-9z; Mon, 21 Feb 2022 11:51:20 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nM7Dl-005SJu-17 for linux-arm-kernel@lists.infradead.org; Mon, 21 Feb 2022 11:51:18 +0000 Received: from fraeml735-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4K2LFt5Hsdz67jnf; Mon, 21 Feb 2022 19:50:10 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml735-chm.china.huawei.com (10.206.15.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 21 Feb 2022 12:51:10 +0100 Received: from localhost (10.202.226.41) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 21 Feb 2022 11:51:09 +0000 Date: Mon, 21 Feb 2022 11:51:08 +0000 From: Jonathan Cameron To: Yicong Yang CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v4 4/8] hisi_ptt: Add support for dynamically updating the filter list Message-ID: <20220221115108.000033bf@Huawei.com> In-Reply-To: <20220221084307.33712-5-yangyicong@hisilicon.com> References: <20220221084307.33712-1-yangyicong@hisilicon.com> <20220221084307.33712-5-yangyicong@hisilicon.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.202.226.41] X-ClientProxiedBy: lhreml732-chm.china.huawei.com (10.201.108.83) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220221_035113_427070_C1F97BAE X-CRM114-Status: GOOD ( 22.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 21 Feb 2022 16:43:03 +0800 Yicong Yang wrote: > The PCIe devices supported by the PTT trace can be removed/rescanned > by hotplug or through sysfs. Add support for dynamically updating > the available filter list by registering a PCI bus notifier block. > Then user can always get latest information about available tracing > filters and driver can block the invalid filters of which related > devices no longer exist in the system. > > Signed-off-by: Yicong Yang One comment following on from ordering of mixed devm and manual cleanup in earlier patches. Otherwise looks fine to me. > --- > drivers/hwtracing/ptt/hisi_ptt.c | 138 ++++++++++++++++++++++++++++--- > drivers/hwtracing/ptt/hisi_ptt.h | 34 ++++++++ > 2 files changed, 160 insertions(+), 12 deletions(-) > > diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c > index c2b6f8aa9f1e..50193a331faa 100644 > --- a/drivers/hwtracing/ptt/hisi_ptt.c > +++ b/drivers/hwtracing/ptt/hisi_ptt.c > @@ -269,25 +269,118 @@ static int hisi_ptt_register_irq(struct hisi_ptt *hisi_ptt) > return 0; > } > ... > @@ -313,6 +406,9 @@ static void hisi_ptt_init_ctrls(struct hisi_ptt *hisi_ptt) > struct pci_bus *bus; > u32 reg; > > + INIT_DELAYED_WORK(&hisi_ptt->work, hisi_ptt_update_filters); > + spin_lock_init(&hisi_ptt->filter_update_lock); > + INIT_KFIFO(hisi_ptt->filter_update_kfifo); > INIT_LIST_HEAD(&hisi_ptt->port_filters); > INIT_LIST_HEAD(&hisi_ptt->req_filters); > > @@ -329,6 +425,13 @@ static void hisi_ptt_init_ctrls(struct hisi_ptt *hisi_ptt) > hisi_ptt->upper = FIELD_GET(HISI_PTT_DEVICE_RANGE_UPPER, reg); > hisi_ptt->lower = FIELD_GET(HISI_PTT_DEVICE_RANGE_LOWER, reg); > > + /* > + * No need to fail if the bus is NULL here as the device > + * maybe hotplugged after the PTT driver probe, in which > + * case we can detect the event and update the list as > + * we register a bus notifier for dynamically updating > + * the filter list. > + */ > bus = pci_find_bus(pci_domain_nr(pdev->bus), PCI_BUS_NUM(hisi_ptt->upper)); > if (bus) > pci_walk_bus(bus, hisi_ptt_init_filters, hisi_ptt); > @@ -832,6 +935,12 @@ static int hisi_ptt_probe(struct pci_dev *pdev, > return ret; > } > > + /* Register the bus notifier for dynamically updating the filter list */ > + hisi_ptt->hisi_ptt_nb.notifier_call = hisi_ptt_notifier_call; > + ret = bus_register_notifier(&pci_bus_type, &hisi_ptt->hisi_ptt_nb); > + if (ret) > + pci_warn(pdev, "failed to register filter update notifier, ret = %d", ret); > + > return 0; > } > > @@ -839,6 +948,11 @@ void hisi_ptt_remove(struct pci_dev *pdev) > { > struct hisi_ptt *hisi_ptt = pci_get_drvdata(pdev); > > + bus_unregister_notifier(&pci_bus_type, &hisi_ptt->hisi_ptt_nb); > + wrt to earlier comment on ordering you'll also need to move these to a devm_action() call to keep the ordering clean wrt to probe vs remove(). > + /* Cancel any work that has been queued */ > + cancel_delayed_work_sync(&hisi_ptt->work); > + > if (hisi_ptt->trace_ctrl.status == HISI_PTT_TRACE_STATUS_ON) > hisi_ptt_trace_end(hisi_ptt); > ... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel