From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755033AbbHYC2w (ORCPT ); Mon, 24 Aug 2015 22:28:52 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:34060 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754766AbbHYC2s (ORCPT ); Mon, 24 Aug 2015 22:28:48 -0400 Subject: Re: [PATCH 1/1] of: to support binding numa node to root subnode(non-bus) To: Rob Herring , Benjamin Herrenschmidt References: <1440419410-10520-1-git-send-email-thunder.leizhen@huawei.com> CC: Grant Likely , Rob Herring , devicetree , Greg Kroah-Hartman , linux-kernel , Zefan Li , Xinwei Hu , Tianhong Ding , Hanjun Guo From: "Leizhen (ThunderTown)" Message-ID: <55DBD1F8.1010206@huawei.com> Date: Tue, 25 Aug 2015 10:24:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.55DBD20B.010A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d549d79ddfe97fd72b384bcbf35a2924 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/8/24 21:25, Rob Herring wrote: > +benh > > On Mon, Aug 24, 2015 at 7:30 AM, Zhen Lei wrote: >> If use of_platform_populate to scan dt-nodes and add devices, the >> subnode of root(such as /smmu), when being scanned and invoke > > You should have a bus as the sub-node of root rather than devices > directly off of root. You still have a problem though... But actually the parent of bus is also &platform_bus if we didn't have special initialization. For example: The function of_platform_device_create_pdata invoke of_device_alloc first, then invoke of_device_add. But in of_device_alloc, we can find that: dev->dev.parent = parent ? : &platform_bus; > >> of_device_add, the ofdev->dev.parent is always equal &platform_bus. So >> that, function set_dev_node will not be called. And in device_add, >> dev_to_node(parent) always return NUMA_NO_NODE. >> >> Signed-off-by: Zhen Lei >> --- >> drivers/base/core.c | 2 +- >> drivers/of/device.c | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/base/core.c b/drivers/base/core.c >> index dafae6d..5df4f46b 100644 >> --- a/drivers/base/core.c >> +++ b/drivers/base/core.c >> @@ -1017,7 +1017,7 @@ int device_add(struct device *dev) >> dev->kobj.parent = kobj; >> >> /* use parent numa_node */ >> - if (parent) >> + if (parent && (parent != &platform_bus)) > > This is only fixing one specific case, but I think things are broken > for any case where the NUMA associativity if not set at the top level > bus node. I think this should be something like: > > if (parent && (dev_to_node(dev) != NO_NUMA_NODE)) It seems a mistake, we should use equal sign. if (parent && (dev_to_node(dev) == NUMA_NO_NODE)) > > Then the OF code can set the node however it wants. OK. I will send patch v2 base upon your advice. Thank you. > >> set_dev_node(dev, dev_to_node(parent)); >> >> /* first, register with generic layer. */ >> diff --git a/drivers/of/device.c b/drivers/of/device.c >> index 8b91ea2..96ebece 100644 >> --- a/drivers/of/device.c >> +++ b/drivers/of/device.c >> @@ -63,7 +63,7 @@ int of_device_add(struct platform_device *ofdev) >> /* device_add will assume that this device is on the same node as >> * the parent. If there is no parent defined, set the node >> * explicitly */ >> - if (!ofdev->dev.parent) >> + if (!ofdev->dev.parent || (ofdev->dev.parent == &platform_bus)) > > And then remove the if here. > OK. I also think remove this statement will be better. Althouth set_dev_node maybe called two times, but it only spends very little time, and this almost happened at initialization phase. >> set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node)); >> >> return device_add(&ofdev->dev); >> -- >> 2.5.0 >> >> >> -- >> To unsubscribe from this list: send the line "unsubscribe devicetree" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > . >