[RFC PATCH 06/11] dax/hmem: bind extmem platform devices with per-region alignment

Uwe Kleine-König u.kleine-koenig at baylibre.com
Thu Dec 3 00:50:56 PST 2026


Hello,

On Wed, Dec 02, 2026 at 12:19:41AM +0000, Suseendran Bhaskaran wrote:
> diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig
> index 602f9a0839a9..834208398f4f 100644
> --- a/drivers/dax/Kconfig
> +++ b/drivers/dax/Kconfig
> @@ -29,7 +29,7 @@ config DEV_DAX_PMEM
>  
>  config DEV_DAX_HMEM
>  	tristate "HMEM DAX: direct access to 'specific purpose' memory"
> -	depends on EFI_SOFT_RESERVE
> +	depends on EFI_SOFT_RESERVE || EXTMEM
>  	select NUMA_KEEP_MEMINFO if NUMA_MEMBLKS
>  	default DEV_DAX
>  	depends on CXL_ACPI || !CXL_ACPI
> diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c
> index af21f66bf872..e82ffbadfe20 100644
> --- a/drivers/dax/hmem/hmem.c
> +++ b/drivers/dax/hmem/hmem.c
> @@ -1,7 +1,9 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include <linux/platform_device.h>
> +#include <linux/mod_devicetable.h>

Please don't add that header. I work on removing it and
<linux/platform_device.h> already gives you struct platform_device_id.

>  #include <linux/memregion.h>
>  #include <linux/module.h>
> +#include <linux/string.h>
>  #include <linux/dax.h>
>  #include "../../cxl/cxl.h"
>  #include "../bus.h"
> @@ -11,24 +13,25 @@ module_param_named(region_idle, region_idle, bool, 0644);
>  
>  static int dax_hmem_probe(struct platform_device *pdev)
>  {
> -	unsigned long flags = IORESOURCE_DAX_KMEM;
>  	struct device *dev = &pdev->dev;
> +	struct memregion_info *mri = dev->platform_data;

IMHO this should be const, I think that needs another const for
alloc_dax_region() so that should probably go to a separate patch.

> +	bool is_hmem = strcmp(pdev->name, "hmem") == 0;
>  	struct dax_region *dax_region;
> -	struct memregion_info *mri;
>  	struct dev_dax_data data;
>  
> +	if ((!is_hmem && strcmp(pdev->name, "extmem") != 0) || !mri)
> +		return -EINVAL;
> +
>  	/*
>  	 * @region_idle == true indicates that an administrative agent
>  	 * wants to manipulate the range partitioning before the devices
>  	 * are created, so do not send them to the dax_kmem driver by
>  	 * default.
>  	 */
> -	if (region_idle)
> -		flags = 0;
> -
> -	mri = dev->platform_data;
>  	dax_region = alloc_dax_region(dev, pdev->id, &mri->range,
> -				      mri->target_node, PMD_SIZE, flags);
> +				      mri->target_node, mri->align ?: PMD_SIZE,
> +				      is_hmem && !region_idle ?
> +				      IORESOURCE_DAX_KMEM : 0);
>  	if (!dax_region)
>  		return -ENOMEM;
>  
> @@ -42,8 +45,16 @@ static int dax_hmem_probe(struct platform_device *pdev)
>  	return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
>  }
>  
> +static const struct platform_device_id dax_hmem_ids[] = {
> +	{ "hmem" },
> +	{ "extmem" },

Please use named initializers here (i.e. `{ .name = "hmem" },`)

> +	{ }
> +};
> +MODULE_DEVICE_TABLE(platform, dax_hmem_ids);
> +

Best regards
Uwe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20261203/7188b6ae/attachment.sig>


More information about the linux-arm-kernel mailing list