All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH v4 04/11] drm/xe/configfs: Use mutex from xe_configfs subsystem
Date: Mon, 28 Jul 2025 21:55:13 +0200	[thread overview]
Message-ID: <e0a9465f-e37e-46ea-a5e3-e059dc9acb41@intel.com> (raw)
In-Reply-To: <aIfUbQWlHiOymYGF@intel.com>



On 7/28/2025 9:50 PM, Rodrigo Vivi wrote:
> On Sun, Jul 27, 2025 at 07:20:01PM +0200, Michal Wajdeczko wrote:
>> It should be sufficient to protect all configuration parameters
>> using single mutex already defined inside xe_configfs subsystem.
>>
>> While around, also convert code to use guard/scoped_guard classes.
> 
> agree on the guard/scope change, but I believe we should keep
> the local lock for the local variables only instead of re-using
> a global one...

Lucas was fine with that, hence the patch, see [1]:

"I think it would be fine. This is very rarely changed and doesn't matter
much it crosses all devices."

[1] https://patchwork.freedesktop.org/patch/665141/?series=151773&rev=4#comment_1219134

> 
>>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>> ---
>>  drivers/gpu/drm/xe/xe_configfs.c | 29 +++++++++++------------------
>>  1 file changed, 11 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
>> index 6aa0531bcf76..e32517afae58 100644
>> --- a/drivers/gpu/drm/xe/xe_configfs.c
>> +++ b/drivers/gpu/drm/xe/xe_configfs.c
>> @@ -85,14 +85,15 @@
>>   *	rmdir /sys/kernel/config/xe/0000:03:00.0/
>>   */
>>  
>> +/*
>> + * Use xe_configfs.su_mutex (also accessible from group.cg_subsys->su_mutex)
>> + * to protect configuration data.
>> + */
>>  struct xe_config_device {
>>  	struct config_group group;
>>  
>>  	bool survivability_mode;
>>  	u64 engines_allowed;
>> -
>> -	/* protects attributes */
>> -	struct mutex lock;
>>  };
>>  
>>  struct engine_info {
>> @@ -135,9 +136,8 @@ static ssize_t survivability_mode_store(struct config_item *item, const char *pa
>>  	if (ret)
>>  		return ret;
>>  
>> -	mutex_lock(&dev->lock);
>> -	dev->survivability_mode = survivability_mode;
>> -	mutex_unlock(&dev->lock);
>> +	scoped_guard(mutex, &item->ci_group->cg_subsys->su_mutex)
>> +		dev->survivability_mode = survivability_mode;
>>  
>>  	return len;
>>  }
>> @@ -219,9 +219,8 @@ static ssize_t engines_allowed_store(struct config_item *item, const char *page,
>>  		val |= mask;
>>  	}
>>  
>> -	mutex_lock(&dev->lock);
>> -	dev->engines_allowed = val;
>> -	mutex_unlock(&dev->lock);
>> +	scoped_guard(mutex, &item->ci_group->cg_subsys->su_mutex)
>> +		dev->engines_allowed = val;
>>  
>>  	return len;
>>  }
>> @@ -239,7 +238,6 @@ static void xe_config_device_release(struct config_item *item)
>>  {
>>  	struct xe_config_device *dev = to_xe_config_device(item);
>>  
>> -	mutex_destroy(&dev->lock);
>>  	kfree(dev);
>>  }
>>  
>> @@ -286,8 +284,6 @@ static struct config_group *xe_config_make_device_group(struct config_group *gro
>>  
>>  	config_group_init_type_name(&dev->group, name, &xe_config_device_type);
>>  
>> -	mutex_init(&dev->lock);
>> -
>>  	return &dev->group;
>>  }
>>  
>> @@ -311,12 +307,10 @@ static struct configfs_subsystem xe_configfs = {
>>  
>>  static struct xe_config_device *configfs_find_group(struct pci_dev *pdev)
>>  {
>> +	guard(mutex)(&xe_configfs.su_mutex);
>>  	struct config_item *item;
>>  
>> -	mutex_lock(&xe_configfs.su_mutex);
>>  	item = config_group_find_item(&xe_configfs.su_group, pci_name(pdev));
>> -	mutex_unlock(&xe_configfs.su_mutex);
>> -
>>  	if (!item)
>>  		return NULL;
>>  
>> @@ -360,9 +354,8 @@ void xe_configfs_clear_survivability_mode(struct pci_dev *pdev)
>>  	if (!dev)
>>  		return;
>>  
>> -	mutex_lock(&dev->lock);
>> -	dev->survivability_mode = 0;
>> -	mutex_unlock(&dev->lock);
>> +	scoped_guard(mutex, &xe_configfs.su_mutex)
>> +		dev->survivability_mode = 0;
>>  
>>  	config_item_put(&dev->group.cg_item);
>>  }
>> -- 
>> 2.47.1
>>


  reply	other threads:[~2025-07-28 19:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-27 17:19 [PATCH v4 00/11] Updates for drm/xe/configfs Michal Wajdeczko
2025-07-27 17:19 ` [PATCH v4 01/11] drm/xe: Simplify module initialization code Michal Wajdeczko
2025-07-28 19:35   ` Rodrigo Vivi
2025-07-28 19:47     ` Michal Wajdeczko
2025-07-28 20:00       ` Rodrigo Vivi
2025-07-28 23:52   ` John Harrison
2025-07-29  8:39     ` Michal Wajdeczko
2025-07-27 17:19 ` [PATCH v4 02/11] drm/xe: Print module init abort code Michal Wajdeczko
2025-07-28 19:39   ` Rodrigo Vivi
2025-07-28 19:51     ` Michal Wajdeczko
2025-07-28 19:59       ` Rodrigo Vivi
2025-07-27 17:20 ` [PATCH v4 03/11] drm/xe/configfs: Destroy xe_configfs.su_mutex on exit/error Michal Wajdeczko
2025-07-28 19:42   ` Rodrigo Vivi
2025-07-27 17:20 ` [PATCH v4 04/11] drm/xe/configfs: Use mutex from xe_configfs subsystem Michal Wajdeczko
2025-07-28 19:50   ` Rodrigo Vivi
2025-07-28 19:55     ` Michal Wajdeczko [this message]
2025-07-27 17:20 ` [PATCH v4 05/11] drm/xe/configfs: Rename struct xe_config_device Michal Wajdeczko
2025-07-28 19:54   ` Rodrigo Vivi
2025-07-27 17:20 ` [PATCH v4 06/11] drm/xe/configfs: Rename configfs_find_group() helper Michal Wajdeczko
2025-07-28 19:57   ` Rodrigo Vivi
2025-07-27 17:20 ` [PATCH v4 07/11] drm/xe/configfs: Reintroduce struct xe_config_device Michal Wajdeczko
2025-07-29  0:06   ` John Harrison
2025-07-27 17:20 ` [PATCH v4 08/11] drm/xe/configfs: Keep default device config settings together Michal Wajdeczko
2025-07-29  0:07   ` John Harrison
2025-07-27 17:20 ` [PATCH v4 09/11] drm/xe/configfs: Check if device was preconfigured Michal Wajdeczko
2025-07-29  0:11   ` John Harrison
2025-07-27 17:20 ` [PATCH v4 10/11] drm/xe/configfs: Only allow configurations for supported devices Michal Wajdeczko
2025-07-27 17:20 ` [PATCH v4 11/11] drm/xe/configfs: Allow adding configurations for future VFs Michal Wajdeczko
2025-07-27 17:28 ` ✓ CI.KUnit: success for Updates for drm/xe/configfs (rev5) Patchwork
2025-07-27 18:07 ` ✓ Xe.CI.BAT: " Patchwork
2025-07-27 19:09 ` ✓ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e0a9465f-e37e-46ea-a5e3-e059dc9acb41@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=rodrigo.vivi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.