Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3233168imm; Sun, 17 Jun 2018 14:36:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIN/85ww2NDgNDhxbWmXKgy5s57QcN8EE5em7IZxdVawfjkRAXHd77erMTbn/SGO4Vv1D58 X-Received: by 2002:a17:902:bd42:: with SMTP id b2-v6mr11276354plx.23.1529271372030; Sun, 17 Jun 2018 14:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529271371; cv=none; d=google.com; s=arc-20160816; b=foFn+V+4gjgq9AT7A+AcG3KlvgN7MuOGOy3wTv9ZaNFET7VTfXeOAtVY/4o+JmimHG Wn+PUxcCEp7NMQAQUvL1i7jH134X9XMQKdBAbbXG7YSvBDexFvWFJq9Q7ckiG267MoJX 1KwdNvJZ5Q5kOh9rClqJOLjg39MqtWyIXlAXPicleyUNReDAkfsJuF8+CGaYY83v4FAV yq/rvfHbsMD9fNYK7Y9L6Z6esWQTh3orX6SgKtoP0gj4t9XiI0yWn44hNLo+ufmbCNse gQBouhibOOxtv5PrG7l7PCELcN4Jpw/PW9UBz5mDWI0paiZ5bDTWfiC9fmXrQESKzgtz 3Qpw== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=cN6adfLIGmVX92xnk4H6uOWaDaefAWUyFVoKe5kwrI4=; b=t/Q7+Ni/DsTyRKx6GGyBLRKRwplvsvbI02voytveE5cCU/mo5mhvz+IilxSwXfzw/U dWkPxSmzYzgJdqUauo/mFXCIWcof403F/UZTbmLGvSL1/zjJRGv5fsbduwNLt5Ss0aHC /yXruwAVPTycTV1LaILPhtkKflCqKGmW1qpVJTbcdLyz4Y9ueA5Iv+DR/dpdVbYqXwbD JWK7l6VvaZBkkg64vhkMC6axrdtU3fp9zaNu99qc+NCvgyst6P1OhYhkeK/pqGGU6qIN Q8Hrv2utJ2JGtKezNQyvtmtPDcwQM+dT1fu2Kpk7z8cyqHg4fmn37RPh40k4+FzVfGOq 3EZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NxmcOrpj; 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 7-v6si13366217plc.179.2018.06.17.14.35.55; Sun, 17 Jun 2018 14:36:11 -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=NxmcOrpj; 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 S1752737AbeFQVdD (ORCPT + 99 others); Sun, 17 Jun 2018 17:33:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:40822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752100AbeFQVdC (ORCPT ); Sun, 17 Jun 2018 17:33:02 -0400 Received: from mail-yb0-f178.google.com (mail-yb0-f178.google.com [209.85.213.178]) (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 6340C208D5; Sun, 17 Jun 2018 21:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529271181; bh=BY84JvCaICcBkLZwN3RFyObVuGWn+y+z24Lvp1Wb4SU=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=NxmcOrpjJtoN75XUntS0F8uC8+1dUidsATU/HZ9VcmGkbl0HZAlVb7FVloNXby3EU WkTzNBuE9p/RYJ/sJR50pKaP+Z3D7/GlvObqgzqGTFmTSfbjIrOSXARhrwWyd9JRqg TCyj2jNu4ndpa8YJG3mlUuG9sB52F0FGO7Ryj22U= Received: by mail-yb0-f178.google.com with SMTP id s14-v6so2564455ybp.13; Sun, 17 Jun 2018 14:33:01 -0700 (PDT) X-Gm-Message-State: APt69E06JfPlCGiST3mJKHbJ79NRvoWqR3+qgYFnqASMiPY7F7lw2fmU mZkLj2dQU/ju0BEPcgJ8AkU16iLasjEpRt4C1LY= X-Received: by 2002:a25:54c2:: with SMTP id i185-v6mr5129267ybb.62.1529271180528; Sun, 17 Jun 2018 14:33:00 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a5b:bcb:0:0:0:0:0 with HTTP; Sun, 17 Jun 2018 14:32:20 -0700 (PDT) In-Reply-To: <1529251416-14814-1-git-send-email-frowand.list@gmail.com> References: <1529251416-14814-1-git-send-email-frowand.list@gmail.com> From: Alan Tull Date: Sun, 17 Jun 2018 16:32:20 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] of: overlay: update phandle cache on overlay apply and remove To: Frank Rowand Cc: Rob Herring , Pantelis Antoniou , Pantelis Antoniou , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-kernel , Geert Uytterhoeven 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 Sun, Jun 17, 2018 at 11:03 AM, wrote: Hi Frank, > From: Frank Rowand > > A comment in the review of the patch adding the phandle cache said that > the cache would have to be updated when modules are applied and removed. > This patch implements the cache updates. > > Fixes: 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of of_find_node_by_phandle()") > Reported-by: Alan Tull > Suggested-by: Alan Tull > Signed-off-by: Frank Rowand > --- > > Compiles for one configuration. > NOT boot tested. > Not run through my normal process to check for new warnings, etc. > > It is late, I'm tired, my brain is fuzzy. I need to review this more to have > any confidence in it. But I wanted to get a version out for Alan to see (and > test if he wants). Thanks for the very fast response! Monday I'll be able to test it and review it. Thanks, Alan > > drivers/of/base.c | 6 +++--- > drivers/of/of_private.h | 2 ++ > drivers/of/overlay.c | 12 ++++++++++++ > 3 files changed, 17 insertions(+), 3 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index 848f549164cd..466e3c8582f0 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -102,7 +102,7 @@ static u32 phandle_cache_mask; > * - the phandle lookup overhead reduction provided by the cache > * will likely be less > */ > -static void of_populate_phandle_cache(void) > +void of_populate_phandle_cache(void) > { > unsigned long flags; > u32 cache_entries; > @@ -134,8 +134,7 @@ static void of_populate_phandle_cache(void) > raw_spin_unlock_irqrestore(&devtree_lock, flags); > } > > -#ifndef CONFIG_MODULES > -static int __init of_free_phandle_cache(void) > +int of_free_phandle_cache(void) > { > unsigned long flags; > > @@ -148,6 +147,7 @@ static int __init of_free_phandle_cache(void) > > return 0; > } > +#if !defined(CONFIG_MODULES) > late_initcall_sync(of_free_phandle_cache); > #endif > > diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h > index 891d780c076a..216175d11d3d 100644 > --- a/drivers/of/of_private.h > +++ b/drivers/of/of_private.h > @@ -79,6 +79,8 @@ int of_resolve_phandles(struct device_node *tree); > #if defined(CONFIG_OF_OVERLAY) > void of_overlay_mutex_lock(void); > void of_overlay_mutex_unlock(void); > +int of_free_phandle_cache(void); > +void of_populate_phandle_cache(void); > #else > static inline void of_overlay_mutex_lock(void) {}; > static inline void of_overlay_mutex_unlock(void) {}; > diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c > index 7baa53e5b1d7..3f76e58fbec4 100644 > --- a/drivers/of/overlay.c > +++ b/drivers/of/overlay.c > @@ -804,6 +804,8 @@ static int of_overlay_apply(const void *fdt, struct device_node *tree, > goto err_free_overlay_changeset; > } > > + of_populate_phandle_cache(); > + > ret = __of_changeset_apply_notify(&ovcs->cset); > if (ret) > pr_err("overlay changeset entry notify error %d\n", ret); > @@ -1046,8 +1048,18 @@ int of_overlay_remove(int *ovcs_id) > > list_del(&ovcs->ovcs_list); > > + /* > + * Empty and disable phandle cache. Must empty here so that > + * changeset notifiers do not use stale cache entry for a removed > + * phandle. > + */ > + of_free_phandle_cache(); > + > ret_apply = 0; > ret = __of_changeset_revert_entries(&ovcs->cset, &ret_apply); > + > + of_populate_phandle_cache(); > + > if (ret) { > if (ret_apply) > devicetree_state_flags |= DTSF_REVERT_FAIL; > -- > Frank Rowand >