From: "Bowman, Terry" <terry.bowman@amd.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: dave@stgolabs.net, dave.jiang@intel.com,
alison.schofield@intel.com, vishal.l.verma@intel.com,
ira.weiny@intel.com, dan.j.williams@intel.com,
willy@infradead.org, jack@suse.cz, rafael@kernel.org,
len.brown@intel.com, pavel@ucw.cz, ming.li@zohomail.com,
nathan.fontenot@amd.com, Smita.KoralahalliChannabasappa@amd.com,
huang.ying.caritas@gmail.com, yaoxt.fnst@fujitsu.com,
peterz@infradead.org, gregkh@linuxfoundation.org,
quic_jjohnson@quicinc.com, ilpo.jarvinen@linux.intel.com,
bhelgaas@google.com, andriy.shevchenko@linux.intel.com,
mika.westerberg@linux.intel.com, akpm@linux-foundation.org,
gourry@gourry.net, linux-cxl@vger.kernel.org,
linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev,
linux-fsdevel@vger.kernel.org, linux-pm@vger.kernel.org,
rrichter@amd.com, benjamin.cheatham@amd.com,
PradeepVineshReddy.Kodamati@amd.com, lizhijian@fujitsu.com
Subject: Re: [PATCH v3 1/4] kernel/resource: Provide mem region release for SOFT RESERVES
Date: Thu, 10 Apr 2025 09:49:33 -0500 [thread overview]
Message-ID: <04dac478-f734-4fb9-a792-d3f11be79657@amd.com> (raw)
In-Reply-To: <20250404141639.00000f59@huawei.com>
On 4/4/2025 8:16 AM, Jonathan Cameron wrote:
> On Thu, 3 Apr 2025 13:33:12 -0500
> Terry Bowman <terry.bowman@amd.com> wrote:
>
>> From: Nathan Fontenot <nathan.fontenot@amd.com>
>>
>> Add a release_Sam_region_adjustable() interface to allow for
>
> Who is Sam? (typo)
>
Hi Jonathan,
It is a typo. I will fix.
>> removing SOFT RESERVE memory resources. This extracts out the code
>> to remove a mem region into a common __release_mem_region_adjustable()
>> routine, this routine takes additional parameters of an IORES
>> descriptor type to add checks for IORES_DESC_* and a flag to check
>> for IORESOURCE_BUSY to control it's behavior.
>>
>> The existing release_mem_region_adjustable() is a front end to the
>> common code and a new release_srmem_region_adjustable() is added to
>> release SOFT RESERVE resources.
>>
>> Signed-off-by: Nathan Fontenot <nathan.fontenot@amd.com>
>> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
>> ---
>> include/linux/ioport.h | 3 +++
>> kernel/resource.c | 55 +++++++++++++++++++++++++++++++++++++++---
>> 2 files changed, 54 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
>> index 5385349f0b8a..718360c9c724 100644
>> --- a/include/linux/ioport.h
>> +++ b/include/linux/ioport.h
>> @@ -357,6 +357,9 @@ extern void __release_region(struct resource *, resource_size_t,
>> #ifdef CONFIG_MEMORY_HOTREMOVE
>> extern void release_mem_region_adjustable(resource_size_t, resource_size_t);
>> #endif
>> +#ifdef CONFIG_CXL_REGION
>> +extern void release_srmem_region_adjustable(resource_size_t, resource_size_t);
> I'm not sure the srmem is obvious enough. Maybe it's worth the long
> name to spell it out some more.. e.g. something like
>
Yes, I'll update with a re name.
> extern void release_softresv_mem_region_adjustable() ?
>> +#endif
>> #ifdef CONFIG_MEMORY_HOTPLUG
>> extern void merge_system_ram_resource(struct resource *res);
>> #endif
>> diff --git a/kernel/resource.c b/kernel/resource.c
>> index 12004452d999..0195b31064b0 100644
>> --- a/kernel/resource.c
>> +++ b/kernel/resource.c
>> @@ -1387,7 +1387,7 @@ void __release_region(struct resource *parent, resource_size_t start,
>> }
>> EXPORT_SYMBOL(__release_region);
>>
>> -#ifdef CONFIG_MEMORY_HOTREMOVE
>> +#if defined(CONFIG_MEMORY_HOTREMOVE) || defined(CONFIG_CXL_REGION)
>> /**
>> * release_mem_region_adjustable - release a previously reserved memory region
>
> Looks like you left the old docs which I'm guessing is not the intent.
>
Correct, this is not intended. Ill remove.
>> * @start: resource start address
>> @@ -1407,7 +1407,10 @@ EXPORT_SYMBOL(__release_region);
>> * assumes that all children remain in the lower address entry for
>> * simplicity. Enhance this logic when necessary.
>> */
>> -void release_mem_region_adjustable(resource_size_t start, resource_size_t size)
>> +static void __release_mem_region_adjustable(resource_size_t start,
>> + resource_size_t size,
>> + bool busy_check,
>> + int res_desc)
>> {
>> struct resource *parent = &iomem_resource;
>> struct resource *new_res = NULL;
>> @@ -1446,7 +1449,12 @@ void release_mem_region_adjustable(resource_size_t start, resource_size_t size)
>> if (!(res->flags & IORESOURCE_MEM))
>> break;
>>
>> - if (!(res->flags & IORESOURCE_BUSY)) {
>> + if (busy_check && !(res->flags & IORESOURCE_BUSY)) {
>> + p = &res->child;
>> + continue;
>> + }
>> +
>> + if (res_desc != IORES_DESC_NONE && res->desc != res_desc) {
>> p = &res->child;
>> continue;
>> }
>> @@ -1496,7 +1504,46 @@ void release_mem_region_adjustable(resource_size_t start, resource_size_t size)
>> write_unlock(&resource_lock);
>> free_resource(new_res);
>> }
>> -#endif /* CONFIG_MEMORY_HOTREMOVE */
>> +#endif
>> +
>> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> +/**
>> + * release_mem_region_adjustable - release a previously reserved memory region
> As above. I was surprised to see new docs in here for an existing function.
> I think you forgot to delete the now wrongly placed ones above.
>
> Jonathan
>
Right, I'll remove the now old function comment.
-Terry
next prev parent reply other threads:[~2025-04-10 14:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 18:33 [PATCH v3 0/4] Add managed SOFT RESERVE resource handling Terry Bowman
2025-04-03 18:33 ` [PATCH v3 1/4] kernel/resource: Provide mem region release for SOFT RESERVES Terry Bowman
2025-04-03 18:40 ` Andy Shevchenko
2025-04-03 18:50 ` Bowman, Terry
2025-04-04 12:57 ` kernel test robot
2025-04-04 13:16 ` Jonathan Cameron
2025-04-04 13:25 ` Andy Shevchenko
2025-04-10 15:07 ` Bowman, Terry
2025-04-10 14:49 ` Bowman, Terry [this message]
2025-04-03 18:33 ` [PATCH v3 2/4] cxl: Update Soft Reserved resources upon region creation Terry Bowman
2025-04-04 13:32 ` Jonathan Cameron
2025-04-10 15:57 ` Bowman, Terry
2025-04-04 13:58 ` kernel test robot
2025-04-03 18:33 ` [PATCH v3 3/4] dax/mum: Save the dax mum platform device pointer Terry Bowman
2025-04-04 13:34 ` Jonathan Cameron
2025-04-10 18:27 ` Bowman, Terry
2025-04-03 18:33 ` [PATCH v3 4/4] cxl/dax: Delay consumption of SOFT RESERVE resources Terry Bowman
2025-04-04 13:38 ` Jonathan Cameron
2025-04-07 7:31 ` [PATCH v3 0/4] Add managed SOFT RESERVE resource handling Zhijian Li (Fujitsu)
2025-04-07 22:35 ` Bowman, Terry
2025-04-14 14:11 ` Bowman, Terry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=04dac478-f734-4fb9-a792-d3f11be79657@amd.com \
--to=terry.bowman@amd.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=PradeepVineshReddy.Kodamati@amd.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=benjamin.cheatham@amd.com \
--cc=bhelgaas@google.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=gourry@gourry.net \
--cc=gregkh@linuxfoundation.org \
--cc=huang.ying.caritas@gmail.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=len.brown@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lizhijian@fujitsu.com \
--cc=mika.westerberg@linux.intel.com \
--cc=ming.li@zohomail.com \
--cc=nathan.fontenot@amd.com \
--cc=nvdimm@lists.linux.dev \
--cc=pavel@ucw.cz \
--cc=peterz@infradead.org \
--cc=quic_jjohnson@quicinc.com \
--cc=rafael@kernel.org \
--cc=rrichter@amd.com \
--cc=vishal.l.verma@intel.com \
--cc=willy@infradead.org \
--cc=yaoxt.fnst@fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox