Re: [PATCH 01/10] drm/xe: Guard configfs attribute reads in getters
Matt Roper <[email protected]>
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Aug 20, 2026 at 09:06:40PM +0000, Stuart Summers wrote: > The configfs getters read dev->config members without holding dev->lock, > so a concurrent store can tear the value being returned. The store paths > and a few of the getters already take the lock; make it consistent by > wrapping every read of dev->config in the getters with a scoped_guard(), > covering the surrounding checks that consume those values as well. > > Signed-off-by: Stuart Summers <[email protected]> > Assisted-by: Copilot:claude-opus-5 I don't think the locking is terribly important for most of these configfs interfaces, but it certainly doesn't hurt anything and is good for consistency. Reviewed-by: Matt Roper <[email protected]> > --- > drivers/gpu/drm/xe/xe_configfs.c | 29 +++++++++++++++++++---------- > 1 file changed, 19 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c > index 052cce962161..0a85043a9dd0 100644 > --- a/drivers/gpu/drm/xe/xe_configfs.c > +++ b/drivers/gpu/drm/xe/xe_configfs.c > @@ -1185,7 +1185,8 @@ bool xe_configfs_get_survivability_mode(struct pci_dev *pdev) > if (!dev) > return device_defaults.survivability_mode; > > - mode = dev->config.survivability_mode; > + scoped_guard(mutex, &dev->lock) > + mode = dev->config.survivability_mode; > config_group_put(&dev->group); > > return mode; > @@ -1199,7 +1200,8 @@ static u64 get_gt_types_allowed(struct pci_dev *pdev) > if (!dev) > return device_defaults.gt_types_allowed; > > - mask = dev->config.gt_types_allowed; > + scoped_guard(mutex, &dev->lock) > + mask = dev->config.gt_types_allowed; > config_group_put(&dev->group); > > return mask; > @@ -1243,7 +1245,8 @@ u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) > if (!dev) > return device_defaults.engines_allowed; > > - engines_allowed = dev->config.engines_allowed; > + scoped_guard(mutex, &dev->lock) > + engines_allowed = dev->config.engines_allowed; > config_group_put(&dev->group); > > return engines_allowed; > @@ -1263,7 +1266,8 @@ bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev) > if (!dev) > return false; > > - ret = dev->config.enable_psmi; > + scoped_guard(mutex, &dev->lock) > + ret = dev->config.enable_psmi; > config_group_put(&dev->group); > > return ret; > @@ -1284,7 +1288,8 @@ bool xe_configfs_get_enable_multi_queue(struct pci_dev *pdev) > if (!dev) > return true; > > - ret = dev->config.enable_multi_queue; > + scoped_guard(mutex, &dev->lock) > + ret = dev->config.enable_multi_queue; > config_group_put(&dev->group); > > return ret; > @@ -1308,10 +1313,12 @@ u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, > if (!dev) > return 0; > > - if (cs) > - *cs = dev->config.ctx_restore_mid_bb[class].cs; > + scoped_guard(mutex, &dev->lock) { > + if (cs) > + *cs = dev->config.ctx_restore_mid_bb[class].cs; > > - len = dev->config.ctx_restore_mid_bb[class].len; > + len = dev->config.ctx_restore_mid_bb[class].len; > + } > config_group_put(&dev->group); > > return len; > @@ -1335,8 +1342,10 @@ u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, > if (!dev) > return 0; > > - *cs = dev->config.ctx_restore_post_bb[class].cs; > - len = dev->config.ctx_restore_post_bb[class].len; > + scoped_guard(mutex, &dev->lock) { > + *cs = dev->config.ctx_restore_post_bb[class].cs; > + len = dev->config.ctx_restore_post_bb[class].len; > + } > config_group_put(&dev->group); > > return len; > -- > 2.43.0 > -- Matt Roper Graphics Software Engineer Linux GPU Platform Enablement Intel Corporation