Re: [RFC PATCH v6 07/12] cxl/memscrub: Register CXL device patrol scrub with scrub configure driver

Jonathan Cameron
2024-02-20T12:43:24Z

On Thu, 15 Feb 2024 19:14:49 +0800
<shiju.jose@huawei.com> wrote:

> From: Shiju Jose <shiju.jose@huawei.com>
>
> Register with the scrub configure driver to expose the sysfs attributes
> to the user for configuring the CXL device memory patrol scrub. Add the
> callback functions to support configuring the CXL memory device patrol
> scrub.
>
> Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
Trivial comment inline.

> diff --git a/drivers/cxl/core/memscrub.c b/drivers/cxl/core/memscrub.c
> index a3a371c5aa7b..a1fb40f8307f 100644
> --- a/drivers/cxl/core/memscrub.c
> +++ b/drivers/cxl/core/memscrub.c
> @@ -6,14 +6,19 @@

> +
> +/**
> + * cxl_mem_patrol_scrub_is_visible() - Callback to return attribute visibility
> + * @dev: Pointer to scrub device
> + * @attr: Scrub attribute
> + * @region_id: ID of the memory region
> + *
> + * Returns: 0 on success, an error otherwise
> + */
> +static umode_t cxl_mem_patrol_scrub_is_visible(struct device *dev,
> + u32 attr_id, int region_id)
> +{
> + const struct cxl_patrol_scrub_context *cxl_ps_ctx = dev_get_drvdata(dev);
> +
> + if (attr_id == scrub_rate_available ||
> + attr_id == scrub_rate) {
> + if (!cxl_ps_ctx->scrub_cycle_changeable)
> + return 0;
> + }
> +
> + switch (attr_id) {
> + case scrub_rate_available:
> + return 0444;

Usual trick on these is to write back their default values if we support them.
If we can make this function take that as well then this bcomes
return mode;
for all those supported.

> + case scrub_enable:
> + case scrub_rate:
> + return 0644;
> + default:
> + return 0;
> + }
> +}
> +