cxl: Fix warning from emitting resoruce_size_t as long long int on 32bit systems
Dave Jiang
maintainerPATCH 1/1 cxl: Fix warning from emitting resoruce_size_t as long long int on 32bit systems
Reported by kernel test bot from an ARM build:drivers/cxl/core/region.c:3263:26: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'resource_size_t' {aka 'unsigned int'} [-Wformat=]
On a 32bit system, resoruce_size_t is defined as 32bit long vs on a 64bit system it is defined as 64bit long. Define the variables as u64 instead to make the size same across all archs.
--- drivers/cxl/core/region.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cxl/core/region.c +3 -2
@@ -3235,14 +3235,15 @@ static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr,struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (cxlr->dev.parent);struct cxl_region_params *p = &cxlr->params;int nid =phys_to_target_node (res->start); -resource_size_t size, cache_size, start; +u64 size, cache_size, start;int rc; size =resource_size (res);if (!size)return -EINVAL ; - rc =cxl_acpi_get_extended_linear_cache_size (res, nid, &cache_size); + rc =cxl_acpi_get_extended_linear_cache_size (res, nid, + (resource_size_t *)&cache_size);if (rc)return rc;
Signature · 1 line
2.48.1
Alison Schofield
maintainerQuoted 4 lines · Dave Jiang
Reported by kernel test bot from an ARM build:
drivers/cxl/core/region.c:3263:26: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'resource_size_t' {aka 'unsigned int'} [-Wformat=]On a 32bit system,
resoruce_size_tis defined as 32bit long vs on a 64bit
'resource' here and in commit msg.
Quoted 22 lines
system it is defined as 64bit long. Define the variables as u64 instead to make the size same across all archs.
Reported-by kernel test robot <[email protected]>Fixes 0ec9849b6333 ("acpi/hmat / cxl: Add extended linear cache support for CXL")Signed-off-by Dave Jiang <[email protected]>--- drivers/cxl/core/region.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/cxl/core/region.c +1
-1@@ -3235,14 +3235,15 @@ static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr,struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (cxlr->dev.parent);struct cxl_region_params *p = &cxlr->params;int nid =phys_to_target_node (res->start); -resource_size_t size, cache_size, start; +u64 size, cache_size, start;int rc;
drivers/cxl/core/region.c static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr, · line 3248
Quoted 10 lines
drivers/cxl/core/region.c +2
-1size =resource_size (res);if (!size)return -EINVAL ; - rc =cxl_acpi_get_extended_linear_cache_size (res, nid, &cache_size); + rc =cxl_acpi_get_extended_linear_cache_size (res, nid, + (resource_size_t *)&cache_size);if (rc)return rc;
Ah...I was thinking this fixup would be either a %pa format or (u64)cast on cache_size in the dev_warns, but this works too.
Do we also need to do this to avoid a complaint assigning to cxl_region_params:
- p->cache_size = cache_size;
+ p->cache_size = (resource_size_t)cache_size;
Quoted 5 lines
Signature · 2 lines
-- 2.48.1
Dave Jiang
maintainerQuoted 45 lines · Alison Schofield
Quoted 4 lines · Dave Jiang
Reported by kernel test bot from an ARM build:
drivers/cxl/core/region.c:3263:26: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'resource_size_t' {aka 'unsigned int'} [-Wformat=]On a 32bit system,
resoruce_size_tis defined as 32bit long vs on a 64bit'resource' here and in commit msg.
Quoted 22 lines
system it is defined as 64bit long. Define the variables as u64 instead to make the size same across all archs.
Reported-by kernel test robot <[email protected]>Fixes 0ec9849b6333 ("acpi/hmat / cxl: Add extended linear cache support for CXL")Signed-off-by Dave Jiang <[email protected]>--- drivers/cxl/core/region.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/cxl/core/region.c +1
-1@@ -3235,14 +3235,15 @@ static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr,struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (cxlr->dev.parent);struct cxl_region_params *p = &cxlr->params;int nid =phys_to_target_node (res->start); -resource_size_t size, cache_size, start; +u64 size, cache_size, start;int rc;drivers/cxl/core/region.c static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr, · line 3248
Quoted 10 lines
drivers/cxl/core/region.c +2
-1size =resource_size (res);if (!size)return -EINVAL ; - rc =cxl_acpi_get_extended_linear_cache_size (res, nid, &cache_size); + rc =cxl_acpi_get_extended_linear_cache_size (res, nid, + (resource_size_t *)&cache_size);if (rc)return rc;Ah...I was thinking this fixup would be either a %pa format or (u64)cast on
cache_sizein thedev_warns, but this works too.Do we also need to do this to avoid a complaint assigning to
cxl_region_params:
Review
Quoted 2 lines
(quoted diff) +1
-1- p->cache_size = cache_size; + p->cache_size = (resource_size_t)cache_size;
Sure I can add that.
Quoted 7 lines
Quoted 7 lines
Signature · 2 lines
-- 2.48.1