Re: [PATCH v18 3/7] firmware: arm_rmm: Configure the RMM with the host's page size
From: Jonathan Cameron
Date: Fri Sep 18 2026 - 21:34:14 EST
> RMM v2.0 brings the ability to set the RMM's granule size. Check the
> feature registers and configure the RMM so that it matches the host's
> page size. This means that operations can be done with a granularity
> equal to PAGE_SIZE.
>
> Reviewed-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
> Signed-off-by: Steven Price <steven.price@xxxxxxx>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
One trivial but looks like it is getting quite a few changes from
Gavin's comments so no tags yet.
Jonathan
> @@ -98,6 +117,62 @@ static int rmi_read_features(void)
> return 0;
> }
>
> +static int rmi_configure(void)
> +{
> + unsigned long granule_feature;
> + unsigned long granule_size;
> + int ret = 0;
> + struct rmm_config *config;
> +
> + switch (PAGE_SIZE) {
> + case SZ_4K:
> + granule_size = RMI_GRANULE_SIZE_4KB;
> + granule_feature = RMI_FEATURE_REGISTER_1_RMI_GRAN_SZ_4KB;
> + break;
> + case SZ_16K:
> + granule_size = RMI_GRANULE_SIZE_16KB;
> + granule_feature = RMI_FEATURE_REGISTER_1_RMI_GRAN_SZ_16KB;
> + break;
> + case SZ_64K:
> + granule_size = RMI_GRANULE_SIZE_64KB;
> + granule_feature = RMI_FEATURE_REGISTER_1_RMI_GRAN_SZ_64KB;
> + break;
> + default:
> + BUILD_BUG();
> + }
> +
> + if (!(rmi_feat_reg(1) & granule_feature)) {
> + pr_err("RMM does not support %luKB granules\n",
> + PAGE_SIZE >> 10);
> + return -ENXIO;
> + }
> +
> + config = (struct rmm_config *)get_zeroed_page(GFP_KERNEL);
> + if (!config) {
> + pr_err("Unable to allocate memory for RMM config\n");
> + return -ENOMEM;
> + }
> +
> + config->rmi_granule_size = granule_size;
> +
> + /*
> + * For now we set the tracking_region_size to 0 which is the only option
> + * for 4KB PAGE_SIZE (1GB for 4KB PAGE_SIZE, 32MB/512MB for 16KB/64KB).
> + * TODO: Support other tracking sizes via Kconfig option for other
> + * PAGE_SIZES
> + */
> + config->tracking_region_size = 0;
> +
> + ret = rmi_rmm_config_set(virt_to_phys(config));
> + if (ret) {
> + pr_err("RMM config set failed (%d)\n", ret);
> + ret = -EINVAL;
> + }
> +
> + free_page((unsigned long)config);
Maybe some __free() magic is applicable here - would let you just
return in the error path above making for tidier flow and get
rid of need to assign ret above.
--
Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>