From owner-svn-src-all@FreeBSD.ORG Sat Sep 6 15:45:10 2014 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DC145E2B; Sat, 6 Sep 2014 15:45:10 +0000 (UTC) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B35214C2; Sat, 6 Sep 2014 15:45:09 +0000 (UTC) Received: from [73.34.117.227] (helo=ilsoft.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1XQIAn-000G58-2S; Sat, 06 Sep 2014 15:45:09 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by ilsoft.org (8.14.9/8.14.9) with ESMTP id s86Fj8pe015621; Sat, 6 Sep 2014 09:45:08 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 73.34.117.227 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1+qymkkWQ6IPjrKnljNoaYQ X-Authentication-Warning: paranoia.hippie.lan: Host revolution.hippie.lan [172.22.42.240] claimed to be [172.22.42.240] Subject: Re: svn commit: r271190 - head/sys/dev/ofw From: Ian Lepore To: Nathan Whitehorn In-Reply-To: <540B2A94.4090201@freebsd.org> References: <201409061511.s86FBZAB050025@svn.freebsd.org> <540B2783.9020808@freebsd.org> <1410017676.1150.356.camel@revolution.hippie.lan> <540B2A94.4090201@freebsd.org> Content-Type: text/plain; charset="us-ascii" Date: Sat, 06 Sep 2014 09:45:07 -0600 Message-ID: <1410018307.1150.358.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Sep 2014 15:45:11 -0000 On Sat, 2014-09-06 at 08:39 -0700, Nathan Whitehorn wrote: > On 09/06/14 08:34, Ian Lepore wrote: > > On Sat, 2014-09-06 at 08:25 -0700, Nathan Whitehorn wrote: > >> What is this for? The way the specification works here explicitly > >> requires this fallback. > >> -Nathan > >> > > It's for determining whether there is an entry in the device<->xref > > list. If a node has no xref phandle property there will be no entry for > > it in the list and thus no way to record or retrieve a device > > association. I found myself coding the "if it has a phandle, or an > > ibm,phandle, or a linux,phandle" incantation, then realized that all > > that figuring-out work was done at init time when the xref list is > > built, I just needed a way to get the result. > > This isn't true. On most but not all real OF systems, which use, or will > use, the same mechanism, there is no distinction between "regular" and > "cross-reference" phandles and device tree cross-references still exist > with no explicit phandle property. So registering a device without a > phandle property has to to work, and has to fall back to the regular > phandle 100% of the time. > Oh. That wasn't clear when you helped me last week with the xref list stuff. I'll have to rework that a bit to meet the requirements you list above. -- Ian > What may be true is that no single device tree has a mixture of implicit > and explicit cross-reference handles, so you could set a flag or > something. But it's probably not worth it. Do you have a concrete > example where you cared about this? > -Nathan > > > -- Ian > > > >> On 09/06/14 08:11, Ian Lepore wrote: > >>> Author: ian > >>> Date: Sat Sep 6 15:11:35 2014 > >>> New Revision: 271190 > >>> URL: http://svnweb.freebsd.org/changeset/base/271190 > >>> > >>> Log: > >>> Add OF_xref_from_node_strict() which returns -1 if there is no xref handle > >>> for the node. The default routine returns the untranslated handle, which > >>> is sometimes useful, but sometimes you really need to know there's no > >>> entry in the xref<->node<->device translation table. > >>> > >>> Modified: > >>> head/sys/dev/ofw/openfirm.c > >>> head/sys/dev/ofw/openfirm.h > >>> > >>> Modified: head/sys/dev/ofw/openfirm.c > >>> ============================================================================== > >>> --- head/sys/dev/ofw/openfirm.c Sat Sep 6 13:21:07 2014 (r271189) > >>> +++ head/sys/dev/ofw/openfirm.c Sat Sep 6 15:11:35 2014 (r271190) > >>> @@ -554,15 +554,15 @@ OF_node_from_xref(phandle_t xref) > >>> return (node); > >>> } > >>> > >>> -phandle_t > >>> -OF_xref_from_node(phandle_t node) > >>> +static phandle_t > >>> +xref_from_node(phandle_t node, phandle_t notfoundvalue) > >>> { > >>> struct xrefinfo *xi; > >>> phandle_t xref; > >>> > >>> if (xref_init_done) { > >>> if ((xi = xrefinfo_find(node, FIND_BY_NODE)) == NULL) > >>> - return (node); > >>> + return (notfoundvalue); > >>> return (xi->xref); > >>> } > >>> > >>> @@ -570,10 +570,24 @@ OF_xref_from_node(phandle_t node) > >>> -1 && OF_getencprop(node, "ibm,phandle", &xref, > >>> sizeof(xref)) == -1 && OF_getencprop(node, > >>> "linux,phandle", &xref, sizeof(xref)) == -1) > >>> - return (node); > >>> + return (notfoundvalue); > >>> return (xref); > >>> } > >>> > >>> +phandle_t > >>> +OF_xref_from_node(phandle_t node) > >>> +{ > >>> + > >>> + return (xref_from_node(node, node)); > >>> +} > >>> + > >>> +phandle_t > >>> +OF_xref_from_node_strict(phandle_t node) > >>> +{ > >>> + > >>> + return (xref_from_node(node, -1)); > >>> +} > >>> + > >>> device_t > >>> OF_device_from_xref(phandle_t xref) > >>> { > >>> > >>> Modified: head/sys/dev/ofw/openfirm.h > >>> ============================================================================== > >>> --- head/sys/dev/ofw/openfirm.h Sat Sep 6 13:21:07 2014 (r271189) > >>> +++ head/sys/dev/ofw/openfirm.h Sat Sep 6 15:11:35 2014 (r271190) > >>> @@ -128,10 +128,12 @@ ssize_t OF_package_to_path(phandle_t no > >>> * Some OF implementations (IBM, FDT) have a concept of effective phandles > >>> * used for device-tree cross-references. Given one of these, returns the > >>> * real phandle. If one can't be found (or running on OF implementations > >>> - * without this property), returns its input. > >>> + * without this property), OF_xref_from_node() returns its input, while the > >>> + * strict version returns -1. > >>> */ > >>> phandle_t OF_node_from_xref(phandle_t xref); > >>> phandle_t OF_xref_from_node(phandle_t node); > >>> +phandle_t OF_xref_from_node_strict(phandle_t node); > >>> > >>> /* > >>> * When properties contain references to other nodes using xref handles it is > >>> > > > >