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 X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26AA0C43381 for ; Thu, 28 Mar 2019 17:42:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E79F920823 for ; Thu, 28 Mar 2019 17:42:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D1owiuwu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IDg8KG8B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E79F920823 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+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject: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=yi6W+K96XqbrapxMAGjBlTLu4yA2J0uukTK4HSwIVTc=; b=D1owiuwuZrBghO IqriTmVseiluex0dVA8ZriXSXGELqi/CsKxtt7JiMbG8mznaUqG4sXHbHVq5Qk7WxWOKqVYKb/H/J Hht4U0j+InKoS1FHIj8eZj2zH66/N3dcL7EtimUD6xu1B2RXs3vRuRuV94TkB9QEiWhoSNi51Avpn +Kaozp2zP1G5cEfjX3L6Ibbgmzxnnc1RibDEwx1CZBpeDs0NcmlYEDzTtkoU9EiCiy4Famo5be53F BtNMdiym4jQXJ9sKDoviRi3CxymSDlR7bBx+WvOKTSLt1DDg3OopSUzZnZkfDwZr1PZZ1OTTDDa3o /vDFnGTw6t05B7sgt6fA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9Z2n-00085L-3b; Thu, 28 Mar 2019 17:42:25 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9Z2k-00084W-A3 for linux-arm-kernel@lists.infradead.org; Thu, 28 Mar 2019 17:42:24 +0000 Received: by mail-pl1-x643.google.com with SMTP id k2so5287466plt.3 for ; Thu, 28 Mar 2019 10:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1mbX6TtDd3JqGNN21RxAU/l6aiTygvCs2X0+WCtQGVQ=; b=IDg8KG8BZ+JDTOffSRUn8bQ09KQf2T7Q5G9AZ9kyXIbOrZF81p0W2RaLU/Rs3221hI rLZNJV2LUrid0ww8/wuJWPurXz3IqkqDl7cYJjwvnKRqGJxK5c1fCdK1furZcb5/9F7o ImNAKDDhaxl3chHRnHyzDWXP8ANaWaC8ep9eWTErFGQXaRsXeE8/fafAWNFUTqKl0JjO PiaL7FQdWQGyRIJmCivp/et72Q3Psq+mvkXxDOtmuFk+WHWg4oXzhLjVSaWAWB/Hkr/s bpuSGBoG7SSo6+73mqqAcyzwSDkd+XG7FbJ40QLBaOZRlYst/qEbMsqTCLnJhOhRFpP9 cCbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1mbX6TtDd3JqGNN21RxAU/l6aiTygvCs2X0+WCtQGVQ=; b=Ti9Q2JEQub/aEp40W3SBF8uyUMbLyc2LnIk5V5mJ52oVlu29Z3YME50QBtHy0JbblW OUp0qhQsoJ47j1SRHqngGw83flBKbyVHrlmpRVtrFCJm7V5Zbx2JoD056kaOT6P2mEHO NApVmzBLlOomOkg/JiUyJQyfCLKZsW3AdtnQ8aPXKO8qnxbAwEa27TV/iDvWz2VIKkLI lkZAcfJ2+PAFWALJ8F8ykSRtnL3H9kME4H5VdFqzfVddDnLYAt0RC/2AGF9Xh8NcTB4m qxKp4s1YdAhLpEEPLTMZRZ/AQDKAzaTJJTFXC0ysa0YP35Cb9HDvAJYeRKLbed7D7eUR ysfw== X-Gm-Message-State: APjAAAVKkEoPFwOa76yfGtqEfGr4DdQ3vQwrRRtUcOYK5iOlm8zQRT7t ibe8ZmEhfyFG2SpO71Q0s8uCCQ== X-Google-Smtp-Source: APXvYqwys9OPDoMLmoETaVAK0WlB/PfzxVlVp1I6JjJswSHb9DnWnYqPVSmB8Wkhoq6kJkMn9uSLpw== X-Received: by 2002:a17:902:1e6:: with SMTP id b93mr44014091plb.325.1553794938940; Thu, 28 Mar 2019 10:42:18 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id l12sm48438288pgn.83.2019.03.28.10.42.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Mar 2019 10:42:18 -0700 (PDT) Date: Thu, 28 Mar 2019 11:42:16 -0600 From: Mathieu Poirier To: Suzuki K Poulose Subject: Re: [PATCH 21/25] coresight: Use fwnode handle instead of device names Message-ID: <20190328174216.GD778@xps15> References: <1553107783-3340-1-git-send-email-suzuki.poulose@arm.com> <1553107783-3340-22-git-send-email-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1553107783-3340-22-git-send-email-suzuki.poulose@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190328_104222_364408_429515D3 X-CRM114-Status: GOOD ( 31.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: coresight@lists.linaro.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.walker@arm.com, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Mar 20, 2019 at 06:49:38PM +0000, Suzuki K Poulose wrote: > We rely on the device names to find a CoreSight device on the > coresight bus. The device name however is obtained from the platform, > which is bound to the real platform/amba device. As we are about > to use different naming scheme for the coresight devices, we can't > rely on the platform device name to find the corresponding > coresight device. Instead we use the platform agnostic > "fwnode handle" of the parent device to find the devices. > We also reuse the same fwnode as the parent for the Coresight > device we create. > > Cc: Mathieu Poirier > Signed-off-by: Suzuki K Poulose > --- > drivers/hwtracing/coresight/coresight-platform.c | 10 ++++------ > drivers/hwtracing/coresight/coresight-priv.h | 2 ++ > drivers/hwtracing/coresight/coresight.c | 19 +++++++++++-------- > include/linux/coresight.h | 4 ++-- > 4 files changed, 19 insertions(+), 16 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c > index 877ed2b..5eee987 100644 > --- a/drivers/hwtracing/coresight/coresight-platform.c > +++ b/drivers/hwtracing/coresight/coresight-platform.c > @@ -31,7 +31,7 @@ static int coresight_alloc_conns(struct device *dev, > return 0; > } > > -static int coresight_fwnode_handle_match(struct device *dev, void *data) > +int coresight_match_fwnode_handle(struct device *dev, void *data) > { > return dev_fwnode(dev) == data; > } > @@ -46,7 +46,7 @@ coresight_find_device_by_fwnode(struct fwnode_handle *fwnode) > * platform bus. > */ > dev = bus_find_device(&platform_bus_type, NULL, > - fwnode, coresight_fwnode_handle_match); > + fwnode, coresight_match_fwnode_handle); > if (dev) > return dev; > > @@ -55,7 +55,7 @@ coresight_find_device_by_fwnode(struct fwnode_handle *fwnode) > * looking for the device that matches the endpoint node. > */ > return bus_find_device(&amba_bustype, NULL, > - fwnode, coresight_fwnode_handle_match); > + fwnode, coresight_match_fwnode_handle); > } Please change the name to coresight_match_fwnode_handle() in the previous patch so that it is set only once. > > #ifdef CONFIG_OF > @@ -214,9 +214,7 @@ static int of_coresight_parse_endpoint(struct device *dev, > } > > conn->outport = endpoint.port; > - conn->child_name = devm_kstrdup(dev, > - dev_name(rdev), > - GFP_KERNEL); > + conn->child_fwnode = fwnode_handle_get(rdev_fwnode); I think it is worth adding a comment saying the refcount on the handle is decremented in coresight_remove_match(). It is quite obvious when looking at this patch but I suspect it won't be so in 1 year from now when trying to understand this code again, especially since the increment/decrement are in different files. > conn->child_port = rendpoint.port; > /* Connection record updated */ > ret = 1; > diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h > index e0684d0..8fb1243 100644 > --- a/drivers/hwtracing/coresight/coresight-priv.h > +++ b/drivers/hwtracing/coresight/coresight-priv.h > @@ -153,6 +153,8 @@ struct list_head *coresight_build_path(struct coresight_device *csdev, > struct coresight_device *sink); > void coresight_release_path(struct list_head *path); > > +int coresight_match_fwnode_handle(struct device *dev, void *data); > + > #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X > extern int etm_readl_cp14(u32 off, unsigned int *val); > extern int etm_writel_cp14(u32 off, u32 val); > diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c > index 29cef89..9cdedab 100644 > --- a/drivers/hwtracing/coresight/coresight.c > +++ b/drivers/hwtracing/coresight/coresight.c > @@ -1005,13 +1005,11 @@ static int coresight_orphan_match(struct device *dev, void *data) > /* We have found at least one orphan connection */ > if (conn->child_dev == NULL) { > /* Does it match this newly added device? */ > - if (conn->child_name && > - !strcmp(dev_name(&csdev->dev), conn->child_name)) { > + if (conn->child_fwnode == csdev->dev.fwnode) > conn->child_dev = csdev; > - } else { > + else > /* This component still has an orphan */ > still_orphan = true; > - } > } > } > > @@ -1043,9 +1041,9 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev) > struct coresight_connection *conn = &csdev->conns[i]; > struct device *dev = NULL; > > - if (conn->child_name) > - dev = bus_find_device_by_name(&coresight_bustype, NULL, > - conn->child_name); > + dev = bus_find_device(&coresight_bustype, NULL, > + (void *)conn->child_fwnode, > + coresight_match_fwnode_handle); > if (dev) { > conn->child_dev = to_coresight_device(dev); > /* and put reference from 'bus_find_device()' */ > @@ -1080,9 +1078,11 @@ static int coresight_remove_match(struct device *dev, void *data) > if (conn->child_dev == NULL) > continue; > > - if (!strcmp(dev_name(&csdev->dev), conn->child_name)) { > + if (csdev->dev.fwnode == conn->child_fwnode) { > iterator->orphan = true; > conn->child_dev = NULL; > + /* Drop the reference to the handle for connection */ Same as above, please comment where this gets incremented. > + fwnode_handle_put(conn->child_fwnode); > /* No need to continue */ > break; > } > @@ -1198,6 +1198,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) > csdev->dev.parent = desc->dev; > csdev->dev.release = coresight_device_release; > csdev->dev.bus = &coresight_bustype; > + csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev)); > + > dev_set_name(&csdev->dev, "%s", desc->pdata->name); > > ret = device_register(&csdev->dev); > @@ -1247,6 +1249,7 @@ void coresight_unregister(struct coresight_device *csdev) > etm_perf_del_symlink_sink(csdev); > /* Remove references of that device in the topology */ > coresight_remove_conns(csdev); > + fwnode_handle_put(csdev->dev.fwnode); > device_unregister(&csdev->dev); > } > EXPORT_SYMBOL_GPL(coresight_unregister); > diff --git a/include/linux/coresight.h b/include/linux/coresight.h > index a48cd9b..76c31b2 100644 > --- a/include/linux/coresight.h > +++ b/include/linux/coresight.h > @@ -128,14 +128,14 @@ struct coresight_desc { > /** > * struct coresight_connection - representation of a single connection > * @outport: a connection's output port number. > - * @chid_name: remote component's name. > + * @chid_fwnode: remote component's fwnode handle. > * @child_port: remote component's port number @output is connected to. > * @child_dev: a @coresight_device representation of the component > connected to @outport. > */ > struct coresight_connection { > int outport; > - const char *child_name; > + struct fwnode_handle *child_fwnode; Please drop this one line to group all the struct together. > int child_port; > struct coresight_device *child_dev; > }; > -- > 2.7.4 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel