* [PATCH 0/2] Fix additional sysfs node access CFI violations
@ 2025-10-17 19:46 Ryan Neph
2025-10-17 19:46 ` [PATCH 1/2] drm/xe/sysfs: " Ryan Neph
2025-10-17 19:46 ` [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name Ryan Neph
0 siblings, 2 replies; 7+ messages in thread
From: Ryan Neph @ 2025-10-17 19:46 UTC (permalink / raw)
To: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter
Cc: intel-xe, dri-devel, linux-kernel, Ryan Neph
There was a patch earlier to fix CFI violations upon sysfs file access,
stemming from Xe's invalid usage of device pointers instead of kobject
pointers in those sysfs file access handlers.
When CFI was disabled, it made no functional difference, because the
`struct device *` decays to a `struct kobject *` (its first member).
However, with CFI enabled this is detected and the kernel is
intentionally crashed.
The earlier patch missed a few instances of this invalid use of `struct
device *` pointers, and a few more have been added to Xe since.
This series cleans up all remaining instances, and fixes an unrelated
compiler warning issued by clang, noticed while testing.
Signed-off-by: Ryan Neph <ryanneph@google.com>
---
Ryan Neph (2):
drm/xe/sysfs: Fix additional sysfs node access CFI violations
drm/xe/configfs: fix clang warnings for missing parameter name
drivers/gpu/drm/xe/xe_configfs.h | 10 ++++++----
drivers/gpu/drm/xe/xe_gt_ccs_mode.c | 24 ++++++++++++------------
drivers/gpu/drm/xe/xe_survivability_mode.c | 15 ++++++++-------
drivers/gpu/drm/xe/xe_vram_freq.c | 20 ++++++++++----------
4 files changed, 36 insertions(+), 33 deletions(-)
---
base-commit: ee74634683e4b3e526a4b014b0358796e97c7ce3
change-id: 20251003-rn-cfi-ab15e1aad8cf
Best regards,
--
Ryan Neph <ryanneph@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] drm/xe/sysfs: Fix additional sysfs node access CFI violations
2025-10-17 19:46 [PATCH 0/2] Fix additional sysfs node access CFI violations Ryan Neph
@ 2025-10-17 19:46 ` Ryan Neph
2025-10-17 19:46 ` [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name Ryan Neph
1 sibling, 0 replies; 7+ messages in thread
From: Ryan Neph @ 2025-10-17 19:46 UTC (permalink / raw)
To: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter
Cc: intel-xe, dri-devel, linux-kernel, Ryan Neph
Sysfs attribute store/show handlers expect the first passed parameter to
be of type 'struct kobject *', but Xe unintentionally abuses the fact
that a pointer to 'struct device' can decay to a kobject pointer (its
first member).
When CFI is enabled in the kernel, this is detected, resulting in an
intentional kernel crash when accessing the corresponding sysfs nodes.
This patch fixes the access handlers to take a kobject pointer instead
of device pointer, similarly to the earlier cleanup in
<https://lore.kernel.org/r/20250422171852.85558-1-jeevaka.badrappan@intel.com>
that missed some instances. Some others were added since with the same
issue.
Signed-off-by: Ryan Neph <ryanneph@google.com>
---
drivers/gpu/drm/xe/xe_gt_ccs_mode.c | 24 ++++++++++++------------
drivers/gpu/drm/xe/xe_survivability_mode.c | 15 ++++++++-------
drivers/gpu/drm/xe/xe_vram_freq.c | 20 ++++++++++----------
3 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_gt_ccs_mode.c b/drivers/gpu/drm/xe/xe_gt_ccs_mode.c
index 50fffc9ebf62a1d0a051bbfd8698d4ec6de4d93e..6e7dc0c317f058e284203fc31dfed51f75e392ef 100644
--- a/drivers/gpu/drm/xe/xe_gt_ccs_mode.c
+++ b/drivers/gpu/drm/xe/xe_gt_ccs_mode.c
@@ -89,30 +89,30 @@ void xe_gt_apply_ccs_mode(struct xe_gt *gt)
}
static ssize_t
-num_cslices_show(struct device *kdev,
- struct device_attribute *attr, char *buf)
+num_cslices_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- struct xe_gt *gt = kobj_to_gt(&kdev->kobj);
+ struct xe_gt *gt = kobj_to_gt(kobj);
return sysfs_emit(buf, "%u\n", hweight32(CCS_MASK(gt)));
}
-static DEVICE_ATTR_RO(num_cslices);
+static struct kobj_attribute attr_num_cslices = __ATTR_RO(num_cslices);
static ssize_t
-ccs_mode_show(struct device *kdev,
- struct device_attribute *attr, char *buf)
+ccs_mode_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- struct xe_gt *gt = kobj_to_gt(&kdev->kobj);
+ struct xe_gt *gt = kobj_to_gt(kobj);
return sysfs_emit(buf, "%u\n", gt->ccs_mode);
}
static ssize_t
-ccs_mode_store(struct device *kdev, struct device_attribute *attr,
+ccs_mode_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buff, size_t count)
{
- struct xe_gt *gt = kobj_to_gt(&kdev->kobj);
+ struct xe_gt *gt = kobj_to_gt(kobj);
struct xe_device *xe = gt_to_xe(gt);
u32 num_engines, num_slices;
int ret;
@@ -158,11 +158,11 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr,
return count;
}
-static DEVICE_ATTR_RW(ccs_mode);
+static struct kobj_attribute attr_ccs_mode = __ATTR_RW(ccs_mode);
static const struct attribute *gt_ccs_mode_attrs[] = {
- &dev_attr_ccs_mode.attr,
- &dev_attr_num_cslices.attr,
+ &attr_ccs_mode.attr,
+ &attr_num_cslices.attr,
NULL,
};
diff --git a/drivers/gpu/drm/xe/xe_survivability_mode.c b/drivers/gpu/drm/xe/xe_survivability_mode.c
index 1662bfddd4bc9c530644c185eb929f0613eb8e30..8bfad28d269440deb6a18a95b91eccc61be1b50e 100644
--- a/drivers/gpu/drm/xe/xe_survivability_mode.c
+++ b/drivers/gpu/drm/xe/xe_survivability_mode.c
@@ -150,11 +150,11 @@ static int check_boot_failure(struct xe_device *xe)
survivability->boot_status == CRITICAL_FAILURE;
}
-static ssize_t survivability_mode_show(struct device *dev,
- struct device_attribute *attr, char *buff)
+static ssize_t survivability_mode_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buff)
{
- struct pci_dev *pdev = to_pci_dev(dev);
- struct xe_device *xe = pdev_to_xe_device(pdev);
+ struct device *dev = container_of(kobj, struct device, kobj);
+ struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
struct xe_survivability *survivability = &xe->survivability;
struct xe_survivability_info *info = survivability->info;
int index = 0, count = 0;
@@ -174,7 +174,8 @@ static ssize_t survivability_mode_show(struct device *dev,
return count;
}
-static DEVICE_ATTR_ADMIN_RO(survivability_mode);
+static struct kobj_attribute attr_survivability_mode =
+ __ATTR_RO_MODE(survivability_mode, 0400);
static void xe_survivability_mode_fini(void *arg)
{
@@ -182,7 +183,7 @@ static void xe_survivability_mode_fini(void *arg)
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
struct device *dev = &pdev->dev;
- sysfs_remove_file(&dev->kobj, &dev_attr_survivability_mode.attr);
+ sysfs_remove_file(&dev->kobj, &attr_survivability_mode.attr);
}
static int create_survivability_sysfs(struct pci_dev *pdev)
@@ -192,7 +193,7 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
int ret;
/* create survivability mode sysfs */
- ret = sysfs_create_file(&dev->kobj, &dev_attr_survivability_mode.attr);
+ ret = sysfs_create_file(&dev->kobj, &attr_survivability_mode.attr);
if (ret) {
dev_warn(dev, "Failed to create survivability sysfs files\n");
return ret;
diff --git a/drivers/gpu/drm/xe/xe_vram_freq.c b/drivers/gpu/drm/xe/xe_vram_freq.c
index 17bc84da4cdcc9da22f44b99f63f2393ad85371a..7c1ce2602f70abd3a00c03982b25a69bacc24a25 100644
--- a/drivers/gpu/drm/xe/xe_vram_freq.c
+++ b/drivers/gpu/drm/xe/xe_vram_freq.c
@@ -25,15 +25,15 @@
* configuration.
*/
-static struct xe_tile *dev_to_tile(struct device *dev)
+static struct xe_tile *kobj_parent_to_tile(struct kobject *kobj)
{
- return kobj_to_tile(dev->kobj.parent);
+ return kobj_to_tile(kobj->parent);
}
-static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr,
+static ssize_t max_freq_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
- struct xe_tile *tile = dev_to_tile(dev);
+ struct xe_tile *tile = kobj_parent_to_tile(kobj);
u32 val = 0, mbox;
int err;
@@ -50,12 +50,12 @@ static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr,
return sysfs_emit(buf, "%u\n", val);
}
-static DEVICE_ATTR_RO(max_freq);
+static struct kobj_attribute attr_max_freq = __ATTR_RO(max_freq);
-static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr,
+static ssize_t min_freq_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
- struct xe_tile *tile = dev_to_tile(dev);
+ struct xe_tile *tile = kobj_parent_to_tile(kobj);
u32 val = 0, mbox;
int err;
@@ -72,11 +72,11 @@ static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr,
return sysfs_emit(buf, "%u\n", val);
}
-static DEVICE_ATTR_RO(min_freq);
+static struct kobj_attribute attr_min_freq = __ATTR_RO(min_freq);
static struct attribute *freq_attrs[] = {
- &dev_attr_max_freq.attr,
- &dev_attr_min_freq.attr,
+ &attr_max_freq.attr,
+ &attr_min_freq.attr,
NULL
};
--
2.51.0.858.gf9c4a03a3a-goog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name
2025-10-17 19:46 [PATCH 0/2] Fix additional sysfs node access CFI violations Ryan Neph
2025-10-17 19:46 ` [PATCH 1/2] drm/xe/sysfs: " Ryan Neph
@ 2025-10-17 19:46 ` Ryan Neph
2025-10-20 10:05 ` David Laight
1 sibling, 1 reply; 7+ messages in thread
From: Ryan Neph @ 2025-10-17 19:46 UTC (permalink / raw)
To: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter
Cc: intel-xe, dri-devel, linux-kernel, Ryan Neph
Fixes warning from clang-17 that look like:
drivers/gpu/drm/xe/xe_configfs.h:35:97: error: omitting the parameter name in a function definition is a C2x extension [-Werror,-Wc2x-extensions]
35 | static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
Signed-off-by: Ryan Neph <ryanneph@google.com>
---
drivers/gpu/drm/xe/xe_configfs.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_configfs.h b/drivers/gpu/drm/xe/xe_configfs.h
index fed57be0b90e146d57d966bab0e55e1723513997..a0d614b37efd54b89390f04a238aef1a8d4df4e2 100644
--- a/drivers/gpu/drm/xe/xe_configfs.h
+++ b/drivers/gpu/drm/xe/xe_configfs.h
@@ -21,9 +21,9 @@ bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev);
bool xe_configfs_media_gt_allowed(struct pci_dev *pdev);
u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev);
bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev);
-u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
+u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class class,
const u32 **cs);
-u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
+u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class class,
const u32 **cs);
#ifdef CONFIG_PCI_IOV
unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev);
@@ -37,9 +37,11 @@ static inline bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev) { return
static inline bool xe_configfs_media_gt_allowed(struct pci_dev *pdev) { return true; }
static inline u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) { return U64_MAX; }
static inline bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev) { return false; }
-static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
+static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev,
+ enum xe_engine_class class,
const u32 **cs) { return 0; }
-static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
+static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
+ enum xe_engine_class class,
const u32 **cs) { return 0; }
static inline unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev) { return UINT_MAX; }
#endif
--
2.51.0.858.gf9c4a03a3a-goog
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name
2025-10-17 19:46 ` [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name Ryan Neph
@ 2025-10-20 10:05 ` David Laight
2025-10-21 6:39 ` Nathan Chancellor
0 siblings, 1 reply; 7+ messages in thread
From: David Laight @ 2025-10-20 10:05 UTC (permalink / raw)
To: Ryan Neph
Cc: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, intel-xe, dri-devel, linux-kernel
On Fri, 17 Oct 2025 12:46:26 -0700
Ryan Neph <ryanneph@google.com> wrote:
> Fixes warning from clang-17 that look like:
>
> drivers/gpu/drm/xe/xe_configfs.h:35:97: error: omitting the parameter name in a function definition is a C2x extension [-Werror,-Wc2x-extensions]
> 35 | static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
Why did that become invalid?
It has pretty much always been used - and can be used to avoid -Wshadow warnings.
This looks like a clang bug.
And you'd want a specific -W 'knob' for it as well.
At a guess the C2x extension lets the name be omitted in the function body for
an unused parameter (the same as C++).
I think that is the 'definition' and the ones being changed here are the 'declaration'.
But I might be wrong.
David
>
> Signed-off-by: Ryan Neph <ryanneph@google.com>
> ---
> drivers/gpu/drm/xe/xe_configfs.h | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_configfs.h b/drivers/gpu/drm/xe/xe_configfs.h
> index fed57be0b90e146d57d966bab0e55e1723513997..a0d614b37efd54b89390f04a238aef1a8d4df4e2 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.h
> +++ b/drivers/gpu/drm/xe/xe_configfs.h
> @@ -21,9 +21,9 @@ bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev);
> bool xe_configfs_media_gt_allowed(struct pci_dev *pdev);
> u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev);
> bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev);
> -u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> +u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class class,
> const u32 **cs);
> -u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> +u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class class,
> const u32 **cs);
> #ifdef CONFIG_PCI_IOV
> unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev);
> @@ -37,9 +37,11 @@ static inline bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev) { return
> static inline bool xe_configfs_media_gt_allowed(struct pci_dev *pdev) { return true; }
> static inline u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) { return U64_MAX; }
> static inline bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev) { return false; }
> -static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> +static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev,
> + enum xe_engine_class class,
> const u32 **cs) { return 0; }
> -static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> +static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
> + enum xe_engine_class class,
> const u32 **cs) { return 0; }
> static inline unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev) { return UINT_MAX; }
> #endif
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name
2025-10-20 10:05 ` David Laight
@ 2025-10-21 6:39 ` Nathan Chancellor
2025-10-21 16:47 ` Ryan Neph
2025-10-22 16:38 ` David Laight
0 siblings, 2 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-10-21 6:39 UTC (permalink / raw)
To: David Laight
Cc: Ryan Neph, Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, intel-xe, dri-devel, linux-kernel
On Mon, Oct 20, 2025 at 11:05:13AM +0100, David Laight wrote:
> On Fri, 17 Oct 2025 12:46:26 -0700
> Ryan Neph <ryanneph@google.com> wrote:
>
> > Fixes warning from clang-17 that look like:
> >
> > drivers/gpu/drm/xe/xe_configfs.h:35:97: error: omitting the parameter name in a function definition is a C2x extension [-Werror,-Wc2x-extensions]
> > 35 | static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
>
> Why did that become invalid?
> It has pretty much always been used - and can be used to avoid -Wshadow warnings.
> This looks like a clang bug.
> And you'd want a specific -W 'knob' for it as well.
>
> At a guess the C2x extension lets the name be omitted in the function body for
> an unused parameter (the same as C++).
> I think that is the 'definition' and the ones being changed here are the 'declaration'.
> But I might be wrong.
I don't think you read the patch clearly enough. Both declarations and
'static inline' definitions are being updated in this patch, likely for
consistency rather than necessity (but the commit message could call
this out). I don't see how there is a clang bug here.
> >
> > Signed-off-by: Ryan Neph <ryanneph@google.com>
> > ---
> > drivers/gpu/drm/xe/xe_configfs.h | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_configfs.h b/drivers/gpu/drm/xe/xe_configfs.h
> > index fed57be0b90e146d57d966bab0e55e1723513997..a0d614b37efd54b89390f04a238aef1a8d4df4e2 100644
> > --- a/drivers/gpu/drm/xe/xe_configfs.h
> > +++ b/drivers/gpu/drm/xe/xe_configfs.h
> > @@ -21,9 +21,9 @@ bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev);
> > bool xe_configfs_media_gt_allowed(struct pci_dev *pdev);
> > u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev);
> > bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev);
> > -u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> > +u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class class,
> > const u32 **cs);
> > -u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> > +u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class class,
> > const u32 **cs);
> > #ifdef CONFIG_PCI_IOV
> > unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev);
> > @@ -37,9 +37,11 @@ static inline bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev) { return
> > static inline bool xe_configfs_media_gt_allowed(struct pci_dev *pdev) { return true; }
> > static inline u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) { return U64_MAX; }
> > static inline bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev) { return false; }
> > -static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> > +static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev,
> > + enum xe_engine_class class,
> > const u32 **cs) { return 0; }
> > -static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> > +static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
> > + enum xe_engine_class class,
> > const u32 **cs) { return 0; }
> > static inline unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev) { return UINT_MAX; }
> > #endif
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name
2025-10-21 6:39 ` Nathan Chancellor
@ 2025-10-21 16:47 ` Ryan Neph
2025-10-22 16:38 ` David Laight
1 sibling, 0 replies; 7+ messages in thread
From: Ryan Neph @ 2025-10-21 16:47 UTC (permalink / raw)
To: Nathan Chancellor
Cc: David Laight, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, David Airlie, Simona Vetter, intel-xe, dri-devel,
linux-kernel
On Tue, Oct 21, 2025 at 08:39:57AM +0200, Nathan Chancellor wrote:
> On Mon, Oct 20, 2025 at 11:05:13AM +0100, David Laight wrote:
> > On Fri, 17 Oct 2025 12:46:26 -0700
> > Ryan Neph <ryanneph@google.com> wrote:
> >
> > > Fixes warning from clang-17 that look like:
> > >
> > > drivers/gpu/drm/xe/xe_configfs.h:35:97: error: omitting the parameter name in a function definition is a C2x extension [-Werror,-Wc2x-extensions]
> > > 35 | static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> >
> > Why did that become invalid?
> > It has pretty much always been used - and can be used to avoid -Wshadow warnings.
> > This looks like a clang bug.
> > And you'd want a specific -W 'knob' for it as well.
> >
> > At a guess the C2x extension lets the name be omitted in the function body for
> > an unused parameter (the same as C++).
> > I think that is the 'definition' and the ones being changed here are the 'declaration'.
> > But I might be wrong.
>
> I don't think you read the patch clearly enough. Both declarations and
> 'static inline' definitions are being updated in this patch, likely for
> consistency rather than necessity (but the commit message could call
> this out). I don't see how there is a clang bug here.
Correct. The warning is generated for the stub definitions on the false branch of the
`#if IS_ENABLED(CONFIG_CONFIGFS_FS)`.
The pure declarations on the true side of the branch don't need a named variable but I included them for
consistency. I can mention this in the commit message for v2 if desired.
>
> > >
> > > Signed-off-by: Ryan Neph <ryanneph@google.com>
> > > ---
> > > drivers/gpu/drm/xe/xe_configfs.h | 10 ++++++----
> > > 1 file changed, 6 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_configfs.h b/drivers/gpu/drm/xe/xe_configfs.h
> > > index fed57be0b90e146d57d966bab0e55e1723513997..a0d614b37efd54b89390f04a238aef1a8d4df4e2 100644
> > > --- a/drivers/gpu/drm/xe/xe_configfs.h
> > > +++ b/drivers/gpu/drm/xe/xe_configfs.h
> > > @@ -21,9 +21,9 @@ bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev);
> > > bool xe_configfs_media_gt_allowed(struct pci_dev *pdev);
> > > u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev);
> > > bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev);
> > > -u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> > > +u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class class,
> > > const u32 **cs);
> > > -u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> > > +u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class class,
> > > const u32 **cs);
> > > #ifdef CONFIG_PCI_IOV
> > > unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev);
> > > @@ -37,9 +37,11 @@ static inline bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev) { return
> > > static inline bool xe_configfs_media_gt_allowed(struct pci_dev *pdev) { return true; }
> > > static inline u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) { return U64_MAX; }
> > > static inline bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev) { return false; }
> > > -static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> > > +static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev,
> > > + enum xe_engine_class class,
> > > const u32 **cs) { return 0; }
> > > -static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> > > +static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
> > > + enum xe_engine_class class,
> > > const u32 **cs) { return 0; }
> > > static inline unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev) { return UINT_MAX; }
> > > #endif
> > >
> >
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name
2025-10-21 6:39 ` Nathan Chancellor
2025-10-21 16:47 ` Ryan Neph
@ 2025-10-22 16:38 ` David Laight
1 sibling, 0 replies; 7+ messages in thread
From: David Laight @ 2025-10-22 16:38 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Ryan Neph, Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, intel-xe, dri-devel, linux-kernel
On Tue, 21 Oct 2025 08:39:57 +0200
Nathan Chancellor <nathan@kernel.org> wrote:
> On Mon, Oct 20, 2025 at 11:05:13AM +0100, David Laight wrote:
> > On Fri, 17 Oct 2025 12:46:26 -0700
> > Ryan Neph <ryanneph@google.com> wrote:
> >
> > > Fixes warning from clang-17 that look like:
> > >
> > > drivers/gpu/drm/xe/xe_configfs.h:35:97: error: omitting the parameter name in a function definition is a C2x extension [-Werror,-Wc2x-extensions]
> > > 35 | static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> >
> > Why did that become invalid?
> > It has pretty much always been used - and can be used to avoid -Wshadow warnings.
> > This looks like a clang bug.
> > And you'd want a specific -W 'knob' for it as well.
> >
> > At a guess the C2x extension lets the name be omitted in the function body for
> > an unused parameter (the same as C++).
> > I think that is the 'definition' and the ones being changed here are the 'declaration'.
> > But I might be wrong.
>
> I don't think you read the patch clearly enough. Both declarations and
> 'static inline' definitions are being updated in this patch, likely for
> consistency rather than necessity (but the commit message could call
> this out). I don't see how there is a clang bug here.
Ah, I only looked closely at the declaration, thought the second change was the
same.
David
>
> > >
> > > Signed-off-by: Ryan Neph <ryanneph@google.com>
> > > ---
> > > drivers/gpu/drm/xe/xe_configfs.h | 10 ++++++----
> > > 1 file changed, 6 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_configfs.h b/drivers/gpu/drm/xe/xe_configfs.h
> > > index fed57be0b90e146d57d966bab0e55e1723513997..a0d614b37efd54b89390f04a238aef1a8d4df4e2 100644
> > > --- a/drivers/gpu/drm/xe/xe_configfs.h
> > > +++ b/drivers/gpu/drm/xe/xe_configfs.h
> > > @@ -21,9 +21,9 @@ bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev);
> > > bool xe_configfs_media_gt_allowed(struct pci_dev *pdev);
> > > u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev);
> > > bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev);
> > > -u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> > > +u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class class,
> > > const u32 **cs);
> > > -u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> > > +u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class class,
> > > const u32 **cs);
> > > #ifdef CONFIG_PCI_IOV
> > > unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev);
> > > @@ -37,9 +37,11 @@ static inline bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev) { return
> > > static inline bool xe_configfs_media_gt_allowed(struct pci_dev *pdev) { return true; }
> > > static inline u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) { return U64_MAX; }
> > > static inline bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev) { return false; }
> > > -static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> > > +static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev,
> > > + enum xe_engine_class class,
> > > const u32 **cs) { return 0; }
> > > -static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> > > +static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
> > > + enum xe_engine_class class,
> > > const u32 **cs) { return 0; }
> > > static inline unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev) { return UINT_MAX; }
> > > #endif
> > >
> >
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-10-22 16:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-17 19:46 [PATCH 0/2] Fix additional sysfs node access CFI violations Ryan Neph
2025-10-17 19:46 ` [PATCH 1/2] drm/xe/sysfs: " Ryan Neph
2025-10-17 19:46 ` [PATCH 2/2] drm/xe/configfs: fix clang warnings for missing parameter name Ryan Neph
2025-10-20 10:05 ` David Laight
2025-10-21 6:39 ` Nathan Chancellor
2025-10-21 16:47 ` Ryan Neph
2025-10-22 16:38 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®