Received: by 10.192.165.148 with SMTP id m20csp78686imm; Wed, 9 May 2018 09:04:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrqrmmy06PW533eOK7+kpc1r2aSdjV4yMaMJ6OTd3eXeb8DAmCwLOOKPKxbOdT5TNYYpCAj X-Received: by 2002:a17:902:6bca:: with SMTP id m10-v6mr46009431plt.6.1525881880024; Wed, 09 May 2018 09:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525881879; cv=none; d=google.com; s=arc-20160816; b=SOoWIp1/dL8e+aJhxLkMk1w5/FI3DtpJaabIoZo0LWv4wvDGSLE71oXSiOtYUk+4hS RwoYRHzfZiqLbJOT91w0FD+ZS7Ny/weFCImNpMfmM0cd/5lHJR/uqPewOViQUWZyu9sC B4XoHOITycR5XIv2CoNkvrPOefFGrMWGOJQg6KM1jmgNq2zGVwnF+JZBYwzEhm5IiFYv 6BpWFOPHn4WCMPGX2/NBG5MDlGYV7YWGfMGdZuyq0fobXOpHjBXmNbHP0vIKfbH6rXcR 0KXuvf35DBjFQMiujHOK4ihCqVlCb9SVMpAqHjmBXZZ1mWER8LcZlATBPKGydrav/rIx dVGg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=w/udt5sCmHLlXnhL/zsTcgwbaJ1++fOzB7piWh4Ehu4=; b=0e9B93789Qne7diQVPkcHgNKFeA8/zGtlbxWvnG+xyypBMwYPFESrU1Wf+EwlJyE0L t7GSVcEE/1lEBrEn615bL+vnfHDoOn7zuwXqFQv4nF2m0JuWhSe3TsZG2fJUJBJJL0VQ FR1mbOvxa+sf9AvLpqMXJnkKKpeBB3tHkNrbyNmNC/uAx48o6jmEaMeo8aONST688ude Bl3dnI9r+dQ/XaOmdMxGtr/61ESN70r7oljDgCELgZ47Bhb64yFzcwYtrGdB71jADE+0 DD8uflTsCG/3uOOq2JBYCi+3uF0ZlIIsQADH6btCqLahLSwacOHg3d/JMv9kERH8jyik tolw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1-v6si26653993plk.257.2018.05.09.09.04.24; Wed, 09 May 2018 09:04:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935469AbeEIQCm (ORCPT + 99 others); Wed, 9 May 2018 12:02:42 -0400 Received: from foss.arm.com ([217.140.101.70]:45892 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965130AbeEIQCk (ORCPT ); Wed, 9 May 2018 12:02:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CAFDE15AB; Wed, 9 May 2018 09:02:39 -0700 (PDT) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6EFB63F592; Wed, 9 May 2018 09:02:36 -0700 (PDT) Subject: Re: [PATCH 1/4] amba: Export amba_bustype To: Mathieu Poirier Cc: Kim Phillips , Alexander Shishkin , Alex Williamson , Andrew Morton , David Howells , Eric Auger , Eric Biederman , Gargi Sharma , Geert Uytterhoeven , Greg Kroah-Hartman , Kefeng Wang , Kirill Tkhai , Mike Rapoport , Oleg Nesterov , Pavel Tatashin , Rik van Riel , Russell King , Thierry Reding , Todd Kjos , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20180508140628.f30774c70c4c481bff3f8000@arm.com> <8c2648ec-1379-fb2a-35d2-b3fa8fc9f063@arm.com> <20180509154055.GB25559@xps15> From: Robin Murphy Message-ID: <19c4b830-9f50-d5ea-3e31-587477210ee1@arm.com> Date: Wed, 9 May 2018 17:02:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180509154055.GB25559@xps15> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/05/18 16:40, Mathieu Poirier wrote: > On Wed, May 09, 2018 at 02:38:32PM +0100, Robin Murphy wrote: >> Hi Kim, >> >> On 08/05/18 20:06, Kim Phillips wrote: >>> This patch is provided in the context of allowing the Coresight driver >>> subsystem to be loaded as modules. Coresight uses amba_bus in its call >>> to bus_find_device() in of_coresight_get_endpoint_device() when >>> searching for a configurable endpoint device. This patch allows >>> Coresight to reference amba_bustype when built as a module. >>> >>> Cc: Mathieu Poirier >>> Cc: Alex Williamson >>> Cc: Eric Auger >>> Cc: Russell King >>> Cc: Greg Kroah-Hartman >>> Cc: Todd Kjos >>> Cc: Geert Uytterhoeven >>> Cc: Thierry Reding >>> Cc: Robin Murphy >>> Signed-off-by: Kim Phillips >>> --- >>> There was a prior patch submitted by Alex W. here: >>> >>> https://lkml.org/lkml/2017/6/19/811 >>> >>> But I can't tell its fate - presume simply delayed? >>> >>> Coresight uses amba_bus in its call to bus_find_device() here: >>> >>> https://lxr.missinglinkelectronics.com/linux/drivers/hwtracing/coresight/of_coresight.c#L51 >>> >>> Grepping for bus_type and EXPORT shows other busses exporting their >>> type, so I don't think this is the wrong approach. If, OTOH, Coresight >>> needs to do something differently, please comment. >> >> Exposing raw bus_types is pretty ugly, but it is indeed the status quo, so >> this probably is the reasonable thing to do. I suppose an amba_bus >> equivalent of of_find_device_by_node() could be implemented, but for only a >> single potential user that doesn't seem particularly worthwhile, since >> unless some massive shake-up of how buses work comes along the bus_type will >> inevitably end up being exported for other reasons anyway. So, in the >> context of this series; >> >> Reviewed-by: Robin Murphy >> >> However, as a wild idea for sidestepping the issue completely (or at least >> keeping it within the CoreSight framework), at first glance it appears >> something like the below might be feasible, although I may well be missing >> some obvious reason why not. >> >> Thanks, >> Robin. >> >> ----->8----- >> diff --git a/drivers/hwtracing/coresight/of_coresight.c >> b/drivers/hwtracing/coresight/of_coresight.c >> index 7c375443ede6..2c3fdc9b63e6 100644 >> --- a/drivers/hwtracing/coresight/of_coresight.c >> +++ b/drivers/hwtracing/coresight/of_coresight.c >> @@ -27,28 +27,13 @@ >> >> static int of_dev_node_match(struct device *dev, void *data) >> { >> - return dev->of_node == data; >> + return dev->parent->of_node == data; >> } >> >> static struct device * >> of_coresight_get_endpoint_device(struct device_node *endpoint) >> { >> - struct device *dev = NULL; >> - >> - /* >> - * If we have a non-configurable replicator, it will be found on the >> - * platform bus. >> - */ >> - dev = bus_find_device(&platform_bus_type, NULL, >> - endpoint, of_dev_node_match); >> - if (dev) >> - return dev; >> - >> - /* >> - * We have a configurable component - circle through the AMBA bus >> - * looking for the device that matches the endpoint node. >> - */ >> - return bus_find_device(&amba_bustype, NULL, >> + return bus_find_device(&coresight_bustype, NULL, >> endpoint, of_dev_node_match); >> } > > Hi Robin and thanks for the input. > > Your approach would work if all CS devices would be on the CS bus, which is not > the case at discovery time when of_coresight_get_endpoint_device() is called. Ah, now I see that obvious thing I was indeed missing - I got mixed up and started thinking bus_add_device() only got called as part of driver probe, but of course it's actually much earlier in {platform,amba}_device_add(). That means my idea cannot in fact work at all, since both ends of any link would defer waiting for the other to probe (and thus call coresight_register()) first. Oh well, I guess poking amba_bustype really does remain the only reasonable answer. Thanks, Robin.