Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1479363pxb; Fri, 22 Oct 2021 01:35:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmJBQJ1k2J+sFZzoo+5vcKop6DZI77nbG7Ntwbgsn5jW/aaZMIspY+LsCmN5/7RDAY9oUs X-Received: by 2002:a17:906:9501:: with SMTP id u1mr13247899ejx.496.1634891706903; Fri, 22 Oct 2021 01:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634891706; cv=none; d=google.com; s=arc-20160816; b=LGQzNqwfh9sCCe1N+H/+6LklfdOY8g3QdJaaonR8YJkdIyKAvuwnwKsWjnx7dfXohz pAGXeHytNl96ve1863zZKcUlWGVwH0FhalFzh3XbmO73TVfrk4qbWNSqbGNBFLErKsE5 oI3lHCqQ1VGrq3uwsUgxuHKs9Kb1XTnSmCEVQcvE4IZDHFVh7ekR6i2XFLpXaPQqwdau VJWcKGD3p+IS9G1CtgF6Otf6/r/V2Y6azA9W+WQ6uKjpemCqLTxgNooKZgbyRAy3M6Ug V3s+Dk4Rmywpbvgvxt/tXFp75nuF8AJDRd0fUoE7yebGbIQYGRmihUjeTt4sCSjW2I+u 0saQ== 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=lqkbfmixKdAIZ7NwTV3pl1HORUZPPAa/zIkOK6+t7Qk=; b=WUnUVOJ62L49Tei3vAoFz6NHQ2nigoDlasxwnx1GjW/6Iv5dV2vnDkolo6k4ffPMvn e7Pf++luBjCscne9WWIqBANOPdYFga8W4nWpRxGWaQ0+Bgw9iUAdXuiRe2lI6wfyLUA4 HrVfeOOdD5+r1NcxOTqtQjy2jUnAcckznH26KVkonTjRL9PikCsja9DxJn6NpKe7SF1T xfppXgFT6nvcZ4i0AN4L16EosbsKDveHJmMwhi6/F4tzZROdfrFKsexlrhABRRQwu9Ug iL73THm5nlJ0GOsRhe3smTL6R030Y1IFM3ofp6vTwdKQRNSxm+tPPmeMW1vdbODUb3WD NjaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=d+0rlGtH; 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 rp18si10084709ejb.316.2021.10.22.01.34.43; Fri, 22 Oct 2021 01:35:06 -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=d+0rlGtH; 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 S232268AbhJVIex (ORCPT + 99 others); Fri, 22 Oct 2021 04:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbhJVIew (ORCPT ); Fri, 22 Oct 2021 04:34:52 -0400 X-Greylist: delayed 23504 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 22 Oct 2021 01:32:35 PDT Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [IPv6:2605:2700:0:5::4713:9cab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15CADC061764; Fri, 22 Oct 2021 01:32:35 -0700 (PDT) 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 232EF3F5; Fri, 22 Oct 2021 01:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1634891554; bh=lqkbfmixKdAIZ7NwTV3pl1HORUZPPAa/zIkOK6+t7Qk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d+0rlGtHbliW+JQVt48EXvy4ih5dfAUHhgt01WK90mdgJdnnPcQ3kB2PeuNRh8uQO F41f+zSfFacuPovblAYpvxD6OjWmzOYPirEiAEf1JRZ/8a+q8L8RXIuiBEkKtibrda //21v1EIHl5bio+r9+6Q1C83qvYMwareZ0BwmBGk= Date: Fri, 22 Oct 2021 01:32:32 -0700 From: Zev Weiss To: Greg Kroah-Hartman Cc: Frank Rowand , Rob Herring , openbmc@lists.ozlabs.org, Jeremy Kerr , Joel Stanley , Andrew Jeffery , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Dave Jiang , Vinod Koul , Kirti Wankhede , Alex Williamson , Cornelia Huck , Saravana Kannan , Konrad Rzeszutek Wilk , Thomas Gleixner , Bhaskar Chowdhury , Jianxiong Gao , Mauro Carvalho Chehab , Rajat Jain , Andy Shevchenko , dmaengine@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH 4/5] driver core: inhibit automatic driver binding on reserved devices Message-ID: References: <20211022020032.26980-1-zev@bewilderbeest.net> <20211022020032.26980-5-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 11:46:56PM PDT, Greg Kroah-Hartman wrote: >On Thu, Oct 21, 2021 at 07:00:31PM -0700, Zev Weiss wrote: >> Devices whose fwnodes are marked as reserved are instantiated, but >> will not have a driver bound to them unless userspace explicitly >> requests it by writing to a 'bind' sysfs file. This is to enable >> devices that may require special (userspace-mediated) preparation >> before a driver can safely probe them. >> >> Signed-off-by: Zev Weiss >> --- >> drivers/base/bus.c | 2 +- >> drivers/base/dd.c | 13 ++++++++----- >> drivers/dma/idxd/compat.c | 3 +-- >> drivers/vfio/mdev/mdev_core.c | 2 +- >> include/linux/device.h | 14 +++++++++++++- >> 5 files changed, 24 insertions(+), 10 deletions(-) > >Ugh, no, I don't really want to add yet-another-state to the driver core >like this. Why are these devices even in the kernel with a driver that >wants to bind to them registered if the driver somehow should NOT be >bound to it? Shouldn't all of that logic be in the crazy driver itself >as that is a very rare and odd thing to do that the driver core should >not care about at all. > >And why does a device need userspace interaction at all? Again, why >would the driver not know about this and handle it all directly? > Let me expand a bit more on the details of the specific situation I'm dealing with... On a server motherboard we've got a host CPU (Xeon, Epyc, POWER, etc.) and a baseboard management controller, or BMC (typically an ARM SoC, an ASPEED AST2500 in my case). The host CPU's firmware (BIOS/UEFI, ME firmware, etc.) lives in a SPI flash chip. Because it's the host's firmware, that flash chip is connected to and generally (by default) under the control of the host CPU. But we also want the BMC to be able to perform out-of-band updates to the host's firmware, so the flash is *also* connected to the BMC. There's an external mux (controlled by a GPIO output driven by the BMC) that switches which processor (host or BMC) is actually driving the SPI signals to the flash chip, but there's a bunch of other stuff that's also required before the BMC can flip that switch and take control of the SPI interface: - the BMC needs to track (and potentially alter) the host's power state to ensure it's not running (in OpenBMC the existing logic for this is an entire non-trivial userspace daemon unto itself) - it needs to twiddle some other GPIOs to put the ME into recovery mode - it needs to exchange some IPMI messages with the ME to confirm it got into recovery mode (Some of the details here are specific to the particular motherboard I'm working with, but I'd guess other systems probably have broadly similar requirements.) The firmware flash (or at least the BMC's side of the mux in front of it) is attached to a spi-nor controller that's well supported by an existing MTD driver (aspeed-smc), but that driver can't safely probe the chip until all the stuff described above has been done. In particular, this means we can't reasonably bind the driver to that device during the normal device-discovery/driver-binding done in the BMC's boot process (nor do we want to, as that would pull the rug out from under the running host). We basically only ever want to touch that SPI interface when a user (sysadmin using the BMC, let's say) has explicitly initiated an out-of-band firmware update. So we want the kernel to be aware of the device's existence (so that we *can* bind a driver to it when needed), but we don't want it touching the device unless we really ask for it. Does that help clarify the motivation for wanting this functionality? Thanks, Zev