Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3642607imm; Mon, 15 Oct 2018 01:26:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV60SpaRciG74RfgJRtCE0AmuRGhcAuQq9E2Z7aD3BVljq97NDnYtxMvHC5Ikxab9waIB2UId X-Received: by 2002:a17:902:a618:: with SMTP id u24-v6mr16023710plq.77.1539591983565; Mon, 15 Oct 2018 01:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539591983; cv=none; d=google.com; s=arc-20160816; b=dnvhJdsI7BTJl82Q/NkhFdIUxqed7vJytQkTkz34UbIVYrFt45T9znWvKRPW4m1TP6 sffTRPTNSgEMztTar0raiTYLhG6HduX8/hRF2OcVYWE1RJFuuI9UDjchxJpVfuJNfW10 ncsb5jxJWxhbtcLRgM3Dh1GoV9rQJ4AlXO+zpqqsAug6iC6bCCczzDyeD2gT/o/qaHMZ WqqVdt6AImDMBHaBhJd/RrOAZnLKmZkW4LGhvrRjSbHkoM/xax/OpGCM153UJvFRkST6 r+6l5/f/7zi9XFVBqBnPsKCHx2YuESXmRhRSEpTKeJ/IOQ2O2KZt5GvPn0ozKSXItaW9 O9fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=2pSeoradrxalP15AWIkg1LMbW0eVL/bIIhTWvlbkWCY=; b=L2wMtIJJaZYg/3dFTnUIJNRIeXnTHrpkelMgoy4GPCFBGvVZCJWjwP6UxHIKI8bC7c ytsMq2LHCl/a62IDqSj6dOYBQdP5HyEKw1FrirAxVgoxU+2Lfz0eLoRW4wMjI9iMbCst jpr0mjI2eI8hErC8stmgB97vL5w5aZ3c2Rwt+M9EGEXjEAK/sLhMiOq6GOdFB3RPayga m3LucrznROzt7m8emDWx0bAXdr+Gjvrlt+gfKlMYREh+LIGuGFbLhMukUU+e/ySQVt/a FMdwjvMDZy1ZULSYk+JKIqbWSQgExxZn0CaDQGMhDtHQoy7hdfIXJgXmLWs4k7v3K6+0 qijA== 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 r13-v6si9568911pfb.43.2018.10.15.01.26.08; Mon, 15 Oct 2018 01:26:23 -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 S1726636AbeJOQIr (ORCPT + 99 others); Mon, 15 Oct 2018 12:08:47 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:44362 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbeJOQIq (ORCPT ); Mon, 15 Oct 2018 12:08:46 -0400 Received: by mail-vs1-f66.google.com with SMTP id w194so15742413vsc.11; Mon, 15 Oct 2018 01:24:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2pSeoradrxalP15AWIkg1LMbW0eVL/bIIhTWvlbkWCY=; b=Ut//PJpNWvZCkBrGt1yuK8B0pLXX48dP/oAhOIsTJy+ZtEuWZnua2pplmouJcyTo4w JS0tl0FB5Vmhy9xa0IZuAqO/mmLK7phlbpvl7svYy5TN86+ii8RWHwjrOyzu8hxEJexe keBP3zYhJtkHCVL4d+2+iyMfCum7slzJlQz726Y8scI3aPvjKdU5TsMsgSVK+fOhEY9l gsUXhZ8o1KogcMo+MdTyeN7UJWZj9Vt+w+Uytb1othFuyioF+bCJl3MMCKhh6LOd7mjd tskD2+OM+ru4jLqu8n0LCoSXPFG18Wl+ZHBy1Ys0a9psnz2QoovjR5eUktGXWqjZ3rn/ O+Mg== X-Gm-Message-State: ABuFfojurFoBdOX05YE+/MHP5ZQrcYl0qM6nA0AhLwfWMdXuQAxDuPmh I58SRp+ZAUxOq2IdpqMNJf5+6xvOhs2pcOAxdrg= X-Received: by 2002:a67:e015:: with SMTP id c21mr5886641vsl.63.1539591871972; Mon, 15 Oct 2018 01:24:31 -0700 (PDT) MIME-Version: 1.0 References: <1539567282-1326-1-git-send-email-frowand.list@gmail.com> In-Reply-To: <1539567282-1326-1-git-send-email-frowand.list@gmail.com> From: Geert Uytterhoeven Date: Mon, 15 Oct 2018 10:24:20 +0200 Message-ID: Subject: Re: [PATCH] of: overlay: user space synchronization To: Frank Rowand Cc: Rob Herring , Pantelis Antoniou , Pantelis Antoniou , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List , Alan Tull 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 Hi Frank, On Mon, Oct 15, 2018 at 3:36 AM wrote: > From: Frank Rowand > > When an overlay is applied or removed, the live devicetree visible in > /proc/device-tree/, aka /sys/firmware/devicetree/base/, reflects the > changes. There is no method for user space to determine whether the > live devicetree was modified by overlay actions. > > Provide a sysfs file, /sys/firmware/devicetree/tree_version, to allow > user space to determine if the live devicetree has remained unchanged > while a series of one or more accesses of /proc/device-tree/ occur. Thanks for your patch! > The use of both dynamic devicetree modifications and overlay apply and > removal are not supported during the same boot cycle. Thus non-overlay > dynamic modifications are not reflected in the value of tree_version. What does this mean exactly, for users? I am used to applying and removing overlays at run time (still carrying Pantelis' overlay configfs patches), but when would I use non-overlay dynamic modifications? > --- a/Documentation/ABI/testing/sysfs-firmware-ofw > +++ b/Documentation/ABI/testing/sysfs-firmware-ofw > > +What: /sys/firmware/devicetree/tree_version > +Date: October 2018 > +KernelVersion: 4.20 > +Contact: Frank Rowand , devicetree@vger.kernel.org > +Description: > + When an overlay is applied or removed, the live devicetree > + visible in /proc/device-tree/, aka > + /sys/firmware/devicetree/base/, reflects the changes. > + > + tree_version provides a way for user space to determine if the > + live devicetree has remained unchanged while a series of one > + or more accesses of /proc/device-tree/ occur. > + > + The use of both dynamic devicetree modifications and overlay > + apply and removal are not supported during the same boot > + cycle. Thus non-overlay dynamic modifications are not > + reflected in the value of tree_version. > + > + Example shell use of tree_version: > + > + done=1 > + > + while [ $done = 1 ] ; do > + > + pre_version=$(cat /sys/firmware/devicetree/tree_version) > + version=$pre_version > + while [ $(( ${version} & 1 )) != 0 ] ; do > + # echo is optional, sleep value can be tuned > + echo "${version} sleeping" > + sleep 2; > + pre_version=$(cat /sys/firmware/devicetree/tree_version) > + version=${pre_version} > + done > + > + # 'critical region' > + # access /proc/device-tree/ one or more times > + > + post_version=$(cat /sys/firmware/devicetree/tree_version) > + > + if [ ${post_version} = ${pre_version} ] ; then > + done=0 > + fi > + > + done Please say explicitly that tree_version contains a 32-bit unsigned decimal number, which is incremented before and after every change. I had to deduce that from the code. IMHO that is more important than having the sample script here. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds