Received: by 10.192.165.148 with SMTP id m20csp1213201imm; Fri, 27 Apr 2018 15:00:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwlZD9EVaNVCBr22/Y+0Sc1fYJx7Ni+hNewiBW8oBAKrQe7pS409mpCpqCIdJnAFkDPjjY X-Received: by 2002:a17:902:20cb:: with SMTP id v11-v6mr3698673plg.82.1524866403152; Fri, 27 Apr 2018 15:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524866403; cv=none; d=google.com; s=arc-20160816; b=VnejPF91K7+OlGoHuEbI9APaQzRR98LYWAkAn9xbm0UCbu7uaMk9WW8Tjxy0toSebA IejEe8yNBEyeM+dWESAB5BT7LclocQ8tlF99ycGTP6NE2sZ5TsP6szIMNCVxcy/dUXU6 5a9WDT5rCv8sCgkh6TUHCx7cSdGJHPsUzhPvy/jPwVAbIobMrwJmicX3TGBeb5+Vixk2 JJorICI1ElQ/WlIr5v2OiufBvIanXS566kwzBes13Lbmj3PlZQSYqgptvGCcs13z8zdy e0X0qReiycJ3q019Y/g8HI0/C/EJ/sKicschsULXoQr9EyY0dh8D36TPEEIqEEWsGYhm OMXQ== 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:autocrypt:openpgp:from:references:cc:to:subject :arc-authentication-results; bh=RqrpnCIPvQl6JZEzh65/cjxESB2XI2fxfVeEvGVswhI=; b=I6iJ1u4ebHV8xxepsgtsQT6JjB8gt/eFWxCR76yFT3ra+HWwhPxeiXk+kOYlUx6hW3 HbsMbi/Uw8gIokao5U8cvmnSDFbfhVLw9rHOk950fJR89mtcckpRLuxaKphFzdWA5jcj dPrroDd8/rMjOqaYYSIq3rodXvNm1WhDBj0ePAqMcIJrGxQFULgo7TiLBqVruvItjR2k QglhNr9SWv1F2Em5J0U+Ube0WUpCVwBD1U8cmKsaHDQ5vsGx5iaEuwrxpCERd00k4a1M Bj4rAgyStqfZDPZiEuLBDpCAeN2W6htjgtRzTGBm38Lwft6ZO7tPpVqLCIAyyfyS6Zbf 4AAQ== 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 g33-v6si2068814plb.297.2018.04.27.14.59.48; Fri, 27 Apr 2018 15:00:03 -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 S1759449AbeD0V6T (ORCPT + 99 others); Fri, 27 Apr 2018 17:58:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:36649 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759262AbeD0V6Q (ORCPT ); Fri, 27 Apr 2018 17:58:16 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 902C8AC1D; Fri, 27 Apr 2018 21:58:14 +0000 (UTC) Subject: Re: [RFC PATCH 1/3] of: base: Introduce of_alias_check_id() to check alias IDs To: Michal Simek , Rob Herring Cc: "linux-kernel@vger.kernel.org" , Michal Simek , One Thousand Gnomes , devicetree@vger.kernel.org, Frank Rowand References: <6045807691c310ccdd57ab16524b7525f26a1dc1.1524751696.git.michal.simek@xilinx.com> <147e8ae7-3682-2350-394a-828c096f5ee3@xilinx.com> From: Alexander Graf Openpgp: preference=signencrypt Autocrypt: addr=ag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y72e5HnLpNg/zj3CBZFM40df8K+zqwtWfQicOM5IJ g1m5nhiB1rMWywSZ2pYkPHVjPJ68MkvCChsK5vSl4sIEoYkZnkQw5J+K8bwqaZZL0REK9xhH z+1FvVl7zEjCZXvyUm25ZS8iqAnlpk9UBFjXYKX8Ut9Y2iIDz3Pg3/FCLXbJSCQ6mIEe80Ns U2+L0x4LbU/JSxdN7+JC+1K36P66yBsWXk5347UdzPkvq6nlUqHPLpqpl4p+KzxI1TKK8co3 0gebQn/WLY3gqt6vCht2mdJztWPCL+r5kYodiYnpDXY/7SFr0+46QLRF1xG0J5UYGnz4koot 3173uxYy75CNZqYpqpLivEG6NXmGUNFypsbGuEhsAV2GWGyf0uT91XFE0SlRUxOMEHbLwwhP iMLccbHM2Kdf238nBUehU8iIsw/q6BWWw60MXH4Rw/1yya6JYvIyaG8ytoKhv8zZ Message-ID: Date: Fri, 27 Apr 2018 23:58:11 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <147e8ae7-3682-2350-394a-828c096f5ee3@xilinx.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.04.18 16:14, Michal Simek wrote: > On 27.4.2018 15:02, Rob Herring wrote: >> On Fri, Apr 27, 2018 at 1:10 AM, Michal Simek wrote: >>> On 27.4.2018 04:39, Rob Herring wrote: >>>> On Thu, Apr 26, 2018 at 9:08 AM, Michal Simek wrote: >>>>> The function travers the lookup table to check if the request alias >>>>> id is compatible with the device driver match structure. >>>>> This function will be used by serial drivers to check if requested alias >>>>> is allocated or free to use. >>>>> >>>>> Signed-off-by: Michal Simek >>>>> --- >>>>> >>>>> drivers/of/base.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ >>>>> include/linux/of.h | 2 ++ >>>>> 2 files changed, 51 insertions(+) >>>>> >>>>> diff --git a/drivers/of/base.c b/drivers/of/base.c >>>>> index 848f549164cd..382de01acc72 100644 >>>>> --- a/drivers/of/base.c >>>>> +++ b/drivers/of/base.c >>>>> @@ -1892,6 +1892,55 @@ int of_alias_get_id(struct device_node *np, const char *stem) >>>>> } >>>>> EXPORT_SYMBOL_GPL(of_alias_get_id); >>>>> >>>>> +/** >>>>> + * of_alias_check_id - Check alias id for the give compatibility >>>>> + * @matches: Array of of device match structures to search in >>>>> + * @stem: Alias stem of the given device_node >>>>> + * @id: Alias ID for checking >>>>> + * >>>>> + * The function travers the lookup table to check if the request alias id >>>>> + * is compatible with the device driver match structure >>>>> + * >>>>> + * Return true if ID is allocated, return false if not >>>>> + */ >>>>> +bool of_alias_check_id(const struct of_device_id *matches, const char *stem, >>>>> + int id) >>>> >>>> Wouldn't it be simpler to just return a bitmap of all allocated ids >>>> that match rather than trying to build that up 1 bit at a time? >>> >>> Is alias list stable or can dt overlay change it? >> >> Stable. If you use an id and then an overlay adds that id as an alias, >> what should the kernel do? The only choice is ignore the suggestion. > > I didn't play with that for a while but on fpga case you have for > example serial0/serial1 fixed to hard IPs/PS part and then you add 20 > uartlites or 16550 IPs to PL via overlays and you want to make sure > proper order for user application. > It means it is not rewriting current but adding new one exactly how you > should do that when fixed and fpga parts are together. > > >> >>> What should be the expected flow? Find out maximum number of aliases of >>> the same kind and allocate bitmap and return it with length. >> >> I think we can assume <32 so just return a bitmap in a unsigned long >> or u32. Use that to initialize a bitmap in the driver. For un-aliased >> devices, find the first unset bit, use that id and set the bit. > > Ok if this is in driver field can be allocated in the driver and passed > also maximum len. It should be better then expecting maximum of 32 > devices which ends with max serial31 alias. > > Or at least expect u64 with max serial63. > > >>> Anyway if you look at that patches I sent then I call in the driver >>> of_alias_get_highest_id("serial") which doesn't take care if alias match >>> with actual driver. It means having information about max alias ID which >>> match actual driver that would be helpful but I am not quite sure what >>> should be the flow. >> >> I'm a bit confused as to why you use of_alias_get_highest_id and >> of_alias_check_id. of_alias_get_highest_id is really intended if you >> want to start dynamic allocations above all the alias ids. > > I need to get maximum number of ports for passing it to > uart_register_driver which is called only once. > And using of_alias_get_highest_id() return me reasonable number for all > listed serial ports. > It is not correct because some IPs don't need to be listed in that list > but it is reasonable expectation for this RFC. > Even alias bitfield won't help with getting correct number. > > > The best will be to get number of devices which match that driver > because they don't need to be listed in aliases list. > > You get 20 of devices and will allocate space for 20. If there is alias > below 20 you will use numbers. If there is alias >= 20 it will be > ignored in probe and number will be assigned based on empty position. > > But this is also no covering overlay cases where others devices can be > added at run time. > > >> I guess the need to match devices is based on each serial driver >> having it's own major and /dev name. IMO, we should get rid of those >> and every serial driver use ttySn (with the exception of things like >> USB serial). Then you'd just need to find all serial aliases. But you >> can support both with this function. Just return a bitmap of all >> aliases if match is NULL. > > This will break a lot of things which are stable today. What if ttySn were simply symlinks and no driver spawns any device of that name? So the normal NS16550 UART driver would get a new name, but ttyS0 we could still match for everywhere regardless. In that layer we could then do the alias mapping and simply honor the numbers given by DT. Alex