Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp445497imm; Fri, 5 Oct 2018 06:26:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV61UGnH8HLnuGr65uzKio+oRy7vXDvnnacdjhbrB5ic3B4Msvoei7EgpLziCmnJw5DPlBrT0 X-Received: by 2002:a63:ec4b:: with SMTP id r11-v6mr10114578pgj.295.1538746010726; Fri, 05 Oct 2018 06:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538746010; cv=none; d=google.com; s=arc-20160816; b=SfbiIhEYWIbtyAjC0XsCa6BkvDL4KThgopHB+PLJq8o+WKQvwza/gxQof9JIYExszS oFpad99ONXVfiXvcbIxo64lrnWHoI5urJhWx4HMQlRAh+QxDe0mDO+O9RqRGNhg4BdtX xQGxWHViKOAz63pvt5Zo7ffN3A+Ubfc7stofRAqk24LohK5BznlK+lH4Mm7rswlLqzoM OMLsDGe1KZ5nB/Xv9tDboUDV+wGBtoLhowJaJD5E5x3Dx7QQKyqJsCi3KxZI0NMfGf5x 3BBD343GL1TBSeGPspdbpjckpwBKG+ITafVbg91ovyL2NJu0nB44kBNQ81rfofsGXkdx B0lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6UjB4UBFy7PPdMgcHtUdsHh+1CC2PrsczkMuPVH/UTU=; b=rziXrc50mmG+4cPeXsO68zu86O8aD+P38ipN+5fE1WsUfM46xaz2XmblhsSBOtdGlP YKzTNSLz6LmNaNsqoqnjMSRDSFsIMP/2MQufvT50N2SNGhD8CxRyn44UArn06/KXiS6m iPiSO3a7xx/x6nuiYtyCkkC0JsI1oeIZ4Sko9l/n7tQORvHzOTGDX2l7fxXkbwnMFDqp 2vQ90G2JwvJb9wPmxRFHJ8zRGcU+khr8KZwb84qnXSVs0l/m7UlpUNGum+AkFhVBOONH Sczi4sNWkBEJ4iB49o8RY2nEdti/dbAs2rswdtbvDFYyZ9QSCYdH5nKiRKMNZRkxJpVw OXFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ktZpWwJ9; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1-v6si7068422pga.240.2018.10.05.06.26.34; Fri, 05 Oct 2018 06:26:50 -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=@kernel.org header.s=default header.b=ktZpWwJ9; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728789AbeJEUWy (ORCPT + 99 others); Fri, 5 Oct 2018 16:22:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:59838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728764AbeJEUWx (ORCPT ); Fri, 5 Oct 2018 16:22:53 -0400 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BAC121477; Fri, 5 Oct 2018 13:24:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1538745850; bh=Eql3v4IORNh6z2CGHUZvvCCBIYV/BOOXmWvpyVfwUeI=; h=References:In-Reply-To:From:Date:Subject:To:From; b=ktZpWwJ91/5LajAaWLXo+hes9MTl46qMoRFyQARpRI3NV8jNZx4VxDqVVFoYDot2N hIfZNjwUBwiae4piGsIsh/WljRjSqx1LAyqvlxPQmaacevavr1AaoveVBYI72YPTZr vSbJWBiamd0vpZONKSiVJ0IYZBnSFgMCNOplZlyQ= Received: by mail-qt1-f179.google.com with SMTP id l9-v6so13712956qtf.5; Fri, 05 Oct 2018 06:24:10 -0700 (PDT) X-Gm-Message-State: ABuFfojM/h8ZQ17nib37jfjEX+9UEkANQL4iSK7IvQ9HmBsnRvOWS8FJ gHaClnfhwp1BxcQggmSh0dd/C2/SSoJdHC3EfQ== X-Received: by 2002:a0c:b5d3:: with SMTP id o19-v6mr9463349qvf.218.1538745849777; Fri, 05 Oct 2018 06:24:09 -0700 (PDT) MIME-Version: 1.0 References: <20180928064841.14117-1-takahiro.akashi@linaro.org> <20180928064841.14117-7-takahiro.akashi@linaro.org> <20181005030849.GK32578@linaro.org> In-Reply-To: <20181005030849.GK32578@linaro.org> From: Rob Herring Date: Fri, 5 Oct 2018 08:23:57 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v15 06/16] of/fdt: add helper functions for handling properties To: "AKASHI, Takahiro" , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Rob