Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1112285pxb; Wed, 29 Sep 2021 17:37:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn21UvD17s3LT2HGhX29gL6H1DmUKm6JrlCxgVdG471sGrd9y1DtufPyAa1FHlkqlsCmxL X-Received: by 2002:a63:d1d:: with SMTP id c29mr2433971pgl.106.1632962270664; Wed, 29 Sep 2021 17:37:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632962270; cv=pass; d=google.com; s=arc-20160816; b=VRdDLNjR8socJyz3KMcxITkcFY9mWqfL58LaECPv8mNIblPo5H/MOt/fJeJooS1VCl x1/tPOIFk1HZJ6sBTfePcHx6P8YaLcp4vZW0IiIJmj4GJQ3HFNjQFMOqd/MX16DKCSyD nfpXv29e3CX9PgAsQ9U2d3JCRQYMtWqJp0WNHwDLdbazh4OrhT45qxKWKy1OzBG+7kOB amyPet4AunBsZbdvYYXpu30pZimvyGvqFt9umjVGohE/0NLJgrYyhMMmaPeDYMyTu9zh x9nF64dJOUcugYo8JMUXluEvf/IPI+lsbS2IMYu18wwDgbAi6tUdADbux9NDQGfo9Btg UgvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=nAd3hC6+9tYVMt8Hq06dVqDUgM3EOvSCsg7PgsPCOtw=; b=SMEeNuBsq97QyM5KtQ8eHGnTQcPMjFTCCK0AbCRH6l67y8Bm0QBI4HKPyFLIPZTaW2 QTg+xD/ePcqcjCQ2F2AnZSGFJIh9VG83KaIc1BbsaRd1rd6dKMoJ2CNz9uEKKLLcC4A8 mltm8e2kx74KQAz6jLZRjdEmqmUfVy/VTlOZDvE7HvFPxKrnpvAiwan5b2fsu8NN/iKn ZjiAPOu7zpvolz4cUmYAHLKg6UGEURQVNKdnrqwGJYfoQoAABUhpiD9FYdQ0UVXDdopv lAK1qxdXXFiMqncdqta40b4tZq7ulyCdw00XNzQU5+jVebntcnd26a1/2/yUoQXZeJrn CAYA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@equinix.com header.s=pps202002 header.b=hJVh2Ug8; arc=pass (i=1 spf=pass spfdomain=equinix.com dkim=pass dkdomain=equinix.com dmarc=pass fromdomain=equinix.com); 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=equinix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si1607539pgf.144.2021.09.29.17.37.37; Wed, 29 Sep 2021 17:37:50 -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=@equinix.com header.s=pps202002 header.b=hJVh2Ug8; arc=pass (i=1 spf=pass spfdomain=equinix.com dkim=pass dkdomain=equinix.com dmarc=pass fromdomain=equinix.com); 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=equinix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345843AbhI2Xl7 (ORCPT + 99 others); Wed, 29 Sep 2021 19:41:59 -0400 Received: from mx0b-00268f01.pphosted.com ([148.163.159.192]:1032 "EHLO mx0b-00268f01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345040AbhI2Xlz (ORCPT ); Wed, 29 Sep 2021 19:41:55 -0400 X-Greylist: delayed 5924 seconds by postgrey-1.27 at vger.kernel.org; Wed, 29 Sep 2021 19:41:55 EDT Received: from pps.filterd (m0105197.ppops.net [127.0.0.1]) by mx0a-00268f01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18TIrWRW015642; Wed, 29 Sep 2021 22:00:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=equinix.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pps202002; bh=nAd3hC6+9tYVMt8Hq06dVqDUgM3EOvSCsg7PgsPCOtw=; b=hJVh2Ug8L75PAl2bDPF6TVfF2QMbsIxYqhPiB+cKb+nHlGTtK95HapdboS5OX8odMawL EfPjsiwVrXogCWLSSR+tL4EyorHZ4sQGWKr5TOgH0oLSvCeC9jl7HdP5vfSMbEqTfIh7 qi5RBFzU0Hm5fUvDeFDA9Y/wk0VKaHUppM+XflcleRjIevJr/fTLG7Y2YqdjMoC7tfRI 5HWjjB4AH8JtkRcNrCYbN4EkST8rWwypQDIgF1yQJAOnIR+OS63+JfGWascEpFRTOdl6 FgPsIDYxzJNpK47Jl3jqQP0kJXdVtf65p5KLHzJ+wPNBrRlaZJCmiZQGF7mqxqnoPYQR Rg== Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2106.outbound.protection.outlook.com [104.47.55.106]) by mx0a-00268f01.pphosted.com with ESMTP id 3bcwtg8gds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Sep 2021 22:00:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PkfzAwXsAMcYz3l0vvm/Ovu1aLxPfu2szw2qoVUZDeFqAnyAl0HPX0+4Hr/502Z2NobkbNEtTd2PehHP6OOVl/1wK6sLERK5EaLqPtaj5HJRTaFCMFCg/sMZVeKRjO6jmzPukZrBZwQxsteUadncGBCIe+TQRSgWMNcvw4cDYjXLQbhbpZ89tHoaVM2RrxSAq30Ed3AljBRBd9q3Hr3li0VgCXsTp7EfgEt1UefaRmcqnFL4KBox4n59o3bpJ3ng3ugLQA3/wF+UVXzgN7Gfx1gJD402v2glpKDrgeTWk6PrNLq32vimcZE5dH7WrQj+Vp0wSWfK38+FpvlNcpSVKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nAd3hC6+9tYVMt8Hq06dVqDUgM3EOvSCsg7PgsPCOtw=; b=Cj08KNkBbxZ75iORZfPtZqSZv9OD0B29dZcQVfbrz8z7hrDizheV5W4Pq0HaCicoyjj8atFyP0hszfIN6s43Zqu2CGLmnVy9va88u+l3bCCnffw2Gr0OlAmDzvZxtnBlGbhkSzIXrF8KO64OAStJvaVYNRxP1u4lCZ2bAWNKEBanSsSlShjfmr2NwajnZWSrU6yVI6thog/Z6xEg0ww1wKzHtoHDARfUOFh5sxEYc6z2mHKoLppRT8IuYPxhbDaFpB3WETgbZvzCvrMMVYyAo9Z5CnNdZPpPIa5HU47wp08QA35VJYPvvNlje6icaXlaW/mtaRwPFHiDd4afRLSdOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=equinix.com; dmarc=pass action=none header.from=equinix.com; dkim=pass header.d=equinix.com; arc=none Received: from DM8PR04MB8007.namprd04.prod.outlook.com (2603:10b6:5:314::20) by DM8PR04MB8183.namprd04.prod.outlook.com (2603:10b6:8:2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Wed, 29 Sep 2021 22:00:39 +0000 Received: from DM8PR04MB8007.namprd04.prod.outlook.com ([fe80::8049:f2d5:9bed:efa0]) by DM8PR04MB8007.namprd04.prod.outlook.com ([fe80::8049:f2d5:9bed:efa0%6]) with mapi id 15.20.4544.021; Wed, 29 Sep 2021 22:00:39 +0000 From: Zev Weiss To: Rob Herring CC: Zev Weiss , "devicetree@vger.kernel.org" , Vignesh Raghavendra , linux-aspeed , Tudor Ambarus , Andrew Jeffery , Greg Kroah-Hartman , OpenBMC Maillist , "linux-kernel@vger.kernel.org" , Richard Weinberger , Michael Walle , MTD Maling List , Miquel Raynal , Jeremy Kerr , Frank Rowand , Pratyush Yadav , linux-arm-kernel , =?iso-8859-1?Q?C=E9dric_Le_Goater?= Subject: Re: [PATCH 0/6] Dynamic aspeed-smc flash chips via "reserved" DT status Thread-Topic: [PATCH 0/6] Dynamic aspeed-smc flash chips via "reserved" DT status Thread-Index: AQHXtX1wzF3QB0SC6EG5ofzLnY2pNQ== Date: Wed, 29 Sep 2021 22:00:39 +0000 Message-ID: <20210929220038.GS17315@packtop> References: <20210929115409.21254-1-zev@bewilderbeest.net> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=equinix.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 90de20b3-e77b-47e5-9080-08d9839492f8 x-ms-traffictypediagnostic: DM8PR04MB8183: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: U4MJaYK8P7N5cy9b0b+NisAEZmqXCzs34R24DkWmKA6jUaVklVY2mFLX3qT9AmKPo8R3IvZQ5IobhUDoxNCRAt/1X9leVfJoySvVS8TRnBO8dNv9wzdcOx27AK/LYUhZtC+sUZgKz3EfYee+Xnb/Ld6vUCY+buqMHAqt+q/TIRAB/SMhopUAqLkiwmXiO+JJVINQKtJm1VJzGcPlAia7z1Xo3UBw2doykoY6cKuJ26GlaJAU5fNCxXEn1l66P738GDtL9kxWPVS0NQ/Hsy9OcAzejYohx+2YJRRf5wIVFr/KUBPe8/AyGuTZ0C4DV7GS+pedA/9sM8VC1FilYLI0ZgObucdkOlBaL4lPOF8WKpUu0zm1hs/APfDNbr75vwyytgODlIC3PUDC3CS+zsVtDMbf19IGQff6wfZUwWV+3Jza/TJoindPhKj+RIkVgUCS4GyqwOYUHpzBJ/eiKwe75XStx0BDvvlqQ0EqDK6ai2V+Qrm4yfQrOEwiMZ1Vz9Q+4wy3i2jLAgVP19VcSvz3avpck5bs3HgkeU8vwG/c24BWtEJp4gnJ9jfQJZlfmkZxW6q/p81ZATYwbQzFpg1UY7GH7hVs1fXIeiVz0fJI7lwz0bXfo8WZgGdoCOlBwKmjx/bvyOG/GJtjpbKT+rO7r3d5WGhYz2ihZqneyOawnbXF5KBjyqjCbrRUN6yiOJ9NMg7Kf9de+LOvlbDDNiU3SA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR04MB8007.namprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(7916004)(366004)(6512007)(9686003)(6506007)(5660300002)(4326008)(122000001)(38100700002)(38070700005)(83380400001)(71200400001)(186003)(66946007)(33716001)(66446008)(64756008)(91956017)(76116006)(7416002)(66476007)(66556008)(2906002)(8676002)(1076003)(33656002)(316002)(54906003)(26005)(6486002)(8936002)(86362001)(508600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ljRbOsUboRe/8iu0ep+lQ/qFOqJxnQwpG0o33FS3Lni4pm7fba5RVD+Ui2?= =?iso-8859-1?Q?UtYQmwoB61kWC736GvyXaetGStHOLoxK8ewRUiWQPDqLeQkgM1ECdEQA53?= =?iso-8859-1?Q?hD2iU19SCaGmysba8Ho2ma5NeQsPopEcfgFf6HJ5nsFDcRqIvqOmmxZ/2e?= =?iso-8859-1?Q?k25cgYptwuj8q1QHvs+3WedYhaRUOnLprhhaZT62LB8hU7wfwCu6fmNtML?= =?iso-8859-1?Q?/nOVVdNNZ01vbIcJzN92nKGf5iIWGZTBDueDtg2Kv2CV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RV3iHoQXgSKzB3u3Bjhemxkt4zAsnRZlT1fU?= =?iso-8859-1?Q?VENNM9hZ62mZCtEv85IqOyeiIP+XUpOgJRktkuc7ZLOZmzWlK/xy1XEfxX?= =?iso-8859-1?Q?PyMIu4r2DVA++T7cvTNsc9NtYPrD+mDvy1Qqyr29M2MKf8V3O53BuCmz3Q?= =?iso-8859-1?Q?k+yxJW2a0QCR6hyf7UqaliraS2InXPfc6XZWRoJIu0iut+U3P3UBwiJDdB?= =?iso-8859-1?Q?N/mdhJ8RGE?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-ID: <3B0506D33DDF9740BD32F9BD8AD1A497@namprd04.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: equinix.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR04MB8007.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90de20b3-e77b-47e5-9080-08d9839492f8 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Sep 2021 22:00:39.2364 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72adb271-2fc7-4afe-a5ee-9de6a59f6bfb X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: RSU8YrEecd5C1VM+hfHQI3R53GNHQbOarcBzPrj3Afw4wl/FaOuu+5AjN8udmAHPOSG6Iq1EdQkFZbmzCPdEMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR04MB8183 X-Proofpoint-ORIG-GUID: LWeCFegyco8CltO6ZFaikpLoY6R7LGlZ X-Proofpoint-GUID: LWeCFegyco8CltO6ZFaikpLoY6R7LGlZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-29_08,2021-09-29_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 priorityscore=1501 adultscore=0 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2109290130 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 09:08:03AM PDT, Rob Herring wrote: >On Wed, Sep 29, 2021 at 6:54 AM Zev Weiss wrote: >> >> Hello, >> >> This patch series aims to improve a scenario that arises in OpenBMC >> and which isn't handled very well at the moment. Certain devices, the >> example at hand being the flash chip used to store the host's firmware >> (e.g. the BIOS), may be shared between the BMC and the host system but >> only available to one or the other at any given time. The device may >> thus be effectively off-limits to the BMC when it boots, and only >> usable after userspace performs the necessary steps to coordinate >> appropriately with the host (tracking its power state, twiddling >> GPIOs, sending IPMI commands, etc.). >> >> Neither the "okay" nor the "disabled" device-tree status values works >> nicely for the flash device this case -- an "okay" device gets probed >> automatically as soon as the device and a driver for it are available, >> and a "disabled" one gets forgotten about entirely, whereas we want >> the BMC's kernel to be aware of the existence of the device, but not >> try to actually do anything with it (i.e. probe it) until explicitly >> requested to do so by userspace. > >While Linux treats 'disabled' as gone forever, that's not exactly what >the spec says. Either disabled or reserved could change in theory. But >I do agree 'reserved' is the right choice for your use. True -- the spec's description of "disabled" also sounds like it could be an appropriate fit for this case, but the existing (somewhat different) interpretation in the kernel is well-established enough that I figured that ship had sailed. > >> However, while there's no support for it currently in the kernel tree, >> the device-tree spec [0] also lists "reserved" as a possible status >> value, and its description seems like a fairly reasonable fit for this >> situation: >> >> 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. >> >> These patches start making use of this status value in the aspeed-smc >> driver. The first patch adds a companion routine to >> of_device_is_available() that checks for a "reserved" status instead >> of "okay". The second patch is a small MTD adjustment to allow an >> unregistered device to be cleanly re-registered. Patches 3 through 5 >> modify the aspeed-smc driver to allow individual chips to be attached >> and detached at runtime, and to avoid automatically attaching any >> marked as reserved. Finally, patch 6 employs the newly-supported >> status in adding support for the BIOS flash device to the ASRock Rack >> e3c246d4i BMC. > >I'm not sure this should be MTD specific. There's other cases where we >may want devices to become available. So the question is whether there >should be a more generic mechanism rather than each subsystem coming >up with their own thing. > Agreed, and in fact in an earlier version of these patches I had approached this via a more generic tweak to the driver-core code to inhibit attaching drivers to devices marked as reserved. The problem I had with that is that it ended up being kind of limited in how far down the device tree it would actually take effect. For example in this particular case, I could mark the entire aspeed-smc controller as reserved and prevent the driver core from binding the driver to it, but nothing more fine-grained than that. If I marked an individual flash chip behind that controller as reserved, the aspeed-smc driver would get attached (as expected), but that driver (not the driver core) is responsible for inspecting its child devices and attaching them, and its existing probe routine only checks of_device_is_available() and hence can't distinguish between reserved and disabled. So while I should probably reincorporate the corresponding driver-core change, I don't see it as a complete solution, and I don't see an obvious way to achieve one centrally without requiring modifications in individual drivers, unfortunately. >There's out of tree support for applying overlays which could be used >here. The issue with it is we don't want it to be unconstrained where >an overlay can make any change anywhere in a DT. > Yeah, I'm vaguely aware of the dt-overlay patches, but had been under the impression that their prospects for mainlining were fairly dim and hence was looking at alternate approaches (of somewhat more limited scope). >Another possibility is making 'status' writeable from userspace. It is >just a sysfs file. That too may need to be opt-in. > The sysfs file you're referring to being those under /sys/firmware/devicetree I assume? That's an interesting idea...in addition to making it opt-in, we'd presumably need to restrict what state transitions are allowed (maybe only okay<->reserved?). Keeping /sys/firmware/fdt in sync with that seems like it might be a bit of a headache though...perhaps that would just remain a static reflection of whatever the state was at boot? Thanks, Zev