public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: intel-gfx <intel-gfx@lists.freedesktop.org>,
	Javier Martinez Canillas <javierm@redhat.com>,
	dri-devel@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 4/5] drm/i915/dsi: Skip MIPI I2C sequences if not listed as a I2cSerialBus resource
Date: Fri, 25 Feb 2022 22:49:33 +0100	[thread overview]
Message-ID: <20220225214934.383168-4-hdegoede@redhat.com> (raw)
In-Reply-To: <20220225214934.383168-1-hdegoede@redhat.com>

The current mipi_exec_i2c code uses 2 methods to find the I2C bus / adapter
to use:

1) Search for an ACPI I2cSerialBus resource matching the client address
from the MIPI sequence

2) Fall back to searching the adapter by the I2C bus number from the MIPI
sequence if 1) fails.

1 is fine, 2 however is problematic Linux does not have a fixed enumeration
order for I2C busses, so Linux numbers don't necessary line up with the
VBT numbers. On the Lenovo Yoga Tablet 2 830/1050 this causes these errors:

i2c_designware 80860F41:03: controller timed out
i915 0000:00:02.0: [drm] *ERROR* Failed to xfer payload of size (1) to reg (169)
i2c_designware 80860F41:03: controller timed out
i915 0000:00:02.0: [drm] *ERROR* Failed to xfer payload of size (1) to reg (165)
i2c_designware 80860F41:03: controller timed out
i915 0000:00:02.0: [drm] *ERROR* Failed to xfer payload of size (1) to reg (167)

Fix these errors by turning mipi_exec_i2c calls into no-ops if there is
no matching ACPI I2cSerialBus resource, restoring the behavior from before
the current mipi_exec_i2c implementation. This change should not cause any
issues because:

1) Most DSDT correctly list an I2cSerialBus resource matching the client
VBT MIPI sequence address, so we never hit scenario 2.

2) The current mipi_exec_i2c implementation was added to fix a backlight
issue on an Aava Mobile's Inari 10 tablet, which is Bay Trail based. Most
BYT based devices have worked fine with a no-op implementation of
mipi_exec_i2c since 2014.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/i915/display/intel_dsi.h     |  3 +++
 drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dsi.h b/drivers/gpu/drm/i915/display/intel_dsi.h
index a3a906cb097e..69e3f7b6fdaf 100644
--- a/drivers/gpu/drm/i915/display/intel_dsi.h
+++ b/drivers/gpu/drm/i915/display/intel_dsi.h
@@ -32,6 +32,9 @@
 #define INTEL_DSI_VIDEO_MODE	0
 #define INTEL_DSI_COMMAND_MODE	1
 
+#define INTEL_DSI_I2C_BUS_UNINITIALIZED		-1
+#define INTEL_DSI_I2C_BUS_INVALID		-2
+
 /* Dual Link support */
 #define DSI_DUAL_LINK_NONE		0
 #define DSI_DUAL_LINK_FRONT_BACK	1
diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
index 215dbfc0af0f..f7273c0cae90 100644
--- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
+++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
@@ -468,11 +468,17 @@ static const u8 *mipi_exec_i2c(struct intel_dsi *intel_dsi, const u8 *data)
 		    __func__, vbt_i2c_bus_num, slave_addr, reg_offset,
 		    payload_size, data + 7);
 
-	if (intel_dsi->i2c_bus_num < 0) {
-		intel_dsi->i2c_bus_num = vbt_i2c_bus_num;
+	if (intel_dsi->i2c_bus_num == INTEL_DSI_I2C_BUS_UNINITIALIZED) {
+		intel_dsi->i2c_bus_num = INTEL_DSI_I2C_BUS_INVALID;
 		i2c_acpi_find_adapter(intel_dsi, slave_addr);
+		if (intel_dsi->i2c_bus_num < 0)
+			drm_warn(&i915->drm, "Cannot find I2C bus %d client-addr 0x%02x, skipping MIPI I2C sequences\n",
+				 vbt_i2c_bus_num, slave_addr);
 	}
 
+	if (intel_dsi->i2c_bus_num < 0)
+		goto err_bus;
+
 	adapter = i2c_get_adapter(intel_dsi->i2c_bus_num);
 	if (!adapter) {
 		drm_err(&i915->drm, "Cannot find a valid i2c bus for xfer\n");
-- 
2.35.1


  parent reply	other threads:[~2022-02-25 21:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 21:49 [Intel-gfx] [PATCH 1/5] drm/i915/vlv_dsi: Add DMI quirk for wrong panel modeline in BIOS on Asus TF103C (v2) Hans de Goede
2022-02-25 21:49 ` [Intel-gfx] [PATCH 2/5] drm/i915/vlv_dsi: Add DMI quirk for wrong panel size on Lenovo Yoga Tablet 2 series Hans de Goede
2022-02-25 21:49 ` [Intel-gfx] [PATCH 3/5] drm/i915/dsi: Add some debug logging to mipi_exec_i2c Hans de Goede
2022-02-25 22:04   ` Javier Martinez Canillas
2022-03-03 10:22   ` Jani Nikula
2022-02-25 21:49 ` Hans de Goede [this message]
2022-02-25 21:49 ` [Intel-gfx] [PATCH 5/5] drm/i915/vlv_dsi: Skip MIPI I2C sequences on Microsoft Surface 3 Hans de Goede
2022-02-26  1:39 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/5] drm/i915/vlv_dsi: Add DMI quirk for wrong panel modeline in BIOS on Asus TF103C (v2) Patchwork
2022-02-26  2:11 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-02-27  1:35 ` [Intel-gfx] ✓ Fi.CI.IGT: " 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=20220225214934.383168-4-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=javierm@redhat.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=ville.syrjala@linux.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