From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B26D13C3BFD; Thu, 19 Mar 2026 14:35:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773930958; cv=none; b=Q4od4TPQVKyFDjg/tHv8qpAVNpd4Y9eTr3u/2yfOcvU6eH/0JH1EZPn3xgQdzg05aTRAze3wXvO2HZkQ31wDDyXJwUTyhoHkcAFOlLfIIabJq8CTrv2pB2ApSC+79dA1fmwkhw09yiem/gCJaVv0XMjV7IR05QZvWL6VgJgBO80= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773930958; c=relaxed/simple; bh=kCFcyI/VQpnscCbjgeBI5ADhG7SSHRdxxGKfbAtuAsA=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uEWx3inSOlVULNOGcwHqi42wpX4ZfWhHwukTjFRheL5WdbzP9eLZMQEa6adKVnBaF2pBCQVdp9BwmiKUZ8lN9W7edhYnEg3bmEZ6cl7yZMJJaPFkbWnucTmmv3Nyrfs4GFwmcxp6aZXfLsJ9KMj4qdd/rhM302VvUMLHGm5jS1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.224.83]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4fc7Wd15CCzJ46Zg; Thu, 19 Mar 2026 22:34:53 +0800 (CST) Received: from dubpeml500005.china.huawei.com (unknown [7.214.145.207]) by mail.maildlp.com (Postfix) with ESMTPS id A01A140569; Thu, 19 Mar 2026 22:35:52 +0800 (CST) Received: from localhost (10.203.177.15) by dubpeml500005.china.huawei.com (7.214.145.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 19 Mar 2026 14:35:51 +0000 Date: Thu, 19 Mar 2026 14:35:49 +0000 From: Jonathan Cameron To: Smita Koralahalli CC: , , , , , Ard Biesheuvel , "Alison Schofield" , Vishal Verma , Ira Weiny , Dan Williams , Yazen Ghannam , "Dave Jiang" , Davidlohr Bueso , "Matthew Wilcox" , Jan Kara , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Li Ming , Jeff Johnson , Ying Huang , Yao Xingtao , "Peter Zijlstra" , Greg Kroah-Hartman , Nathan Fontenot , Terry Bowman , Robert Richter , Benjamin Cheatham , Zhijian Li , Borislav Petkov , Tomasz Wolski Subject: Re: [PATCH v7 7/7] dax/hmem: Reintroduce Soft Reserved ranges back into the iomem tree Message-ID: <20260319143549.00005394@huawei.com> In-Reply-To: <20260319011500.241426-8-Smita.KoralahalliChannabasappa@amd.com> References: <20260319011500.241426-1-Smita.KoralahalliChannabasappa@amd.com> <20260319011500.241426-8-Smita.KoralahalliChannabasappa@amd.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100011.china.huawei.com (7.191.174.247) To dubpeml500005.china.huawei.com (7.214.145.207) On Thu, 19 Mar 2026 01:15:00 +0000 Smita Koralahalli wrote: > Reworked from a patch by Alison Schofield > > Reintroduce Soft Reserved range into the iomem_resource tree for HMEM > to consume. > > This restores visibility in /proc/iomem for ranges actively in use, while > avoiding the early-boot conflicts that occurred when Soft Reserved was > published into iomem before CXL window and region discovery. > > Link: https://lore.kernel.org/linux-cxl/29312c0765224ae76862d59a17748c8188fb95f1.1692638817.git.alison.schofield@intel.com/ > Co-developed-by: Alison Schofield > Signed-off-by: Alison Schofield > Co-developed-by: Zhijian Li > Signed-off-by: Zhijian Li > Signed-off-by: Smita Koralahalli > Reviewed-by: Dave Jiang > Reviewed-by: Jonathan Cameron > Reviewed-by: Dan Williams One minor update needed as kmalloc_obj() has shown up in meantime. Thanks Jonathan > --- > drivers/dax/hmem/hmem.c | 32 +++++++++++++++++++++++++++++++- > 1 file changed, 31 insertions(+), 1 deletion(-) > > diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c > index 8c574123bd3b..15e462589b92 100644 > --- a/drivers/dax/hmem/hmem.c > +++ b/drivers/dax/hmem/hmem.c > @@ -72,6 +72,34 @@ void dax_hmem_flush_work(void) > } > EXPORT_SYMBOL_GPL(dax_hmem_flush_work); > > +static void remove_soft_reserved(void *r) > +{ > + remove_resource(r); > + kfree(r); > +} > + > +static int add_soft_reserve_into_iomem(struct device *host, > + const struct resource *res) > +{ > + int rc; > + > + struct resource *soft __free(kfree) = > + kmalloc(sizeof(*res), GFP_KERNEL); Update to struct resource *soft __free(kfree) = kmalloc_obj(*soft); Got added in 7.0 with lots of call sites updated via scripting. Not sure why this had sizeof(*res) rather than sizeof(*soft). Same type but should have been soft! If nothing else that would probably have broken the scripts looking for where we should be using kmalloc_obj(). > + if (!soft) > + return -ENOMEM; > + > + *soft = DEFINE_RES_NAMED_DESC(res->start, (res->end - res->start + 1), > + "Soft Reserved", IORESOURCE_MEM, > + IORES_DESC_SOFT_RESERVED); > + > + rc = insert_resource(&iomem_resource, soft); > + if (rc) > + return rc; > + > + return devm_add_action_or_reset(host, remove_soft_reserved, > + no_free_ptr(soft)); > +} > + > static int hmem_register_device(struct device *host, int target_nid, > const struct resource *res) > { > @@ -94,7 +122,9 @@ static int hmem_register_device(struct device *host, int target_nid, > if (rc != REGION_INTERSECTS) > return 0; > > - /* TODO: Add Soft-Reserved memory back to iomem */ > + rc = add_soft_reserve_into_iomem(host, res); > + if (rc) > + return rc; > > id = memregion_alloc(GFP_KERNEL); > if (id < 0) {