intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Naladala Ramanaidu" <ramanaidu.naladala@intel.com>
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v2 1/1] drm/i915/gmbus: Add bit-banging debugfs control
Date: Thu, 24 Sep 2026 15:36:40 +0000	[thread overview]
Message-ID: <20260924153641.6B2891F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260924152812.439986-2-ramanaidu.naladala@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/i915: race in debugfs write causes force_bit refcount corruption
--

commit dbe416d20c046e80d3b0b6e516a640339bbbd1e9
Author: Naladala Ramanaidu <ramanaidu.naladala@intel.com>

drm/i915/gmbus: Add bit-banging debugfs control

This commit adds a connector debugfs interface to enable or disable I2C
bit-banging for Intel GMBUS adapters.

> diff --git a/drivers/gpu/drm/i915/display/intel_gmbus.c b/drivers/gpu/drm/i915/display/intel_gmbus.c
> index 60a70dea5d856..38d6d11483994 100644
> --- a/drivers/gpu/drm/i915/display/intel_gmbus.c
> +++ b/drivers/gpu/drm/i915/display/intel_gmbus.c

[ ... ]

> +static ssize_t intel_force_bit_banging_write(struct file *file,
> +						     const char __user *ubuf,
> +						     size_t len, loff_t *offp)
> +{
> +	struct seq_file *m = file->private_data;
> +	struct intel_connector *connector = m->private;
> +	bool force_bit_banging;
> +	int ret;
> +
> +	ret = kstrtobool_from_user(ubuf, len, &force_bit_banging);
> +	if (ret)
> +		return ret;
> +
> +	if (force_bit_banging != connector->force_bit_banging) {
> +		intel_gmbus_force_bit(connector->base.ddc, force_bit_banging);
> +		connector->force_bit_banging = force_bit_banging;
> +	}

[Severity: Medium]
Is this state transition safe against concurrent debugfs writes?

Since this read-modify-write block on connector->force_bit_banging
is not protected by any locks, multiple threads concurrently writing to
the intel_force_bit_banging debugfs file could trigger multiple calls to
intel_gmbus_force_bit() for the same state change.

Looking at intel_gmbus_force_bit(), it manages bus->force_bit as a
reference count:

drivers/gpu/drm/i915/display/intel_gmbus.c:intel_gmbus_force_bit() {
    ...
    mutex_lock(&display->gmbus.mutex);
    bus->force_bit += force_bit ? 1 : -1;
    ...
}

Could unbalanced calls resulting from a race here cause the refcount to
underflow or leak, permanently forcing bit-banging mode for the adapter?

> +	*offp += len;
> +
> +	return len;
> +}

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924152812.439986-1-ramanaidu.naladala@intel.com?part=1

  reply	other threads:[~2026-09-24 15:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 15:28 [PATCH v2 0/1] drm/i915/gmbus: Add bit-banging debugfs control Naladala Ramanaidu
2026-09-24 15:28 ` [PATCH v2 1/1] " Naladala Ramanaidu
2026-09-24 15:36   ` sashiko-bot [this message]
2026-09-28  5:10     ` Naladala, Ramanaidu
2026-09-25 10:30   ` Jani Nikula
2026-09-28  5:12     ` Naladala, Ramanaidu
2026-09-24 15:34 ` ✗ CI.checkpatch: warning for " Patchwork
2026-09-24 15:36 ` ✓ CI.KUnit: success " Patchwork
2026-09-24 16:55 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-25  4:50 ` ✗ Xe.CI.FULL: failure " 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=20260924153641.6B2891F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=ramanaidu.naladala@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).