Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1278561pxb; Thu, 21 Oct 2021 20:15:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvAyl7hcgJKiZ94uyKQYGzu+F0nVb6YKw3Tfhf79/HzH2Zh5deB+3wFbWftwgjUJVavEQv X-Received: by 2002:a17:90b:3ecb:: with SMTP id rm11mr11661919pjb.110.1634872558363; Thu, 21 Oct 2021 20:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634872558; cv=none; d=google.com; s=arc-20160816; b=ZwJFTSGXavn0+vHwn47tYsyAsvY6z6Be7gfZ2RtwkYi3/8UUeKVXd3qUZivxwc3vwG DUGccTz2WXRG6fd2JeVETGSxhep2wcB5Ap4ZVlf5PSaF/gsNoaGg4H5/lhL+f+CheZ6C Y7vT6FAv01xcFCfb74AA/Sd6cEHrL7Sp5teozlfUCSpP4oqimG+4xF2TPJFP4ncfbExl UV2vqT+1vNdv8PpIKgl3gbW8Lt/tOb/DphQtfY0uloykxsBuRswYWhBnWF1dsE3olMlO UkpYMmPkAETzs0LxJve8Crbp88jkh2YIuPLlweVgmvY17Fm/PdiUMMSPGpjvkU87t7F8 rQtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LLNRJiKGUMP7EoEUR5wD7aBtbHYbva/6dCa1Qn54veA=; b=mG+wI3oma98U5FzgzHS+IkRRseAgJ5AQNT/AAtbg0794sxYVHCWPFyayfSCFfRuUF1 o3SVupFHkdAY5u0xsnY5zW+eZeQio6b8IVRFR+hp0wgaf8Po/cOK/r+S5aY9TW5kIOqs NJnWixjQAxbA0RABzuHQLNUMCiigGWuYEwz7azl4j8l4Y+pTdfiydo3KezsFQ0AajojO 12SN8jfAQoFEH7y/KrGcm0HW21x1Fu3SeZiF0PhbnRVwPYzi+dx5hMUfwlfVeH6qZIl5 wA/xqzvhLe8LP5Wpphl+NBVCwc9koj/TW35uwWOTcO2mbvOf/mwhG464RxePtXOyicgm g4Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=IKgkUD9b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si14516458pjg.78.2021.10.21.20.15.44; Thu, 21 Oct 2021 20:15:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=IKgkUD9b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232842AbhJVDPn (ORCPT + 99 others); Thu, 21 Oct 2021 23:15:43 -0400 Received: from thorn.bewilderbeest.net ([71.19.156.171]:32805 "EHLO thorn.bewilderbeest.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232641AbhJVDPm (ORCPT ); Thu, 21 Oct 2021 23:15:42 -0400 Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 949F582; Thu, 21 Oct 2021 20:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1634872404; bh=LLNRJiKGUMP7EoEUR5wD7aBtbHYbva/6dCa1Qn54veA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IKgkUD9bQNVd0XbhImJSr8B9499DdErazMVErWDoirEAEC+tFs0P/BCzyQWEi625B CLioUn/XybYiEDiTPUzYo2PGkG5J08gr84dqq6JWu+2nTxAfL0l15t8F1DEgteW6Mi hdfS4zkF/77d6chq5yp1zOLPgb6rIMlbASLrxKio= Date: Thu, 21 Oct 2021 20:13:19 -0700 From: Zev Weiss To: Rob Herring Cc: Frank Rowand , Greg Kroah-Hartman , OpenBMC Maillist , Jeremy Kerr , Joel Stanley , Andrew Jeffery , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 0/5] driver core, of: support for reserved devices Message-ID: References: <20211022020032.26980-1-zev@bewilderbeest.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 21, 2021 at 07:58:46PM PDT, Rob Herring wrote: >On Thu, Oct 21, 2021 at 9:00 PM Zev Weiss wrote: >> >> Hello all, >> >> This series is another incarnation of a couple other patchsets I've >> posted recently [0, 1], but again different enough in overall >> structure that I'm not sure it's exactly a v2 (or v3). >> >> As compared to [1], it abandons the writable binary sysfs files and at >> Frank's suggestion returns to an approach more akin to [0], though >> without any driver-specific (aspeed-smc) changes, which I figure might >> as well be done later in a separate series once appropriate >> infrastructure is in place. > >I skimmed this, and overall I like the approach. > >> The basic idea is to implement support for a status property value >> that's documented in the DT spec [2], but thus far not used at all in >> the kernel (or anywhere else I'm aware of): "reserved". According to >> the spec (section 2.3.4, Table 2.4), this status: >> >> Indicates that the device is operational, but should not be used. >> Typically this is used for devices that are controlled by another >> software component, such as platform firmware. >> >> With these changes, devices marked as reserved are (at least in some >> cases, more on this later) instantiated, but will not have drivers >> bound to them unless and until userspace explicitly requests it by >> writing the device's name to the driver's sysfs 'bind' file. This >> enables appropriate handling of hardware arrangements that can arise >> in contexts like OpenBMC, where a device may be shared with another >> external controller not under the kernel's control (for example, the >> flash chip storing the host CPU's firmware, shared by the BMC and the >> host CPU and exclusively under the control of the latter by default). >> Such a device can be marked as reserved so that the kernel refrains >> from touching it until appropriate preparatory steps have been taken >> (e.g. BMC userspace coordinating with the host CPU to arbitrate which >> processor has control of the firmware flash). >> >> Patches 1-3 provide some basic plumbing for checking the "reserved" >> status of a device, patch 4 is the main driver-core change, and patch >> 5 tweaks the OF platform code to not skip reserved devices so that >> they can actually be instantiated. >> >> One shortcoming of this series is that it doesn't automatically apply >> universally across all busses and drivers -- patch 5 enables support >> for platform devices, but similar changes would be required for >> support in other busses (e.g. in of_register_spi_devices(), >> of_i2c_register_devices(), etc.) and drivers that instantiate DT >> devices. Since at present a "reserved" status is treated as >> equivalent to "disabled" and this series preserves that status quo in >> those cases I'd hope this wouldn't be considered a deal-breaker, but >> a thing to be aware of at least. >> >> Greg: I know on [1] you had commented nack-ing the addition of boolean >> function parameters; patch 4 adds a flags mask instead in an analogous >> situation. I'm not certain how much of an improvement you'd consider >> that (hopefully at least slightly better, in that the arguments passed >> at the call site are more self-explanatory); if that's still >> unsatisfactory I'd welcome any suggested alternatives. > >Can't we add a flag bit in struct device to reflect manual binding? >bind will set it and unbind clears it. > I considered this (and actually drafted up a version that did exactly that), but it seemed like turning a parameter-passing problem into a state-maintenance problem (finding all the places that flag would need to be cleared and ensuring newly-added ones don't get missed, which unlike a function parameter the compiler can't really check for us). Given that the live range (definition to use) of that value is entirely within the codepath of a single call-chain (bind_store() -> device_driver_attach() -> __driver_probe_device()), continuing to maintain that state beyond that call chain seemed like unnecessary complexity to me, but if there's a consensus that that would actually be preferable I can certainly do it that way instead. Zev