From: Imre Deak <imre.deak@intel.com>
To: <intel-gfx@lists.freedesktop.org>, <intel-xe@lists.freedesktop.org>
Subject: [PATCH 08/13] drm/i915/gmbus: Add stable DDC adapters for the DDI pool
Date: Thu, 26 Nov 2026 12:07:48 +0200 [thread overview]
Message-ID: <20261126100755.1252635-9-imre.deak@intel.com> (raw)
In-Reply-To: <20261126100755.1252635-1-imre.deak@intel.com>
Pool encoders use the DDIs shared by dynamic legacy and DP-alt/TBT-alt
ports; non-pool encoders do not participate in that allocation scheme.
Pool HDMI connectors need stable adapters even when their original VBT
entries provide no DDC pin. Add separate adapters indexed by DDI instead
of reusing the ordinary pin-indexed adapters. This lets a non-pool
connector use a pool DDI's default pin without competing for the same
adapter slot.
Keep ordinary adapters fixed to their physical pins and usable. All
adapters share the GMBUS mutex, including GPIO fallback and direct HDCP
AKSV transfers, so access through aliases is serialized.
Register the additional adapters with fixed DDI names. Start them
disabled and enable an adapter only when its DDI is assigned to a legacy
PHY with HDMI/DVI support and a valid DDC pin.
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_ddi_mgr.c | 17 +++
drivers/gpu/drm/i915/display/intel_ddi_mgr.h | 1 +
.../gpu/drm/i915/display/intel_display_core.h | 1 +
drivers/gpu/drm/i915/display/intel_gmbus.c | 108 +++++++++++++++++-
drivers/gpu/drm/i915/display/intel_gmbus.h | 4 +
drivers/gpu/drm/i915/display/intel_hdmi.c | 17 ++-
6 files changed, 139 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_ddi_mgr.c b/drivers/gpu/drm/i915/display/intel_ddi_mgr.c
index 7dc547a617990..a4a4673dda585 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi_mgr.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi_mgr.c
@@ -103,6 +103,23 @@ bool intel_ddi_mgr_pool_supports_hdmi(struct intel_display *display)
return mgr && mgr->pool_ddi_mask && mgr->has_hdmi;
}
+/* Zero means that this DDI has no valid legacy DDC route. */
+u8 intel_ddi_mgr_ddc_pin_for_ddi(struct intel_display *display, enum port ddi)
+{
+ struct intel_ddi_mgr *mgr = display->ddi_mgr;
+ const struct intel_ddi_route *route;
+
+ if (!intel_ddi_mgr_is_enabled(mgr) ||
+ !intel_ddi_mgr_is_pool_ddi(display, ddi))
+ return 0;
+
+ route = &mgr->route[ddi - PORT_TC1];
+ if (route->mode != INTEL_DDI_ROUTE_LEGACY)
+ return 0;
+
+ return mgr->ddc_pin[route->phy];
+}
+
static const char *iom_lock_owner(u32 semaphore)
{
switch (semaphore & IOM_REQUESTOR_ID_MASK) {
diff --git a/drivers/gpu/drm/i915/display/intel_ddi_mgr.h b/drivers/gpu/drm/i915/display/intel_ddi_mgr.h
index b1793b848c238..0f84c7286dab6 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi_mgr.h
+++ b/drivers/gpu/drm/i915/display/intel_ddi_mgr.h
@@ -14,5 +14,6 @@ void intel_ddi_mgr_init(struct intel_display *display);
bool intel_ddi_mgr_is_pool_ddi(struct intel_display *display, enum port ddi);
bool intel_ddi_mgr_pool_supports_hdmi(struct intel_display *display);
+u8 intel_ddi_mgr_ddc_pin_for_ddi(struct intel_display *display, enum port ddi);
#endif
diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h
index ec02f61a13706..eb383abeabb4e 100644
--- a/drivers/gpu/drm/i915/display/intel_display_core.h
+++ b/drivers/gpu/drm/i915/display/intel_display_core.h
@@ -452,6 +452,7 @@ struct intel_display {
struct mutex mutex;
struct intel_gmbus *bus[GMBUS_NUM_PINS];
+ struct intel_gmbus *ddi_bus[I915_MAX_PORTS];
wait_queue_head_t wait_queue;
} gmbus;
diff --git a/drivers/gpu/drm/i915/display/intel_gmbus.c b/drivers/gpu/drm/i915/display/intel_gmbus.c
index 8736b39e1ea62..4b395976fc8e9 100644
--- a/drivers/gpu/drm/i915/display/intel_gmbus.c
+++ b/drivers/gpu/drm/i915/display/intel_gmbus.c
@@ -37,6 +37,7 @@
#include <drm/drm_print.h>
#include <drm/display/drm_hdcp_helper.h>
+#include "intel_ddi_mgr.h"
#include "intel_de.h"
#include "intel_display_regs.h"
#include "intel_display_types.h"
@@ -52,6 +53,7 @@ struct intel_gmbus {
bool debugfs_force_bit;
u32 reg0;
intel_reg_t gpio_reg;
+ bool disabled;
struct i2c_algo_bit_data bit_algo;
struct intel_display *display;
};
@@ -697,6 +699,9 @@ do_gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num,
int i = 0, inc, try = 0;
int ret = 0;
+ if (bus->disabled)
+ return -ENXIO;
+
/* Display WA #0868: skl,bxt,kbl,cfl,glk */
if (display->platform.geminilake || display->platform.broxton)
bxt_gmbus_clock_gating(display, false);
@@ -827,6 +832,9 @@ gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)
struct ref_tracker *wakeref;
int ret;
+ if (bus->disabled)
+ return -ENXIO;
+
wakeref = intel_display_power_get(display, POWER_DOMAIN_GMBUS);
if (bus->force_bit) {
@@ -1015,14 +1023,14 @@ static const struct i2c_lock_operations gmbus_lock_ops = {
};
static struct intel_gmbus *
-intel_gmbus_create(struct intel_display *display, unsigned int pin)
+intel_gmbus_create(struct intel_display *display, unsigned int pin, enum port ddi)
{
struct pci_dev *pdev = to_pci_dev(display->drm->dev);
const struct gmbus_pin *gmbus_pin = get_gmbus_pin(display, pin);
struct intel_gmbus *bus;
int ret;
- if (!gmbus_pin)
+ if (ddi == PORT_NONE && !gmbus_pin)
return NULL;
bus = kzalloc_obj(*bus);
@@ -1030,8 +1038,14 @@ intel_gmbus_create(struct intel_display *display, unsigned int pin)
return ERR_PTR(-ENOMEM);
bus->adapter.owner = THIS_MODULE;
- snprintf(bus->adapter.name, sizeof(bus->adapter.name),
- "i915 gmbus %s", gmbus_pin->name);
+ if (ddi == PORT_NONE)
+ snprintf(bus->adapter.name, sizeof(bus->adapter.name),
+ "i915 gmbus %s", gmbus_pin->name);
+ else
+ snprintf(bus->adapter.name, sizeof(bus->adapter.name),
+ "i915 gmbus DDI TC%d", ddi - PORT_TC1 + 1);
+
+ bus->disabled = ddi != PORT_NONE;
bus->adapter.dev.parent = &pdev->dev;
bus->display = display;
bus->adapter.algo = &gmbus_algorithm;
@@ -1050,7 +1064,7 @@ intel_gmbus_create(struct intel_display *display, unsigned int pin)
if (display->platform.i830)
bus->force_bit = 1;
- intel_gpio_setup(bus, GPIO(display, gmbus_pin->gpio));
+ intel_gpio_setup(bus, gmbus_pin ? GPIO(display, gmbus_pin->gpio) : INTEL_REG_INVALID);
ret = i2c_add_adapter(&bus->adapter);
if (ret) {
@@ -1071,6 +1085,80 @@ static void intel_gmbus_destroy(struct intel_gmbus *bus)
kfree(bus);
}
+/* Keep each pool connector's adapter fixed while changing its physical pins. */
+void intel_gmbus_ddi_pool_update(struct intel_display *display, bool enable)
+{
+ enum port ddi;
+
+ mutex_lock(&display->gmbus.mutex);
+
+ for (ddi = PORT_A; ddi < I915_MAX_PORTS; ddi++) {
+ struct intel_gmbus *bus = display->gmbus.ddi_bus[ddi];
+ const struct gmbus_pin *gmbus_pin;
+ u8 pin;
+
+ if (!bus)
+ continue;
+
+ bus->disabled = true;
+
+ if (!enable)
+ continue;
+
+ pin = intel_ddi_mgr_ddc_pin_for_ddi(display, ddi);
+ gmbus_pin = get_gmbus_pin(display, pin);
+ if (!gmbus_pin)
+ continue;
+
+ /* Retry hardware only when switching to different DDC pins. */
+ if (bus->reg0 != (pin | GMBUS_RATE_100KHZ))
+ bus->force_bit &= ~GMBUS_FORCE_BIT_RETRY;
+
+ bus->reg0 = pin | GMBUS_RATE_100KHZ;
+ bus->gpio_reg = GPIO(display, gmbus_pin->gpio);
+
+ bus->disabled = false;
+ }
+
+ mutex_unlock(&display->gmbus.mutex);
+}
+
+struct i2c_adapter *
+intel_gmbus_get_ddi_adapter(struct intel_display *display, enum port ddi)
+{
+ struct intel_gmbus *bus;
+
+ if (!intel_ddi_mgr_is_pool_ddi(display, ddi))
+ return NULL;
+
+ bus = display->gmbus.ddi_bus[ddi];
+
+ return bus ? &bus->adapter : NULL;
+}
+
+static void intel_gmbus_ddi_pool_setup(struct intel_display *display)
+{
+ enum port ddi;
+
+ if (!intel_ddi_mgr_pool_supports_hdmi(display))
+ return;
+
+ for (ddi = PORT_A; ddi < I915_MAX_PORTS; ddi++) {
+ struct intel_gmbus *bus;
+
+ if (!intel_ddi_mgr_is_pool_ddi(display, ddi))
+ continue;
+
+ bus = intel_gmbus_create(display, 0, ddi);
+ if (IS_ERR(bus))
+ continue;
+
+ display->gmbus.ddi_bus[ddi] = bus;
+ }
+
+ intel_gmbus_ddi_pool_update(display, true);
+}
+
/**
* intel_gmbus_setup - instantiate all Intel i2c GMBuses
* @display: display device
@@ -1093,7 +1181,7 @@ int intel_gmbus_setup(struct intel_display *display)
init_waitqueue_head(&display->gmbus.wait_queue);
for (pin = 0; pin < ARRAY_SIZE(display->gmbus.bus); pin++) {
- struct intel_gmbus *bus = intel_gmbus_create(display, pin);
+ struct intel_gmbus *bus = intel_gmbus_create(display, pin, PORT_NONE);
if (IS_ERR(bus)) {
ret = PTR_ERR(bus);
@@ -1103,6 +1191,8 @@ int intel_gmbus_setup(struct intel_display *display)
display->gmbus.bus[pin] = bus;
}
+ intel_gmbus_ddi_pool_setup(display);
+
intel_gmbus_reset(display);
return 0;
@@ -1149,6 +1239,12 @@ bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
void intel_gmbus_teardown(struct intel_display *display)
{
unsigned int pin;
+ enum port ddi;
+
+ for (ddi = PORT_A; ddi < I915_MAX_PORTS; ddi++) {
+ intel_gmbus_destroy(display->gmbus.ddi_bus[ddi]);
+ display->gmbus.ddi_bus[ddi] = NULL;
+ }
for (pin = 0; pin < ARRAY_SIZE(display->gmbus.bus); pin++) {
intel_gmbus_destroy(display->gmbus.bus[pin]);
diff --git a/drivers/gpu/drm/i915/display/intel_gmbus.h b/drivers/gpu/drm/i915/display/intel_gmbus.h
index 6f05456388329..3c8abc06f1e01 100644
--- a/drivers/gpu/drm/i915/display/intel_gmbus.h
+++ b/drivers/gpu/drm/i915/display/intel_gmbus.h
@@ -9,6 +9,7 @@
#include <linux/types.h>
struct i2c_adapter;
+enum port;
enum tc_port;
struct intel_connector;
struct intel_display;
@@ -44,6 +45,9 @@ int intel_gmbus_output_aksv(struct i2c_adapter *adapter);
struct i2c_adapter *
intel_gmbus_get_adapter(struct intel_display *display, unsigned int pin);
+struct i2c_adapter *
+intel_gmbus_get_ddi_adapter(struct intel_display *display, enum port ddi);
+void intel_gmbus_ddi_pool_update(struct intel_display *display, bool enable);
void intel_gmbus_connector_debugfs_add(struct intel_connector *connector);
void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter);
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index 7be5eadcadf03..2622d754d8605 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -50,6 +50,7 @@
#include "intel_connector.h"
#include "intel_cx0_phy.h"
#include "intel_ddi.h"
+#include "intel_ddi_mgr.h"
#include "intel_de.h"
#include "intel_display_driver.h"
#include "intel_display_regs.h"
@@ -3133,6 +3134,7 @@ bool intel_hdmi_init_connector(struct intel_digital_port *dig_port,
struct drm_device *dev = intel_encoder->base.dev;
enum port port = intel_encoder->port;
struct cec_connector_info conn_info;
+ struct i2c_adapter *ddc;
u8 ddc_pin;
drm_dbg_kms(display->drm,
@@ -3148,14 +3150,23 @@ bool intel_hdmi_init_connector(struct intel_digital_port *dig_port,
intel_encoder->base.name))
return false;
- ddc_pin = intel_hdmi_ddc_pin(intel_encoder);
- if (!ddc_pin)
+ if (intel_ddi_mgr_is_pool_ddi(display, port)) {
+ ddc = intel_gmbus_get_ddi_adapter(display, port);
+ } else {
+ ddc_pin = intel_hdmi_ddc_pin(intel_encoder);
+ if (!ddc_pin)
+ return false;
+
+ ddc = intel_gmbus_get_adapter(display, ddc_pin);
+ }
+
+ if (!ddc)
return false;
drm_connector_init_with_ddc(dev, connector,
&intel_hdmi_connector_funcs,
DRM_MODE_CONNECTOR_HDMIA,
- intel_gmbus_get_adapter(display, ddc_pin));
+ ddc);
drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs);
--
2.49.1
next prev parent reply other threads:[~2026-11-26 10:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 10:07 [PATCH 00/13] drm/i915/ddi_mgr: Add support for dynamic DDI allocation Imre Deak
2026-11-26 10:07 ` [PATCH 01/13] drm/i915/dp: Allow rebuilding the source rate list Imre Deak
2026-11-26 10:07 ` [PATCH 02/13] drm/i915/hotplug: Set detector enable bits without a clear mask Imre Deak
2026-11-26 10:07 ` [PATCH 03/13] drm/i915/nvl+: Add support for remapping logical HPD pins to HW pins Imre Deak
2026-11-26 10:07 ` [PATCH 04/13] drm/xe/display: Distinguish failed system suspend recovery Imre Deak
2026-11-26 13:22 ` Jani Nikula
2026-11-26 10:07 ` [PATCH 05/13] drm/i915/gmbus: Extract a helper for Type-C DDC pin mapping Imre Deak
2026-11-26 10:07 ` [PATCH 06/13] drm/i915/ddi_mgr: Add support for dynamic DDI allocation Imre Deak
2026-11-26 13:23 ` Jani Nikula
2026-11-26 16:51 ` Imre Deak
2026-11-26 10:07 ` [PATCH 07/13] drm/i915/gmbus: Extract adapter creation and destruction Imre Deak
2026-11-26 10:07 ` Imre Deak [this message]
2026-11-26 10:07 ` [PATCH 09/13] drm/i915/ddi_mgr: Register encoders with dynamic DDI support Imre Deak
2026-11-26 10:26 ` sashiko-bot
2026-11-26 10:07 ` [PATCH 10/13] drm/i915/ddi_mgr: Keep AUX access consistent with DDI pool routes Imre Deak
2026-11-26 10:07 ` [PATCH 11/13] drm/i915/ddi_mgr: Verify and restore DDI allocations after runtime resume Imre Deak
2026-11-26 13:25 ` Jani Nikula
2026-11-26 10:07 ` [PATCH 12/13] drm/i915/ddi_mgr: Handle DDI pool system suspend and resume Imre Deak
2026-11-26 10:41 ` sashiko-bot
2026-11-26 13:25 ` Jani Nikula
2026-11-26 10:07 ` [PATCH 13/13] drm/i915/ddi_mgr: Enable dynamic DDI allocation at load Imre Deak
2026-11-26 11:15 ` ✗ i915.CI.BAT: failure for drm/i915/ddi_mgr: Add support for dynamic DDI allocation Patchwork
2026-11-26 14:08 ` ✗ CI.checkpatch: warning " Patchwork
2026-11-26 14:10 ` ✓ CI.KUnit: success " Patchwork
2026-11-26 14:49 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-26 21:32 ` ✓ 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=20261126100755.1252635-9-imre.deak@intel.com \
--to=imre.deak@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
/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.