[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <acb0f359-cd4a-4221-a7ba-9c473ad7ecd2@intel.com>
Date: Wed, 4 Jun 2025 07:35:33 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: "Zhijian Li (Fujitsu)" <lizhijian@...itsu.com>,
Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>,
"linux-cxl@...r.kernel.org" <linux-cxl@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"nvdimm@...ts.linux.dev" <nvdimm@...ts.linux.dev>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>
Cc: Davidlohr Bueso <dave@...olabs.net>,
Jonathan Cameron <jonathan.cameron@...wei.com>,
Alison Schofield <alison.schofield@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>, Ira Weiny <ira.weiny@...el.com>,
Dan Williams <dan.j.williams@...el.com>, Matthew Wilcox
<willy@...radead.org>, Jan Kara <jack@...e.cz>,
"Rafael J . Wysocki" <rafael@...nel.org>, Len Brown <len.brown@...el.com>,
Pavel Machek <pavel@...nel.org>, Li Ming <ming.li@...omail.com>,
Jeff Johnson <jeff.johnson@....qualcomm.com>,
Ying Huang <huang.ying.caritas@...il.com>,
"Xingtao Yao (Fujitsu)" <yaoxt.fnst@...itsu.com>,
Peter Zijlstra <peterz@...radead.org>, Greg KH <gregkh@...uxfoundation.org>,
Nathan Fontenot <nathan.fontenot@....com>,
Terry Bowman <terry.bowman@....com>, Robert Richter <rrichter@....com>,
Benjamin Cheatham <benjamin.cheatham@....com>,
PradeepVineshReddy Kodamati <PradeepVineshReddy.Kodamati@....com>
Subject: Re: [PATCH v4 4/7] cxl/acpi: Add background worker to wait for
cxl_pci and cxl_mem probe
On 6/4/25 2:40 AM, Zhijian Li (Fujitsu) wrote:
>
>
> On 04/06/2025 06:19, Smita Koralahalli wrote:
>> drivers/cxl/acpi.c | 23 +++++++++++++++++++++++
>> drivers/cxl/core/suspend.c | 21 +++++++++++++++++++++
>> drivers/cxl/cxl.h | 2 ++
>> 3 files changed, 46 insertions(+)
>>
>> diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
>> index cb14829bb9be..978f63b32b41 100644
>> --- a/drivers/cxl/acpi.c
>> +++ b/drivers/cxl/acpi.c
>> @@ -813,6 +813,24 @@ static int pair_cxl_resource(struct device *dev, void *data)
>> return 0;
>> }
>>
>> +static void cxl_softreserv_mem_work_fn(struct work_struct *work)
>> +{
>> + /* Wait for cxl_pci and cxl_mem drivers to load */
>> + cxl_wait_for_pci_mem();
>> +
>> + /*
>> + * Wait for the driver probe routines to complete after cxl_pci
>> + * and cxl_mem drivers are loaded.
>> + */
>> + wait_for_device_probe();
>> +}
>> +static DECLARE_WORK(cxl_sr_work, cxl_softreserv_mem_work_fn);
>> +
>> +static void cxl_softreserv_mem_update(void)
>> +{
>> + schedule_work(&cxl_sr_work);
>> +}
>> +
>> static int cxl_acpi_probe(struct platform_device *pdev)
>> {
>> int rc;
>> @@ -887,6 +905,10 @@ static int cxl_acpi_probe(struct platform_device *pdev)
>>
>> /* In case PCI is scanned before ACPI re-trigger memdev attach */
>> cxl_bus_rescan();
>> +
>> + /* Update SOFT RESERVE resources that intersect with CXL regions */
>> + cxl_softreserv_mem_update();
>> +
>> return 0;
>> }
>>
>> @@ -918,6 +940,7 @@ static int __init cxl_acpi_init(void)
>>
>> static void __exit cxl_acpi_exit(void)
>> {
>> + cancel_work_sync(&cxl_sr_work);
>> platform_driver_unregister(&cxl_acpi_driver);
>> cxl_bus_drain();
>> }
>> diff --git a/drivers/cxl/core/suspend.c b/drivers/cxl/core/suspend.c
>> index 72818a2c8ec8..c0d8f70aed56 100644
>> --- a/drivers/cxl/core/suspend.c
>> +++ b/drivers/cxl/core/suspend.c
>> @@ -2,12 +2,15 @@
>> /* Copyright(c) 2022 Intel Corporation. All rights reserved. */
>> #include <linux/atomic.h>
>> #include <linux/export.h>
>> +#include <linux/wait.h>
>> #include "cxlmem.h"
>> #include "cxlpci.h"
>>
>> static atomic_t mem_active;
>> static atomic_t pci_loaded;
>>
>> +static DECLARE_WAIT_QUEUE_HEAD(cxl_wait_queue);
>
> Given that this file (suspend.c) focuses on power management functions,
> it might be more appropriate to move the wait queue declaration and its
> related changes to acpi.c in where the its caller is.
You mean drivers/cxl/acpi.c and not drivers/cxl/core/acpi.c right? The core one is my mistake and I'm going to create a patch to remove that.
DJ
>
>
> Thanks
> Zhijian
>
>> +
>> bool cxl_mem_active(void)
>> {
>> if (IS_ENABLED(CONFIG_CXL_MEM))
>> @@ -19,6 +22,7 @@ bool cxl_mem_active(void)
>> void cxl_mem_active_inc(void)
>> {
>> atomic_inc(&mem_active);
>> + wake_up(&cxl_wait_queue);
>> }
>> EXPORT_SYMBOL_NS_GPL(cxl_mem_active_inc, "CXL");
>>
>> @@ -28,8 +32,25 @@ void cxl_mem_active_dec(void)
>> }
>> EXPORT_SYMBOL_NS_GPL(cxl_mem_active_dec, "CXL");
>>
>> +static bool cxl_pci_loaded(void)
>> +{
>> + if (IS_ENABLED(CONFIG_CXL_PCI))
>> + return atomic_read(&pci_loaded) != 0;
>> +
>> + return false;
>> +}
>> +
>> void mark_cxl_pci_loaded(void)
>> {
>> atomic_inc(&pci_loaded);
>> + wake_up(&cxl_wait_queue);
>> }
>> EXPORT_SYMBOL_NS_GPL(mark_cxl_pci_loaded, "CXL");
>> +
>> +void cxl_wait_for_pci_mem(void)
>> +{
>> + if (!wait_event_timeout(cxl_wait_queue, cxl_pci_loaded() &&
>> + cxl_mem_active(), 30 * HZ))
>> + pr_debug("Timeout waiting for cxl_pci or cxl_mem probing\n");
>> +}
Powered by blists - more mailing lists