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 406B0C10F03 for ; Tue, 23 Apr 2019 16:14:38 +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 0B3E2208E4 for ; Tue, 23 Apr 2019 16:14:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="r+b1HnFR"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="M1A3JZzH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B3E2208E4 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=BFhGTsTb/9qlXitFc4p0DVXhtkpH3616b5nAkSvuiHE=; b=r+b1HnFRPNVNmK Q1olafYWc74b/cTynojplQVzISN2kM0sXDE9vgff8012DDGElKT1Yrv5JHQGd7ADnKjuaGMoos5qO Xk3F3bJb+fDWfxHwj87WJ43edWJ2EQ+XytaYjwWY3GZIDDYXi267OfNumxbK9pQ7ALmrovGWcaWcj nJTGYSWdKrAV94JQKFH4Pyv7umGwEVbf/4HlZrkqCbR7zXPQBqrUMJUAeGCo8ZeghAPXLmEc4737f 1IajamLktZI7qNeWPcDpKHsUQRYURuYWoPBqX4vAlHJpb3jhRvW5SGzODCy5LKlz5OprDv1w99ncn GmNIsGlGWP3iwJu0qPlw==; 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 1hIy3z-0005Qu-JV; Tue, 23 Apr 2019 16:14:31 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIy3w-0005QF-1f for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2019 16:14:29 +0000 Received: by mail-pf1-x442.google.com with SMTP id 8so7742096pfr.4 for ; Tue, 23 Apr 2019 09:14:27 -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=3sn7KqiGW30dkQKXr6QVLij/1FoqIHbldIq/02XidKw=; b=M1A3JZzHiArlOJub7vpLZFmeS0SpQa4YdZCJPFDTM+xz8gAPxVdsKkTHTXht6hzoO2 0Mzmy4nIRehQU/f1TVn96iYucuLKDbn5qK996Fai0xu/nr6Af9DpOQ2j2ZJkFwsPTKyN xTcUveaVGLDEH//tVXhgI+q2Et7tgwuw87XAMiC1mtyhLJGDiZBfNJ2o3G0kj/o7ksY0 DeDfxqC4Rw2uqDWoxqRI1vbxrcffaZbK9Gzn2wVemvqilYOVitpMiomSF7pah6T0GmY/ B38NEqzctKe2aHDJDhUS9GzQntbIWA/mPXlKj3lU4k7pFtqJpbg4WFXLFths52KdtUEa 6GCw== 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=3sn7KqiGW30dkQKXr6QVLij/1FoqIHbldIq/02XidKw=; b=Km1xVYG4iXZKQ1u415WtkhhH/j+jnbKUkDNhxK6uuFO/SmVJr3A8ZJIuZRzjfO7H+H wX3lyNuRINLa2f1m0aqkgOudANJH4DWREUAx6JRQ85mpsMzKWFZlBguGbCmB4LQgk7VQ B1zGsSFJeSXqupMrjCSPgMs+IA6roELj2Zl1mijTLPCF14Tfb7eInmYNBaakypIMVgU5 EeFzoKlog2YcFttpbJofPVfTVMoDYo3k6EiaRixzBNSBCrjpHpf5hGA7BM19nlIROx0z jp2x4OH3X/pjSfAs/9w+6leIfZR+h/ZfImq8qOQ6psIgsYsYEHbtzlgOmWk4jM3zMGNi 8OHA== X-Gm-Message-State: APjAAAVjiu3aQvT4N6Xs+48jI/c8rYuB8f3+OJ9IauSowFvvNRUHafmv KgAHIswW9QYiE+Lnu7iT5XGQEg== X-Google-Smtp-Source: APXvYqzeHHOioGKfVmk2VQ7/tIhElI8+8hXk8VcQbQ2tgiTIMrjk8HPTGxnrZauiAB7uiApGypWwgw== X-Received: by 2002:a65:6414:: with SMTP id a20mr1663736pgv.217.1556036067164; Tue, 23 Apr 2019 09:14:27 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id d69sm32358413pfg.24.2019.04.23.09.14.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 09:14:25 -0700 (PDT) Date: Tue, 23 Apr 2019 10:14:23 -0600 From: Mathieu Poirier To: Suzuki K Poulose Subject: Re: [PATCH v2 29/36] coresight: Use fwnode handle instead of device names Message-ID: <20190423161423.GA21070@xps15> References: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> <1555344260-12375-30-git-send-email-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1555344260-12375-30-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-20190423_091428_105266_18566930 X-CRM114-Status: GOOD ( 33.20 ) 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, rjw@rjwysocki.net, linux-kernel@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 Mon, Apr 15, 2019 at 05:04:12PM +0100, 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 | 12 +++++-- > drivers/hwtracing/coresight/coresight-priv.h | 4 +-- > drivers/hwtracing/coresight/coresight.c | 42 +++++++++++++++++++----- > include/linux/coresight.h | 4 +-- > 4 files changed, 46 insertions(+), 16 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c > index 318a6ff..c9a59fb 100644 > --- a/drivers/hwtracing/coresight/coresight-platform.c > +++ b/drivers/hwtracing/coresight/coresight-platform.c > @@ -214,9 +214,15 @@ static int of_coresight_parse_endpoint(struct device *dev, > } > > conn->outport = endpoint.port; > - conn->child_name = devm_kstrdup(dev, > - dev_name(rdev), > - GFP_KERNEL); > + /* > + * Hold the refcount to the target device. This could be > + * released via: > + * 1) coresight_release_platform_data() if the probe fails or > + * this device is unregistered. > + * 2) While removing the target device via > + * coresight_remove_match() > + */ Many thanks for the documentation - not only does it help me but it also makes it easier for other people to contribute to the subsystem. > + conn->child_fwnode = fwnode_handle_get(rdev_fwnode); > 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 c216421..61d7f9f 100644 > --- a/drivers/hwtracing/coresight/coresight-priv.h > +++ b/drivers/hwtracing/coresight/coresight-priv.h > @@ -200,8 +200,6 @@ static inline void *coresight_get_uci_data(const struct amba_id *id) > return 0; > } > > -static inline void > -coresight_release_platform_data(struct coresight_platform_data *pdata) > -{} > +void coresight_release_platform_data(struct coresight_platform_data *pdata); Now that we have fixed of_get_coresight_platform_data() I think patch 26 should be rolled into this one. That way everything related to coresight_release_platform_data() is done in the same patch and the function doesn't have to be modified twice. > > #endif > diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c > index 82fb411..5169ce1 100644 > --- a/drivers/hwtracing/coresight/coresight.c > +++ b/drivers/hwtracing/coresight/coresight.c > @@ -976,6 +976,7 @@ static void coresight_device_release(struct device *dev) > { > struct coresight_device *csdev = to_coresight_device(dev); > > + fwnode_handle_put(csdev->dev.fwnode); > kfree(csdev->refcnt); > kfree(csdev); > } > @@ -1007,13 +1008,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; > - } > } > } > > @@ -1045,9 +1044,9 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev) > struct coresight_connection *conn = &csdev->pdata->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, > + device_fwnode_match); > if (dev) { > conn->child_dev = to_coresight_device(dev); > /* and put reference from 'bus_find_device()' */ > @@ -1082,9 +1081,15 @@ 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 the remote > + * device acquired in parsing the connections from > + * platform data. > + */ > + fwnode_handle_put(conn->child_fwnode); > /* No need to continue */ > break; > } > @@ -1164,6 +1169,22 @@ static int __init coresight_init(void) > } > postcore_initcall(coresight_init); > > +/* > + * coresight_release_platform_data: Release references to the devices connected > + * to the output port of this device. > + */ > +void coresight_release_platform_data(struct coresight_platform_data *pdata) > +{ > + int i; > + > + for (i = 0; i < pdata->nr_outport; i++) { > + if (pdata->conns[i].child_fwnode) { > + fwnode_handle_put(pdata->conns[i].child_fwnode); > + pdata->conns[i].child_fwnode = 0; pdata->conns[i].child_fwnode = NULL; > + > + } > +} > + > struct coresight_device *coresight_register(struct coresight_desc *desc) > { > int ret; > @@ -1208,6 +1229,11 @@ 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; > + /* > + * Hold the reference to our parent device. This will be > + * dropped only in coresight_device_release(). > + */ > + csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev)); > dev_set_name(&csdev->dev, "%s", desc->name); > > ret = device_register(&csdev->dev); > diff --git a/include/linux/coresight.h b/include/linux/coresight.h > index 8c10def..188e759 100644 > --- a/include/linux/coresight.h > +++ b/include/linux/coresight.h > @@ -126,15 +126,15 @@ struct coresight_desc { > /** > * struct coresight_connection - representation of a single connection > * @outport: a connection's output port number. > - * @chid_name: remote component's name. > * @child_port: remote component's port number @output is connected to. > + * @chid_fwnode: remote component's fwnode handle. > * @child_dev: a @coresight_device representation of the component > connected to @outport. > */ > struct coresight_connection { > int outport; > - const char *child_name; > int child_port; > + struct fwnode_handle *child_fwnode; > 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