From: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
To: Jani Nikula <jani.nikula@intel.com>,
<intel-gfx@lists.freedesktop.org>,
<intel-xe@lists.freedesktop.org>
Cc: Naladala Ramanaidu <ramanaidu.naladala@intel.com>
Subject: Re: [PATCH v2 4/6] drm/i915/gmbus: deduplicate setting force bit-banging
Date: Thu, 26 Nov 2026 18:37:33 +0530 [thread overview]
Message-ID: <6e917119-b642-4d2b-9592-897a5683d042@intel.com> (raw)
In-Reply-To: <7093a619be58bf8c6811260e4efae0a3dbc9f6f2.1795607055.git.jani.nikula@intel.com>
On 11/25/2026 5:16 PM, Jani Nikula wrote:
> The code to adjust bus->force_bit is already brittle, and it's better to
> avoid duplicating it. Abstract unlocked intel_gmbus_force_bit_unlocked()
> helper, and use it.
>
> Cc: Naladala Ramanaidu <ramanaidu.naladala@intel.com>
> Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_gmbus.c | 32 ++++++++++------------
> 1 file changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_gmbus.c b/drivers/gpu/drm/i915/display/intel_gmbus.c
> index df25a8233345..0c3037ef0dcb 100644
> --- a/drivers/gpu/drm/i915/display/intel_gmbus.c
> +++ b/drivers/gpu/drm/i915/display/intel_gmbus.c
> @@ -1015,19 +1015,27 @@ struct i2c_adapter *intel_gmbus_get_adapter(struct intel_display *display,
> return &display->gmbus.bus[pin]->adapter;
> }
>
> -void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit)
> +static void intel_gmbus_force_bit_unlocked(struct i2c_adapter *adapter, bool force_bit)
> {
> struct intel_gmbus *bus = to_intel_gmbus(adapter);
> struct intel_display *display = bus->display;
>
> - mutex_lock(&display->gmbus.mutex);
> + lockdep_assert_held(&display->gmbus.mutex);
>
> bus->force_bit += force_bit ? 1 : -1;
> drm_dbg_kms(display->drm,
> "%sabling bit-banging on %s. force bit now %d\n",
> force_bit ? "en" : "dis", adapter->name,
> bus->force_bit);
> +}
Noted the _unlocked construct. I had the same mutex idea back then, just
didn't extract it this cleanly.
Change LGTM.
Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> +
> +void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit)
> +{
> + struct intel_gmbus *bus = to_intel_gmbus(adapter);
> + struct intel_display *display = bus->display;
>
> + mutex_lock(&display->gmbus.mutex);
> + intel_gmbus_force_bit_unlocked(adapter, force_bit);
> mutex_unlock(&display->gmbus.mutex);
> }
>
> @@ -1085,30 +1093,20 @@ static ssize_t intel_force_bit_banging_write(struct file *file,
> struct i2c_adapter *adapter = m->private;
> struct intel_gmbus *bus = to_intel_gmbus(adapter);
> struct intel_display *display = bus->display;
> - bool force_bit_banging;
> - bool changed = false;
> - u32 force_bit = 0;
> + bool force_bit;
> int ret;
>
> - ret = kstrtobool_from_user(ubuf, len, &force_bit_banging);
> + ret = kstrtobool_from_user(ubuf, len, &force_bit);
> if (ret)
> return ret;
>
> mutex_lock(&display->gmbus.mutex);
> - if (force_bit_banging != bus->debugfs_force_bit) {
> - bus->force_bit += force_bit_banging ? 1 : -1;
> - force_bit = bus->force_bit;
> - bus->debugfs_force_bit = force_bit_banging;
> - changed = true;
> + if (force_bit != bus->debugfs_force_bit) {
> + intel_gmbus_force_bit_unlocked(adapter, force_bit);
> + bus->debugfs_force_bit = force_bit;
> }
> mutex_unlock(&display->gmbus.mutex);
>
> - if (changed)
> - drm_dbg_kms(display->drm,
> - "%sabling bit-banging on %s. force bit now %d\n",
> - force_bit_banging ? "en" : "dis",
> - adapter->name, force_bit);
> -
> *offp += len;
>
> return len;
next prev parent reply other threads:[~2026-11-26 13:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:46 [PATCH v2 0/6] drm/i915: gmbus refactors and str_enable_disable() usage Jani Nikula
2026-11-25 11:46 ` [PATCH v2 1/6] drm/i915/gmbus: move debugfs stuff at the end of the file Jani Nikula
2026-11-26 13:01 ` Nautiyal, Ankit K
2026-11-25 11:46 ` [PATCH v2 2/6] drm/i915/gmbus: pass struct i2c_adapter to debugfs functions Jani Nikula
2026-11-26 13:02 ` Nautiyal, Ankit K
2026-11-25 11:46 ` [PATCH v2 3/6] drm/i915/gmbus: remove and open-code intel_gmbus_is_adapter() Jani Nikula
2026-11-26 13:03 ` Nautiyal, Ankit K
2026-11-25 11:46 ` [PATCH v2 4/6] drm/i915/gmbus: deduplicate setting force bit-banging Jani Nikula
2026-11-26 13:07 ` Nautiyal, Ankit K [this message]
2026-11-25 11:46 ` [PATCH v2 5/6] drm/i915/display: don't be cute about printing enabling/disabling Jani Nikula
2026-11-26 13:23 ` Nautiyal, Ankit K
2026-11-25 11:46 ` [PATCH v2 6/6] drm/i915/display: use str_enable_disable() more Jani Nikula
2026-11-26 13:24 ` Nautiyal, Ankit K
2026-11-27 9:36 ` Jani Nikula
2026-11-25 12:05 ` ✓ CI.KUnit: success for drm/i915: gmbus refactors and str_enable_disable() usage Patchwork
2026-11-25 12:53 ` ✓ i915.CI.BAT: " Patchwork
2026-11-25 12:56 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-25 17:48 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-26 15:17 ` ✓ i915.CI.Full: success " 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=6e917119-b642-4d2b-9592-897a5683d042@intel.com \
--to=ankit.k.nautiyal@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=ramanaidu.naladala@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.