Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4220139imm; Mon, 8 Oct 2018 17:36:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Pu+3mYFBwFEI155phFI4893O6MjgmOIQso0bCxlcxDu3MV0DaBJi5nTH50Jf8VrANZ4oA X-Received: by 2002:a62:1407:: with SMTP id 7-v6mr27111295pfu.28.1539045396984; Mon, 08 Oct 2018 17:36:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539045396; cv=none; d=google.com; s=arc-20160816; b=RNxzIUWyeqsVhsoaK5k99o+sOkaMVqWRVhF/IAbt1mhvDWQoLjnYnOxSBl0cBlbK4O vhL6OUg+rqp2nNAlvTEwLm48a6ejtF721IELuBP/8pIdMyyIXhhJkQjnqUJG+t8Y2ozv 8Du+H4WlvVoCwnzk+AQJE+VamsM4mbriE8qqlBiS5FLR+FmolObrVY8U8wa/nFgJHdkC HnYEUnVAGCtnrpxTwaquG5bytDn0O5l1pZxSDnXl85bmTrTaiY6VvhxOIvpByZuiBvec Ht2qyOqQ55tP2lDkFxhWP1lsCe8ofOrn8iTs5p0cvg7TRCMOFNu0Z1/qFPzC/sH9GTLJ bsrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=HePli8mKtdKbl3iIvUw8Wyge320kjCtZSB60kSgy08A=; b=k3107c+auS7trpbTrSrUH47A/TaaxhuxNqqdbru0OQShxlW6dBNnuaE8UEWX9SauKa lbI+Hz4g/SLZpEXiTlK3l1gGWnfnCMUTgxLPEdSoSpteLjw0YF26F8gLeJsxuNnVwHjN 43yrl20AQKztoELUHK8lZ82+RomWAeTndypo1spAtowkONqL0BFwQeePppC3vd4myRak jnq8j5CqUmaRJXXYKezNwsIdOFgmrLB/7pk1BNsRtK90XMJQ0M/zsS+eC4OLPQoaS7Lv jlF/xleNwKBBxTgifd1IOQm0khx8KRL6dITfTtVlFS40jYiEfwTGifEqRVLzlzNa8cqZ DncQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hBXPEZY7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r21-v6si11605471pgo.506.2018.10.08.17.36.20; Mon, 08 Oct 2018 17:36:36 -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; dkim=pass header.i=@linaro.org header.s=google header.b=hBXPEZY7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726488AbeJIHuR (ORCPT + 99 others); Tue, 9 Oct 2018 03:50:17 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44687 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbeJIHuR (ORCPT ); Tue, 9 Oct 2018 03:50:17 -0400 Received: by mail-pl1-f196.google.com with SMTP id p25-v6so10790267pli.11 for ; Mon, 08 Oct 2018 17:35:58 -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:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HePli8mKtdKbl3iIvUw8Wyge320kjCtZSB60kSgy08A=; b=hBXPEZY79NFf/JzEHo1u5gYIiL5wSszf9SKpDFr4S023sBiY3cLjg16RNyFnaxDnOe R3rCuLkmQBqm/ezByeLmuyno9hiNW0uvxJ3dCCI+0ryd3ZNEI5ZVudzKHsV2KcP+MYhx jj8/699LeZN4o8gM2UUEbjIiGK5U6pmq59M8I= 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 :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=HePli8mKtdKbl3iIvUw8Wyge320kjCtZSB60kSgy08A=; b=gaDBrANl+9xOyFMfb2Wzyt0ZgfRbg5HYECiav80HXAgdJfPQdTIfrEJd5GsOk159xr egu+Cln1Vyqs4CyZu02wcY108lJlGUPivqktQMIMMd5uQvpOJTcAC8Bt+O+m+EwlsPtY /yRWKTyLffMgm9OrPqP602yYkXesA5nqvzWNQWHVIalcq5eNJCYbp6llR1VcY3bZAsXO 51ys6Y1ACK+68Zp+sDSM8nIYwqMkdlrPasSjZTXLHZcA7fFNnyW8ulWpNKgWnrZZQsDo /8z9S2SMY++D1zgOPQKm2LPwpojbZ0b1fzjIQG4Clf8oBz9ZmIR8JA5srDakIfir/wfu sdWA== X-Gm-Message-State: ABuFfojv9zFtzoTd6zwpKRBp3vfzE5UKKeEZc6mbHFV1QL65E3eqjAE/ Umiu+/s62fev0pKVFU7QCOaVsw== X-Received: by 2002:a17:902:bcc3:: with SMTP id o3-v6mr26781108pls.202.1539045358033; Mon, 08 Oct 2018 17:35:58 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z26-v6sm14091043pfh.77.2018.10.08.17.35.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 17:35:57 -0700 (PDT) Date: Tue, 9 Oct 2018 09:37:37 +0900 From: "AKASHI, Takahiro" To: Rob Herring Cc: David Gibson , Catalin Marinas , Will Deacon , David Howells , Vivek Goyal , Herbert Xu , David Miller , dyoung@redhat.com, Baoquan He , Arnd Bergmann , Martin Schwidefsky , Heiko Carstens , prudo@linux.ibm.com, Ard Biesheuvel , James Morse , bhsharma@redhat.com, kexec@lists.infradead.org, "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , "linux-kernel@vger.kernel.org" , Frank Rowand , devicetree@vger.kernel.org Subject: Re: [PATCH v15 06/16] of/fdt: add helper functions for handling properties Message-ID: <20181009003733.GN32578@linaro.org> Mail-Followup-To: "AKASHI, Takahiro" , Rob Herring , David Gibson , Catalin Marinas , Will Deacon , David Howells , Vivek Goyal , Herbert Xu , David Miller , dyoung@redhat.com, Baoquan He , Arnd Bergmann , Martin Schwidefsky , Heiko Carstens , prudo@linux.ibm.com, Ard Biesheuvel , James Morse , bhsharma@redhat.com, kexec@lists.infradead.org, "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , "linux-kernel@vger.kernel.org" , Frank Rowand , devicetree@vger.kernel.org References: <20180928064841.14117-1-takahiro.akashi@linaro.org> <20180928064841.14117-7-takahiro.akashi@linaro.org> <20181005030849.GK32578@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 05, 2018 at 08:23:57AM -0500, Rob Herring wrote: > On Thu, Oct 4, 2018 at 10:07 PM AKASHI, Takahiro > wrote: > > > > Rob, > > > > # I haven't replied to this comment yet. > > > > On Fri, Sep 28, 2018 at 08:44:42AM -0500, Rob Herring wrote: > > > +David Gibson > > > > > > On Fri, Sep 28, 2018 at 1:48 AM AKASHI Takahiro > > > wrote: > > > > > > > > These functions will be used later to handle kexec-specific properties > > > > in arm64's kexec_file implementation. > > > > > > > > Signed-off-by: AKASHI Takahiro > > > > Cc: Rob Herring > > > > Cc: Frank Rowand > > > > Cc: devicetree@vger.kernel.org > > > > --- > > > > drivers/of/fdt.c | 56 ++++++++++++++++++++++++++++++++++++++++++ > > > > include/linux/of_fdt.h | 4 +++ > > > > 2 files changed, 60 insertions(+) > > > > > > > > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c > > > > index 800ad252cf9c..c65c31562ccb 100644 > > > > --- a/drivers/of/fdt.c > > > > +++ b/drivers/of/fdt.c > > > > @@ -25,6 +25,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > #include /* for COMMAND_LINE_SIZE */ > > > > #include > > > > @@ -1323,3 +1324,58 @@ late_initcall(of_fdt_raw_init); > > > > #endif > > > > > > > > #endif /* CONFIG_OF_EARLY_FLATTREE */ > > > > + > > > > +#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) > > > > +#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) > > > > + > > > > +int fdt_prop_len(const char *prop_name, int len) > > > > +{ > > > > + return (strlen(prop_name) + 1) + > > > > + sizeof(struct fdt_property) + > > > > + FDT_TAGALIGN(len); > > > > > > Looks like you are using this to calculate how much space you need to > > > allocate in addition to the current DTB for a couple of new or > > > replaced properties. I'm not sure that this calculation is completely > > > accurate. And it is strange there doesn't seem to be any libfdt > > > function for this already. It would be simpler to just add some fixed > > > additional amount. > > > > > > Maybe David G has comments on this? > > > > > > > +} > > > > + > > > > > > The rest of this should go in drivers/of/fdt_address.c. Ultimately, it > > > should go into libfdt, but I'm fine with having it in the kernel for > > > now. > > > > I'd like to have this function in the kernel for now. > > > > > > +static void fill_property(void *buf, u64 val64, int cells) > > > > +{ > > > > + __be32 val32; > > > > + > > > > + while (cells) { > > > > + val32 = cpu_to_fdt32((val64 >> (32 * (--cells))) & U32_MAX); > > > > + memcpy(buf, &val32, sizeof(val32)); > > > > + buf += sizeof(val32); > > > > > > This is kind of hard to read. I would copy u-boot's fdt_pack_reg function. > > > > Are you sure? > > I originally implemented this function in a similar way that fdt_pack_reg() > > was, but, you suggested, in your past comment[1], that we'd be better to > > have of_read_number()-like implementation. > > > > [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-May/579118.html > > Yeah, you're right. Plus, I'm not sure the u-boot one would work for > unaligned accesses with armv5 and earlier h/w. > > My only comment then is I think you can drop the U32_MAX masking. Okay, then I will leave this function, yet renaming it to cpu64_to_fdt_cells() after Frank's comment. Thanks, -Takahiro Akashi > > Rob