From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8273ED216AC for ; Tue, 15 Oct 2024 14:20:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D38CD6B007B; Tue, 15 Oct 2024 10:19:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE9436B0082; Tue, 15 Oct 2024 10:19:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB0876B0083; Tue, 15 Oct 2024 10:19:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9CBE76B007B for ; Tue, 15 Oct 2024 10:19:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 70065AB34F for ; Tue, 15 Oct 2024 14:19:41 +0000 (UTC) X-FDA: 82676045466.23.D62FFC7 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf18.hostedemail.com (Postfix) with ESMTP id 7C3461C0027 for ; Tue, 15 Oct 2024 14:19:53 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729001924; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LLBO8/Cx9yDqpPSIDdk0YbawAzImJzNTjEMptrm8njU=; b=FnNkPK62k8oTIiJCf5ZoadMZ4BWU/1fd7Du7kKMci/pIKbL6Zwcr3o/5d8xHccWyE9XzgV JhqFL7m71EWtUHku/6T2I+HuoMRYb3rPWTstTkk8EOyjh63oOruBKTD7lApPDfhkMFiRik GoJ36gZtwyx4LbnN0KLY1hLsfTT4S2o= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729001924; a=rsa-sha256; cv=none; b=opkO+LGM/dA5N7LNnseaI5rpivhUgjxta6BnswTVooYY9OhuBVD94haLuLX3PDfWyYvPys /I+0Kzk9R6lM+bnQ522ceG5qe380qBHABEGyxLt29T1lCjNt15y810z6HhXgnT3QwMNnYk G18Qeyp07uHWuHLfKdqfFDse20XJcHs= Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XSbnc48G8z6HJby; Tue, 15 Oct 2024 22:19:16 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 360FC1400D9; Tue, 15 Oct 2024 22:19:51 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 15 Oct 2024 16:19:49 +0200 Date: Tue, 15 Oct 2024 15:19:47 +0100 From: Jonathan Cameron To: "Rafael J. Wysocki" CC: Greg KH , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v13 12/18] platform: Add __free() based cleanup function for platform_device_put Message-ID: <20241015151947.00006a4f@Huawei.com> In-Reply-To: References: <20241009124120.1124-1-shiju.jose@huawei.com> <20241009124120.1124-13-shiju.jose@huawei.com> <20241014164339.00003e73@Huawei.com> <2024101410-turf-junior-7739@gregkh> <2024101451-reword-animation-2179@gregkh> <20241014181654.00005180@Huawei.com> <20241015101025.00005305@Huawei.com> <20241015104021.00002906@huawei.com> <2024101517-bubbling-deploy-1be0@gregkh> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml500002.china.huawei.com (7.191.160.78) To frapeml500008.china.huawei.com (7.182.85.71) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 7C3461C0027 X-Stat-Signature: yppy6c9m59qqugxyqohmfak53ex7c7xf X-HE-Tag: 1729001993-650955 X-HE-Meta: U2FsdGVkX1/9CNhRfF43Ra08/ULLDAVd9Gu3063DbBKA343wTbLeGKzZt1CCSA1v5OD4+h/oqFGaKtpQ6rafjJzZezsKHx7neVcr1LpfhKjo1lO5bKksEw25B8omwqRwH0kNOWK9vq0xyR6chgBuIa5rWr43en9ZaUWfRjlq2Q45oGuZuTa971cTwXJ7C9fn+5ZEcVtX1FzoOD5I0gbvXo4E1gpudQcc2oUcH+wJN/L1z1ynmi4WpLuNi/v8c02BOHFxE+QhYiYA2uA8Ysh0QxPidPwPlTJEFkt+dKemffVECpxGsc3PkzEzYe2KVjF+1mENUysjWf1nIk8Hmoq2n7PjIIjngbDKkEPEtsbXTFHhizj2yion1d7pj1qebEupzvM1Sc04Bhji7mkKMnLCbow2t5nI9ekQNRekEscqRwOEElT+JrC/MGT2taIn+kn51b9NKrI110mHvUoF+0bsNyw94joaIcOzaZXdwLqVefdHJmR237auXwCvsIjR6mNXmhYvb3HHrdDuN0amqlY63CcjwntBBlszfMoxqRf2TVHT/SQ7c3ohxs5aaPQoNfEAasTnQyA4C9/ktdAAax/GkKNcEGzHKcImWzzoJM9ZRhIqcfQDGjR5Oi8AfIffzMEi4bMkU/4Ux4RjXW1YnzyofbSKxyRNLcHYMFQRC2y9zC0aIW2RaFQ25ynIotpK/vcXr6TRQizkBiToL/iQC4wOypf1Sf3x1Rcy/3rshmN7dNJKznvppGZLDd92mIn6yGftDZ3Rml2SqmXMM3/d9QzcbPONWi0t62pKmmawjOhzkvp3KI0GWh7yzlOTDneEbu8yIgMFWripfTWCHzBHZdVrngF9a8ZziKrwtkHeUqt0sKzKOfbWJvV0mqOEzuUd9qIkc+QTL0EaUWBD0NmstV8wlwMwa7pd1sy6D1ih98bjKex+F2dcAWw70+stq2dN75c2XzSTiQtc1vZEiqQW1nW BtpDRjb4 JKnDyZ7CgPI12/h+sCVGnzfMtkhq1wHTo7hZ03ZOpORRbCb1s6ELSgk9bSzO4ZUnTiJcbAUKZDiKcenuQBjOolQmAVDk5OughrseOBvBprSBhiAZpTlce+PnYxcHWCCvZtr2lnKvzPbzVZttbQcmUMVAQWbyMk7eAkDdO9wKZUrOMomBW34vOOUHE/cr5K+bZ+7Pz4WBN4nOjEmi2+reqyQPwl5Lq0U9zxgbLG5xtqBS9cW8IWQBFSarkF+H6/0tzhJt+fjNu4IG5bmCDeE8L6lOQ/QQmq+SY5/eCMJmpGwV1HTZg772pzpYX2u8UxlP/Tr3GQOKzSR53pSS3nXrCdq//pqjnHdoThZ+pnqgSsmuB2XoA4VObmnWTbImHBLTDMXzERxODmdBgA1XUyF4yffyYjO/daKYTkZmPaZ38nrvXhrzO5p7qv6VOzw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, 15 Oct 2024 15:32:28 +0200 "Rafael J. Wysocki" wrote: > On Tue, Oct 15, 2024 at 12:17=E2=80=AFPM Greg KH wrote: > > > > On Tue, Oct 15, 2024 at 10:40:54AM +0100, Jonathan Cameron wrote: =20 > > > On Tue, 15 Oct 2024 10:10:25 +0100 > > > Jonathan Cameron wrote: > > > =20 > > > > On Mon, 14 Oct 2024 20:06:40 +0200 > > > > "Rafael J. Wysocki" wrote: > > > > =20 > > > > > On Mon, Oct 14, 2024 at 7:17=E2=80=AFPM Jonathan Cameron > > > > > wrote: =20 > > > > > > > > > > > > On Mon, 14 Oct 2024 18:04:37 +0200 > > > > > > Greg KH wrote: > > > > > > =20 > > > > > > > On Mon, Oct 14, 2024 at 06:00:51PM +0200, Greg KH wrote: =20 > > > > > > > > On Mon, Oct 14, 2024 at 04:43:39PM +0100, Jonathan Cameron = wrote: =20 > > > > > > > > > On Wed, 9 Oct 2024 13:41:13 +0100 > > > > > > > > > wrote: > > > > > > > > > =20 > > > > > > > > > > From: Jonathan Cameron > > > > > > > > > > > > > > > > > > > > Add __free() based cleanup function for platform_device= _put(). > > > > > > > > > > > > > > > > > > > > Signed-off-by: Jonathan Cameron > > > > > > > > > > Signed-off-by: Shiju Jose > > > > > > > > > > --- > > > > > > > > > > include/linux/platform_device.h | 1 + > > > > > > > > > > 1 file changed, 1 insertion(+) > > > > > > > > > > > > > > > > > > > > diff --git a/include/linux/platform_device.h b/include/= linux/platform_device.h > > > > > > > > > > index d422db6eec63..606533b88f44 100644 > > > > > > > > > > --- a/include/linux/platform_device.h > > > > > > > > > > +++ b/include/linux/platform_device.h > > > > > > > > > > @@ -232,6 +232,7 @@ extern int platform_device_add_data= (struct platform_device *pdev, > > > > > > > > > > extern int platform_device_add(struct platform_device = *pdev); > > > > > > > > > > extern void platform_device_del(struct platform_device= *pdev); > > > > > > > > > > extern void platform_device_put(struct platform_device= *pdev); > > > > > > > > > > +DEFINE_FREE(platform_device_put, struct platform_devic= e *, if (_T) platform_device_put(_T)) > > > > > > > > > > > > > > > > > > > > struct platform_driver { > > > > > > > > > > int (*probe)(struct platform_device *); =20 > > > > > > > > > > > > > > > > > > +CC Greg KH and Rafael. > > > > > > > > > > > > > > > > > > Makes sure to include them on v14 as this needs review fr= om a driver core point > > > > > > > > > of view I think. =20 > > > > > > > > > > > > > > > > Why is this needed for a platform device? This feels like = you will have > > > > > > > > to do more work to "keep" the reference on the normal path = than you to > > > > > > > > today to release the reference on the error path, right? H= ave a pointer > > > > > > > > to a patch that uses this? =20 > > > > > > > > > > > > > > Ah, is it this one: > > > > > > > https://lore.kernel.org/all/20241014164955.00003439@Hua= wei.com/ > > > > > > > ? > > > > > > > > > > > > > > If so, no, that's an abuse of a platform device, don't do tha= t, make a > > > > > > > REAL device on the bus that this device lives on. If it does= n't live on > > > > > > > a real bus, then put it on the virtual bus but do NOT abuse t= he platform > > > > > > > device layer for something like this. =20 > > > > > > > > > > > > Ok. Probably virtual bus it is then. Rafael, what do you thin= k makes sense > > > > > > for a 'feature' that is described only by an ACPI table (here R= AS2)? > > > > > > Kind of similar(ish) to say IORT. =20 > > > > > > > > > > Good question. > > > > > > > > > > I guess it depends on whether or not there are any registers to a= ccess > > > > > or AML to interact with. If so, I think that a platform device m= akes > > > > > sense. =20 > > > > > > > > Unfortunately still a gray area I think. > > > > > > > > This does access mailbox memory addresses, but they are provided > > > > by an existing platform device, so maybe platform device for this > > > > device is still inappropriate :( > > > > > > > > What this uses is: > > > > PCC channel (mailbox in memory + doorbells, etc but that is indirec= tly > > > > provided as a service via reference in ACPI to the PCCT table entry > > > > allowing this to find the mailbox device - which is a platform > > > > device drivers/mailbox/pcc.c). > > > > Because it's all spec defined content in the mailbox messages, we d= on't > > > > have the more flexible (and newer I think) 'register' via operation= region > > > > stuff in AML. > > > > > > > > A wrinkle though. The mailbox data is mapped into this driver via > > > > an acpi_os_ioremap() call. > > > > > > > > So I'm thinking we don't have a strong reason for a platform device > > > > other than 'similarity' to other examples. Never the strongest rea= son! > > > > > > > > We'll explore alternatives and see what they end up looking like. > > > > > > > > Jonathan > > > > =20 > > > > > > Greg, > > > > > > I'm struggling a little to figure out how you envision the virtual bus > > > working here. So before we spend too much time implementing the wron= g thing > > > as it feels non trivial, let me check my understanding. > > > > > > Would this mean registering a ras2 bus via subsys_virtual_register(). > > > (Similar to done for memory tiers) =20 > > > > It should show up under /sys/devices/virtual/ is what I mean. > > =20 > > > On that we'd then add all the devices: one per RAS2 PCC descriptor (t= hese > > > are one per independent feature). Each feature has its own mailbox sub > > > channel (via a reference to the PCC mailbox devices . > > > Typically you have one of these per feature type per numa node, but > > > that isn't guaranteed. That will then need wiring up with bus->probe= () etc > > > so that the RAS2 edac feature drivers can find this later and bind to= it to > > > register with edac etc. > > > > > > So spinning up a full new bus, to support this? I'm not against that= . =20 > > > > No, again, see how the stuff that shows up in /sys/devices/virtual > > works, that should be much simpler. > > > > But really, as this is a "bus", just make a new one. I don't understand > > why ACPI isn't creating your devices for you, as this is ACPI code, > > perhaps just fix that up instead? That would make much more sense to > > me... =20 >=20 > Because it is a data-only table, not AML. >=20 > It looks to me like this could be an auxiliary device, similar to the > Intel VSEC driver: see intel_vsec_add_aux() etc. >=20 That was in the other branch of the thread abbreviated as auxbus. My concern with that approach is we have no parent device and the auxiliary bus is always described as being for sub parts of a compound device. In the intel_vsec case there is always a parent pci device or platform device. I don't think there is any functional requirement for a real parent, it just feels like abuse given the stated purpose of auxiliary bus. Greg, auxiliary bus or separate acpi_ras2 bus feel better to you? We'd need to parent it off something to avoid the check in auxiliary_device_init() + all devices should have a parent anyway. I was thinking we could use the virtual device, but can only get the kobj for that (there is no device), so nope - need a parent. platform_device! (only kidding ;) So my thinking is we are back with a new bus. Jonathan > Cheers, Rafael >=20