Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>, intel-gfx@lists.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [Intel-gfx] [PATCH 1/2] drm/i915/display: use fetch_and_zero if applicable
Date: Thu, 08 Dec 2022 14:37:16 +0200	[thread overview]
Message-ID: <874ju6137n.fsf@intel.com> (raw)
In-Reply-To: <877cz213fa.fsf@intel.com>

On Thu, 08 Dec 2022, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> On Thu, 08 Dec 2022, Andrzej Hajda <andrzej.hajda@intel.com> wrote:
>> Simplify the code.
>
> Personally, I absolutely hate fetch_and_zero().
>
> I understand the point, but there are two main traps:
>
> First, the name implies atomicity, which there is none at all.
>
> Second, the name implies it's part of a kernel core header, which it
> isn't, and this just amplifies the first point.
>
> It's surprising and misleading, and those are not things I like about
> interfaces in the kernel.
>
> I would not like to see this proliferate. If fetch_and_zero() was atomic
> *and* part of a core kernel header, it would be a different matter. But
> I don't think that's going to happen, exactly because it won't be atomic
> and the name implies it is.

PS. The origin is commit 78ef2d9abad6 ("drm/i915: Add fetch_and_zero()
macro") which presents the idea of making it a pattern that can be
extended for atomic use, but six years and counting, that never
happened.


>
>
> BR,
> Jani.
>
>
>>
>> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
>> ---
>>  drivers/gpu/drm/i915/display/intel_hotplug.c | 12 ++++--------
>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
>> index 907ab7526cb478..2972d7533da44e 100644
>> --- a/drivers/gpu/drm/i915/display/intel_hotplug.c
>> +++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
>> @@ -304,10 +304,8 @@ static void i915_digport_work_func(struct work_struct *work)
>>  	u32 old_bits = 0;
>>  
>>  	spin_lock_irq(&dev_priv->irq_lock);
>> -	long_port_mask = dev_priv->display.hotplug.long_port_mask;
>> -	dev_priv->display.hotplug.long_port_mask = 0;
>> -	short_port_mask = dev_priv->display.hotplug.short_port_mask;
>> -	dev_priv->display.hotplug.short_port_mask = 0;
>> +	long_port_mask = fetch_and_zero(&dev_priv->display.hotplug.long_port_mask);
>> +	short_port_mask = fetch_and_zero(&dev_priv->display.hotplug.short_port_mask);
>>  	spin_unlock_irq(&dev_priv->irq_lock);
>>  
>>  	for_each_intel_encoder(&dev_priv->drm, encoder) {
>> @@ -379,10 +377,8 @@ static void i915_hotplug_work_func(struct work_struct *work)
>>  
>>  	spin_lock_irq(&dev_priv->irq_lock);
>>  
>> -	hpd_event_bits = dev_priv->display.hotplug.event_bits;
>> -	dev_priv->display.hotplug.event_bits = 0;
>> -	hpd_retry_bits = dev_priv->display.hotplug.retry_bits;
>> -	dev_priv->display.hotplug.retry_bits = 0;
>> +	hpd_event_bits = fetch_and_zero(&dev_priv->display.hotplug.event_bits);
>> +	hpd_retry_bits = fetch_and_zero(&dev_priv->display.hotplug.retry_bits);
>>  
>>  	/* Enable polling for connectors which had HPD IRQ storms */
>>  	intel_hpd_irq_storm_switch_to_polling(dev_priv);

-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2022-12-08 12:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08 11:12 [Intel-gfx] [PATCH 1/2] drm/i915/display: use fetch_and_zero if applicable Andrzej Hajda
2022-12-08 11:12 ` [Intel-gfx] [PATCH 2/2] drm/i915/gt: " Andrzej Hajda
2022-12-08 11:47 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [1/2] drm/i915/display: " Patchwork
2022-12-08 12:11 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-12-08 12:32 ` [Intel-gfx] [PATCH 1/2] " Jani Nikula
2022-12-08 12:37   ` Jani Nikula [this message]
2022-12-08 13:36   ` Vivi, Rodrigo
2022-12-08 15:02     ` Jani Nikula
2022-12-08 15:44       ` Tvrtko Ursulin
2022-12-08 16:26         ` Andrzej Hajda
2022-12-08 15:02     ` Andrzej Hajda
2022-12-08 19:03 ` [Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [1/2] " 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=874ju6137n.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox