From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Douglas Anderson <dianders@chromium.org>,
Kuogee Hsieh <quic_khsieh@quicinc.com>,
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
Sasha Levin <sashal@kernel.org>,
robdclark@gmail.com, quic_abhinavk@quicinc.com,
airlied@gmail.com, daniel@ffwll.ch, swboyd@chromium.org,
quic_sbillaka@quicinc.com, quic_vpolimer@quicinc.com,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org
Subject: [PATCH AUTOSEL 6.2 25/37] drm/msm/dp: Clean up handling of DP AUX interrupts
Date: Sun, 30 Apr 2023 22:59:33 -0400 [thread overview]
Message-ID: <20230501025945.3253774-25-sashal@kernel.org> (raw)
In-Reply-To: <20230501025945.3253774-1-sashal@kernel.org>
From: Douglas Anderson <dianders@chromium.org>
[ Upstream commit b20566cdef05cd40d95f10869d2a7646f48b1bbe ]
The DP AUX interrupt handling was a bit of a mess.
* There were two functions (one for "native" transfers and one for
"i2c" transfers) that were quite similar. It was hard to say how
many of the differences between the two functions were on purpose
and how many of them were just an accident of how they were coded.
* Each function sometimes used "else if" to test for error bits and
sometimes didn't and again it was hard to say if this was on purpose
or just an accident.
* The two functions wouldn't notice whether "unknown" bits were
set. For instance, there seems to be a bit "DP_INTR_PLL_UNLOCKED"
and if it was set there would be no indication.
* The two functions wouldn't notice if more than one error was set.
Let's fix this by being more consistent / explicit about what we're
doing.
By design this could cause different handling for AUX transfers,
though I'm not actually aware of any bug fixed as a result of
this patch (this patch was created because we simply noticed how odd
the old code was by code inspection). Specific notes here:
1. In the old native transfer case if we got "done + wrong address"
we'd ignore the "wrong address" (because of the "else if"). Now we
won't.
2. In the old native transfer case if we got "done + timeout" we'd
ignore the "timeout" (because of the "else if"). Now we won't.
3. In the old native transfer case we'd see "nack_defer" and translate
it to the error number for "nack". This differed from the i2c
transfer case where "nack_defer" was given the error number for
"nack_defer". This 100% can't matter because the only user of this
error number treats "nack defer" the same as "nack", so it's clear
that the difference between the "native" and "i2c" was pointless
here.
4. In the old i2c transfer case if we got "done" plus any error
besides "nack" or "defer" then we'd ignore the error. Now we don't.
5. If there is more than one error signaled by the hardware it's
possible that we'll report a different one than we used to. I don't
know if this matters. If someone is aware of a case this matters we
should document it and change the code to make it explicit.
6. One quirk we keep (I don't know if this is important) is that in
the i2c transfer case if we see "done + defer" we report that as a
"nack". That seemed too intentional in the old code to just drop.
After this change we will add extra logging, including:
* A warning if we see more than one error bit set.
* A warning if we see an unexpected interrupt.
* A warning if we get an AUX transfer interrupt when shouldn't.
It actually turns out that as a result of this change then at boot we
sometimes see an error:
[drm:dp_aux_isr] *ERROR* Unexpected DP AUX IRQ 0x01000000 when not busy
That means that, during init, we are seeing DP_INTR_PLL_UNLOCKED. For
now I'm going to say that leaving this error reported in the logs is
OK-ish and hopefully it will encourage someone to track down what's
going on at init time.
One last note here is that this change renames one of the interrupt
bits. The bit named "i2c done" clearly was used for native transfers
being done too, so I renamed it to indicate this.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Reviewed-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/520658/
Link: https://lore.kernel.org/r/20230126170745.v2.1.I90ffed3ddd21e818ae534f820cb4d6d8638859ab@changeid
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/msm/dp/dp_aux.c | 80 ++++++++++++-----------------
drivers/gpu/drm/msm/dp/dp_catalog.c | 2 +-
drivers/gpu/drm/msm/dp/dp_catalog.h | 2 +-
3 files changed, 36 insertions(+), 48 deletions(-)
diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c b/drivers/gpu/drm/msm/dp/dp_aux.c
index cc3efed593aa1..84f9e3e5f9642 100644
--- a/drivers/gpu/drm/msm/dp/dp_aux.c
+++ b/drivers/gpu/drm/msm/dp/dp_aux.c
@@ -162,47 +162,6 @@ static ssize_t dp_aux_cmd_fifo_rx(struct dp_aux_private *aux,
return i;
}
-static void dp_aux_native_handler(struct dp_aux_private *aux, u32 isr)
-{
- if (isr & DP_INTR_AUX_I2C_DONE)
- aux->aux_error_num = DP_AUX_ERR_NONE;
- else if (isr & DP_INTR_WRONG_ADDR)
- aux->aux_error_num = DP_AUX_ERR_ADDR;
- else if (isr & DP_INTR_TIMEOUT)
- aux->aux_error_num = DP_AUX_ERR_TOUT;
- if (isr & DP_INTR_NACK_DEFER)
- aux->aux_error_num = DP_AUX_ERR_NACK;
- if (isr & DP_INTR_AUX_ERROR) {
- aux->aux_error_num = DP_AUX_ERR_PHY;
- dp_catalog_aux_clear_hw_interrupts(aux->catalog);
- }
-}
-
-static void dp_aux_i2c_handler(struct dp_aux_private *aux, u32 isr)
-{
- if (isr & DP_INTR_AUX_I2C_DONE) {
- if (isr & (DP_INTR_I2C_NACK | DP_INTR_I2C_DEFER))
- aux->aux_error_num = DP_AUX_ERR_NACK;
- else
- aux->aux_error_num = DP_AUX_ERR_NONE;
- } else {
- if (isr & DP_INTR_WRONG_ADDR)
- aux->aux_error_num = DP_AUX_ERR_ADDR;
- else if (isr & DP_INTR_TIMEOUT)
- aux->aux_error_num = DP_AUX_ERR_TOUT;
- if (isr & DP_INTR_NACK_DEFER)
- aux->aux_error_num = DP_AUX_ERR_NACK_DEFER;
- if (isr & DP_INTR_I2C_NACK)
- aux->aux_error_num = DP_AUX_ERR_NACK;
- if (isr & DP_INTR_I2C_DEFER)
- aux->aux_error_num = DP_AUX_ERR_DEFER;
- if (isr & DP_INTR_AUX_ERROR) {
- aux->aux_error_num = DP_AUX_ERR_PHY;
- dp_catalog_aux_clear_hw_interrupts(aux->catalog);
- }
- }
-}
-
static void dp_aux_update_offset_and_segment(struct dp_aux_private *aux,
struct drm_dp_aux_msg *input_msg)
{
@@ -427,13 +386,42 @@ void dp_aux_isr(struct drm_dp_aux *dp_aux)
if (!isr)
return;
- if (!aux->cmd_busy)
+ if (!aux->cmd_busy) {
+ DRM_ERROR("Unexpected DP AUX IRQ %#010x when not busy\n", isr);
return;
+ }
- if (aux->native)
- dp_aux_native_handler(aux, isr);
- else
- dp_aux_i2c_handler(aux, isr);
+ /*
+ * The logic below assumes only one error bit is set (other than "done"
+ * which can apparently be set at the same time as some of the other
+ * bits). Warn if more than one get set so we know we need to improve
+ * the logic.
+ */
+ if (hweight32(isr & ~DP_INTR_AUX_XFER_DONE) > 1)
+ DRM_WARN("Some DP AUX interrupts unhandled: %#010x\n", isr);
+
+ if (isr & DP_INTR_AUX_ERROR) {
+ aux->aux_error_num = DP_AUX_ERR_PHY;
+ dp_catalog_aux_clear_hw_interrupts(aux->catalog);
+ } else if (isr & DP_INTR_NACK_DEFER) {
+ aux->aux_error_num = DP_AUX_ERR_NACK_DEFER;
+ } else if (isr & DP_INTR_WRONG_ADDR) {
+ aux->aux_error_num = DP_AUX_ERR_ADDR;
+ } else if (isr & DP_INTR_TIMEOUT) {
+ aux->aux_error_num = DP_AUX_ERR_TOUT;
+ } else if (!aux->native && (isr & DP_INTR_I2C_NACK)) {
+ aux->aux_error_num = DP_AUX_ERR_NACK;
+ } else if (!aux->native && (isr & DP_INTR_I2C_DEFER)) {
+ if (isr & DP_INTR_AUX_XFER_DONE)
+ aux->aux_error_num = DP_AUX_ERR_NACK;
+ else
+ aux->aux_error_num = DP_AUX_ERR_DEFER;
+ } else if (isr & DP_INTR_AUX_XFER_DONE) {
+ aux->aux_error_num = DP_AUX_ERR_NONE;
+ } else {
+ DRM_WARN("Unexpected interrupt: %#010x\n", isr);
+ return;
+ }
complete(&aux->comp);
}
diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.c b/drivers/gpu/drm/msm/dp/dp_catalog.c
index 676279d0ca8d9..421391755427d 100644
--- a/drivers/gpu/drm/msm/dp/dp_catalog.c
+++ b/drivers/gpu/drm/msm/dp/dp_catalog.c
@@ -27,7 +27,7 @@
#define DP_INTF_CONFIG_DATABUS_WIDEN BIT(4)
#define DP_INTERRUPT_STATUS1 \
- (DP_INTR_AUX_I2C_DONE| \
+ (DP_INTR_AUX_XFER_DONE| \
DP_INTR_WRONG_ADDR | DP_INTR_TIMEOUT | \
DP_INTR_NACK_DEFER | DP_INTR_WRONG_DATA_CNT | \
DP_INTR_I2C_NACK | DP_INTR_I2C_DEFER | \
diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.h b/drivers/gpu/drm/msm/dp/dp_catalog.h
index 1f717f45c1158..f36b7b372a065 100644
--- a/drivers/gpu/drm/msm/dp/dp_catalog.h
+++ b/drivers/gpu/drm/msm/dp/dp_catalog.h
@@ -13,7 +13,7 @@
/* interrupts */
#define DP_INTR_HPD BIT(0)
-#define DP_INTR_AUX_I2C_DONE BIT(3)
+#define DP_INTR_AUX_XFER_DONE BIT(3)
#define DP_INTR_WRONG_ADDR BIT(6)
#define DP_INTR_TIMEOUT BIT(9)
#define DP_INTR_NACK_DEFER BIT(12)
--
2.39.2
next prev parent reply other threads:[~2023-05-01 3:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-01 2:59 [PATCH AUTOSEL 6.2 01/37] drm/displayid: add displayid_get_header() and check bounds better Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 02/37] drm/amd/display: populate subvp cmd info only for the top pipe Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 03/37] drm/amd/display: Correct DML calculation to align HW formula Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 04/37] drm/amd/display: enable DPG when disabling plane for phantom pipe Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 05/37] platform/x86: x86-android-tablets: Add Acer Iconia One 7 B1-750 data Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 06/37] drm/amd/display: Enable HostVM based on rIOMMU active Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 07/37] drm/amd/display: Use DC_LOG_DC in the trasform pixel function Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 08/37] regmap: cache: Return error in cache sync operations for REGCACHE_NONE Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 09/37] remoteproc: imx_dsp_rproc: Add custom memory copy implementation for i.MX DSP Cores Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 10/37] arm64: dts: qcom: msm8996: Add missing DWC3 quirks Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 11/37] accel/habanalabs: postpone mem_mgr IDR destruction to hpriv_release() Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 12/37] media: imx-jpeg: Bounds check sizeimage access Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 13/37] media: cx23885: Fix a null-ptr-deref bug in buffer_prepare() and buffer_finish() Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 14/37] media: pci: tw68: Fix null-ptr-deref bug in buf prepare and finish Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 15/37] media: pvrusb2: VIDEO_PVRUSB2 depends on DVB_CORE to use dvb_* symbols Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 16/37] ACPI: processor: Check for null return of devm_kzalloc() in fch_misc_setup() Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 17/37] drm/rockchip: dw_hdmi: cleanup drm encoder during unbind Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 18/37] memstick: r592: Fix UAF bug in r592_remove due to race condition Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 19/37] arm64: dts: imx8mq-librem5: Remove dis_u3_susphy_quirk from usb_dwc3_0 Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 20/37] firmware: arm_sdei: Fix sleep from invalid context BUG Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 21/37] ACPI: EC: Fix oops when removing custom query handlers Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 22/37] drm/amd/display: fixed dcn30+ underflow issue Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 23/37] remoteproc: stm32_rproc: Add mutex protection for workqueue Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 24/37] drm/tegra: Avoid potential 32-bit integer overflow Sasha Levin
2023-05-01 2:59 ` Sasha Levin [this message]
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 26/37] ACPICA: Avoid undefined behavior: applying zero offset to null pointer Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 27/37] ACPICA: ACPICA: check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 28/37] arm64: dts: qcom: sdm845-polaris: Drop inexistent properties Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 29/37] irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4 Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 30/37] media: cros-ec-cec: Don't exit early in .remove() callback Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 31/37] ACPI: video: Remove desktops without backlight DMI quirks Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 32/37] drm/amd/display: Correct DML calculation to follow HW SPEC Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 33/37] drm/amd: Fix an out of bounds error in BIOS parser Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 34/37] drm/amdgpu: Fix sdma v4 sw fini error Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 35/37] media: Prefer designated initializers over memset for subdev pad ops Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 36/37] drm/amdgpu: Enable IH retry CAM on GFX9 Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 37/37] media: mediatek: vcodec: Fix potential array out-of-bounds in decoder queue_setup Sasha Levin
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=20230501025945.3253774-25-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dianders@chromium.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_khsieh@quicinc.com \
--cc=quic_sbillaka@quicinc.com \
--cc=quic_vpolimer@quicinc.com \
--cc=robdclark@gmail.com \
--cc=stable@vger.kernel.org \
--cc=swboyd@chromium.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 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).