From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10AB224B254 for ; Fri, 10 Jan 2025 22:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736546683; cv=none; b=rmpYwr2EDq1rk/BXNfABV002y1VfuSBXCIQscCfiHC42XRG3qbq9AolTjVAPnAn4+U+YsNL5YbyQBmnllnj1UYQeWNsUPchJxwgQ9ZlxWXUaJN3lN+kvxLtbw4P4b3MXorckQe8zP1fFdRcyh0gk7xK8r3VerPRsNfhEJBkydcQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736546683; c=relaxed/simple; bh=b9WKBQ8NuViU/bZ0HeL+7P1wKdEpWaLgYphdVF4bMoE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XFTM51K7Kc7a2VFMNBo8htw+nIKdA2udlYc1BdwkTsCJBJA9sMjv1hwRJDb6mVOPbh6mTpb7C0g3s9Vxurl8DEvnzSAD1sdNyx9fJ6P+xBGI6O88zonv3UENQOd+/+yxDpBlVKC3XoyjJz17P4dRpe1A6uXR0q8zYxiwPEHa8OE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=VU6wzF3m; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="VU6wzF3m" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1736546679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2x5BxF/3ZkUkZ+08VxDfgNb3JHhNGdhbGCSwU27BGaM=; b=VU6wzF3mE866i1no/6U66csETxez/bREQM53MmiNGv1XnD0PmIbPMQpAz7P1cHr+ry40jW 6RMUzfnkgYIoplHz5iotr5rTv8Kd9snuwjrJqwmLPxQE4200bmPgNzApeRG79EpcFVqIDY oWOrLT1Lseiz3xI8SPo8HyEsEA8aMP4= Date: Fri, 10 Jan 2025 17:04:34 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 2/2] of/address: Fix WARN when attempting translating non-translatable addresses To: "Rob Herring (Arm)" , Michael Ellerman , Saravana Kannan Cc: linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250110215030.3637845-1-robh@kernel.org> <20250110215030.3637845-2-robh@kernel.org> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson In-Reply-To: <20250110215030.3637845-2-robh@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 1/10/25 16:50, Rob Herring (Arm) wrote: > The recently added WARN() for deprecated #address-cells and #size-cells > triggered a WARN when of_platform_populate() (which calls > of_address_to_resource()) is used on nodes with non-translatable > addresses. This case is expected to return an error. > > Rework the bus matching to allow no match and make the default require > an #address-cells property. That should be safe to do as any platform > missing #address-cells would have a warning already. > > Fixes: 045b14ca5c36 ("of: WARN on deprecated #address-cells/#size-cells handling") > Signed-off-by: Rob Herring (Arm) > --- > drivers/of/address.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/drivers/of/address.c b/drivers/of/address.c > index c1f1c810e810..8770004d9b08 100644 > --- a/drivers/of/address.c > +++ b/drivers/of/address.c > @@ -340,6 +340,15 @@ static int of_bus_default_flags_match(struct device_node *np) > return of_property_present(np, "#address-cells") && (of_bus_n_addr_cells(np) == 3); > } > > +static int of_bus_default_match(struct device_node *np) > +{ > + /* > + * Check for presence first since of_bus_n_addr_cells() will warn when > + * walking parent nodes. > + */ > + return of_property_present(np, "#address-cells"); > +} > + > /* > * Array of bus specific translators > */ > @@ -384,7 +393,7 @@ static const struct of_bus of_busses[] = { > { > .name = "default", > .addresses = "reg", > - .match = NULL, > + .match = of_bus_default_match, > .count_cells = of_bus_default_count_cells, > .map = of_bus_default_map, > .translate = of_bus_default_translate, > @@ -399,7 +408,6 @@ static const struct of_bus *of_match_bus(struct device_node *np) > for (i = 0; i < ARRAY_SIZE(of_busses); i++) > if (!of_busses[i].match || of_busses[i].match(np)) > return &of_busses[i]; > - BUG(); > return NULL; > } > > @@ -521,6 +529,8 @@ static u64 __of_translate_address(struct device_node *node, > if (parent == NULL) > return OF_BAD_ADDR; > bus = of_match_bus(parent); > + if (!bus) > + return OF_BAD_ADDR; > > /* Count address cells & copy address locally */ > bus->count_cells(dev, &na, &ns); > @@ -564,6 +574,8 @@ static u64 __of_translate_address(struct device_node *node, > > /* Get new parent bus and counts */ > pbus = of_match_bus(parent); > + if (!pbus) > + return OF_BAD_ADDR; > pbus->count_cells(dev, &pna, &pns); > if (!OF_CHECK_COUNTS(pna, pns)) { > pr_err("Bad cell count for %pOF\n", dev); > @@ -703,7 +715,7 @@ const __be32 *__of_get_address(struct device_node *dev, int index, int bar_no, > > /* match the parent's bus type */ > bus = of_match_bus(parent); > - if (strcmp(bus->name, "pci") && (bar_no >= 0)) > + if (!bus || (strcmp(bus->name, "pci") && (bar_no >= 0))) > return NULL; > > /* Get "reg" or "assigned-addresses" property */ Tested-by: Sean Anderson