Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1779527ybv; Sun, 23 Feb 2020 15:12:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwA/FHN5TB7s0b1mAmTWa0qy+On7rhovd43XJAzJY7mq0QoZHU1binb24+RF2aCpTh8jaiI X-Received: by 2002:a9d:20a:: with SMTP id 10mr36651815otb.319.1582499544625; Sun, 23 Feb 2020 15:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582499544; cv=none; d=google.com; s=arc-20160816; b=00x3MjJ8rUde70PTAMwb911pfqn3QT9SiIbaJigb+3MDDosBN3oqEIi6O6UBBi3A2r 0u+ix5LEUCIiyaL/msvn4FQWb3Y4rsrEHybjfwAw+sRDsArtiz1AzvhNSg/1JsOYugXT wOaeKNd8qrbTl99zfbeKczo89/+xPi8cuE4LkcskWUcbPhOjB4pcIltl3icvtPsDycoX Px2o9vEJrVmuHyeOriIxA4vmN+Ntpo3/BT+XxyJf6h4ZZYdT0s/4KGstWfvhCTyaXpem D75g6whfBNHNxvnZacxWdX8pFtzgWrSCitRErKsWIcFRkRF9r531eFLyYgoTyFX2v+P/ 6fmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ZQRcpAKJNzYRbATqxRb61dtd80r9bLPYMz2uvZimt/4=; b=Os4Af2gmjjheELfmshWtQAk3ICDBZRs5Y5OtiDVBLNjj8n2i8xqt+o1JN10Fn3MpJt XZov6AM9rpQ+sesj8CDUQ83GtIFSKzVdlBpDVFh+NQ7H9+uG/bh5oAbWDsGyCXQjkZsy /WlCSps8/zYZOhs+omi4Qn+n1nkdz2V0bgz92HT1kfsdnmGEv2KADl5dH5myL5d6FUEx BT2LTgFAfxCG0BgOKyLs/5ZbExrkKc/RIwalPlREmn/WE78nSIj7u885cGT42xh7YY2+ J7KHeJMEZILWCa5jmNVbUebCVXXGO8ekGxtNgFBVtg4SReoN8OtNAFgqOlc9dlywDbIG ocZg== 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 v6si5202831ota.19.2020.02.23.15.12.00; Sun, 23 Feb 2020 15:12:24 -0800 (PST) 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 S1727156AbgBWXLR (ORCPT + 99 others); Sun, 23 Feb 2020 18:11:17 -0500 Received: from hostingweb31-40.netsons.net ([89.40.174.40]:50009 "EHLO hostingweb31-40.netsons.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbgBWXLR (ORCPT ); Sun, 23 Feb 2020 18:11:17 -0500 Received: from [78.134.20.33] (port=59608 helo=[192.168.77.67]) by hostingweb31.netsons.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1j60P0-00FBU2-SK; Mon, 24 Feb 2020 00:11:10 +0100 Subject: Re: [RFC PATCH 3/7] i2c: allow DT nodes without 'compatible' To: Geert Uytterhoeven , Wolfram Sang Cc: Linux I2C , Linux-Renesas , linux-i3c@lists.infradead.org, Kieran Bingham , =?UTF-8?Q?Niklas_S=c3=b6derlund?= , Jacopo Mondi , Laurent Pinchart , Vladimir Zapolskiy , Linux Kernel Mailing List , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Alexandre Belloni References: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> <20200220172403.26062-4-wsa+renesas@sang-engineering.com> From: Luca Ceresoli Message-ID: Date: Mon, 24 Feb 2020 00:11:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca@lucaceresoli.net X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 21/02/20 10:45, Geert Uytterhoeven wrote: > Hi Wolfram, > > On Thu, Feb 20, 2020 at 6:26 PM Wolfram Sang > wrote: >> Sometimes, we have unknown devices in a system and still want to block >> their address. For that, we allow DT nodes with only a 'reg' property. >> These devices will be bound to the "dummy" driver but with the name >> "reserved". That way, we can distinguish them and even hand them over to >> the "dummy" driver later when they are really requested using >> i2c_new_ancillary_device(). >> >> Signed-off-by: Wolfram Sang Cc:ing Alexandre who raised the need for a described-but-disabled I2C node. > Thanks for your patch! > > Reviewed-by: Geert Uytterhoeven > but one question below. > >> --- a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt >> +++ b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt >> @@ -50,7 +50,6 @@ Examples: >> reg-io-width = <1>; /* 8 bit read/write */ >> >> dummy@60 { >> - compatible = "dummy"; >> reg = <0x60>; >> }; >> }; > > There's a second instance to remove 18 lines below. > >> --- a/drivers/i2c/i2c-core-of.c >> +++ b/drivers/i2c/i2c-core-of.c >> @@ -27,17 +27,15 @@ int of_i2c_get_board_info(struct device *dev, struct device_node *node, >> >> memset(info, 0, sizeof(*info)); >> >> - if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) { >> - dev_err(dev, "of_i2c: modalias failure on %pOF\n", node); >> - return -EINVAL; >> - } >> - >> ret = of_property_read_u32(node, "reg", &addr); >> if (ret) { >> dev_err(dev, "of_i2c: invalid reg on %pOF\n", node); >> return ret; >> } >> >> + if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) >> + strlcpy(info->type, I2C_RESERVED_DRV_NAME, sizeof(I2C_RESERVED_DRV_NAME)); > > Could this cause a regression, e.g. if people already have such dummy > nodes in their DTS, and use sysfs new_device from userspace to > instantiate the device later? Such a DTS would be illegal because "compatible" has been a required property so far. Thus one could leave such people out in the cold because they went on an unsupported path. Not super nice anyway. However I'd like to view the issue from the DT point of view. DT describes the hardware, and it is possible (and even desirable) that the firmware provides the DTB independently from the OS, and the kernel consumes it. It this scenario, firmware could and should describe all I2C slaves with proper "compatible" property, and there is no way to remove it, in a clean way at least. But the kernel currently ignores nodes that have no matching driver, right? So in this case the kernel knows that that address is used, but ignores this information and considers the address as available. Seen in this perspective, we should have a "compatible" for all nodes: it is just describing the hardware and could be out of the kernel control. But instead of discarding all nodes without a matching driver, the i2c-core-of code should mark them as "reserved". Does it sound correct? Clearly this does not fit the case reported by Alexandre: a device having a driver which is known to be badly buggy, so we don't want to instantiate it. But again, this should not affect DT as it is not describing the HW, but only an implementation detail. Probably disabling or blacklisting the driver would be a better option there? My apologies to Wolfram, I appreciate a lot the effort you are doing, but before reviewing this patch I have never realized what I tried to explain above. -- Luca