Skip to content

Commit 3c5838f

Browse files
dianderssmb49
authored andcommitted
drm/msm/dp: Clean up handling of DP AUX interrupts
BugLink: https://bugs.launchpad.net/bugs/2028408 [ Upstream commit b20566c ] 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> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 8ea6a15 commit 3c5838f

File tree

3 files changed

+36
-48
lines changed

3 files changed

+36
-48
lines changed

drivers/gpu/drm/msm/dp/dp_aux.c

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -161,47 +161,6 @@ static ssize_t dp_aux_cmd_fifo_rx(struct dp_aux_private *aux,
161161
return i;
162162
}
163163

164-
static void dp_aux_native_handler(struct dp_aux_private *aux, u32 isr)
165-
{
166-
if (isr & DP_INTR_AUX_I2C_DONE)
167-
aux->aux_error_num = DP_AUX_ERR_NONE;
168-
else if (isr & DP_INTR_WRONG_ADDR)
169-
aux->aux_error_num = DP_AUX_ERR_ADDR;
170-
else if (isr & DP_INTR_TIMEOUT)
171-
aux->aux_error_num = DP_AUX_ERR_TOUT;
172-
if (isr & DP_INTR_NACK_DEFER)
173-
aux->aux_error_num = DP_AUX_ERR_NACK;
174-
if (isr & DP_INTR_AUX_ERROR) {
175-
aux->aux_error_num = DP_AUX_ERR_PHY;
176-
dp_catalog_aux_clear_hw_interrupts(aux->catalog);
177-
}
178-
}
179-
180-
static void dp_aux_i2c_handler(struct dp_aux_private *aux, u32 isr)
181-
{
182-
if (isr & DP_INTR_AUX_I2C_DONE) {
183-
if (isr & (DP_INTR_I2C_NACK | DP_INTR_I2C_DEFER))
184-
aux->aux_error_num = DP_AUX_ERR_NACK;
185-
else
186-
aux->aux_error_num = DP_AUX_ERR_NONE;
187-
} else {
188-
if (isr & DP_INTR_WRONG_ADDR)
189-
aux->aux_error_num = DP_AUX_ERR_ADDR;
190-
else if (isr & DP_INTR_TIMEOUT)
191-
aux->aux_error_num = DP_AUX_ERR_TOUT;
192-
if (isr & DP_INTR_NACK_DEFER)
193-
aux->aux_error_num = DP_AUX_ERR_NACK_DEFER;
194-
if (isr & DP_INTR_I2C_NACK)
195-
aux->aux_error_num = DP_AUX_ERR_NACK;
196-
if (isr & DP_INTR_I2C_DEFER)
197-
aux->aux_error_num = DP_AUX_ERR_DEFER;
198-
if (isr & DP_INTR_AUX_ERROR) {
199-
aux->aux_error_num = DP_AUX_ERR_PHY;
200-
dp_catalog_aux_clear_hw_interrupts(aux->catalog);
201-
}
202-
}
203-
}
204-
205164
static void dp_aux_update_offset_and_segment(struct dp_aux_private *aux,
206165
struct drm_dp_aux_msg *input_msg)
207166
{
@@ -410,13 +369,42 @@ void dp_aux_isr(struct drm_dp_aux *dp_aux)
410369
if (!isr)
411370
return;
412371

413-
if (!aux->cmd_busy)
372+
if (!aux->cmd_busy) {
373+
DRM_ERROR("Unexpected DP AUX IRQ %#010x when not busy\n", isr);
414374
return;
375+
}
415376

416-
if (aux->native)
417-
dp_aux_native_handler(aux, isr);
418-
else
419-
dp_aux_i2c_handler(aux, isr);
377+
/*
378+
* The logic below assumes only one error bit is set (other than "done"
379+
* which can apparently be set at the same time as some of the other
380+
* bits). Warn if more than one get set so we know we need to improve
381+
* the logic.
382+
*/
383+
if (hweight32(isr & ~DP_INTR_AUX_XFER_DONE) > 1)
384+
DRM_WARN("Some DP AUX interrupts unhandled: %#010x\n", isr);
385+
386+
if (isr & DP_INTR_AUX_ERROR) {
387+
aux->aux_error_num = DP_AUX_ERR_PHY;
388+
dp_catalog_aux_clear_hw_interrupts(aux->catalog);
389+
} else if (isr & DP_INTR_NACK_DEFER) {
390+
aux->aux_error_num = DP_AUX_ERR_NACK_DEFER;
391+
} else if (isr & DP_INTR_WRONG_ADDR) {
392+
aux->aux_error_num = DP_AUX_ERR_ADDR;
393+
} else if (isr & DP_INTR_TIMEOUT) {
394+
aux->aux_error_num = DP_AUX_ERR_TOUT;
395+
} else if (!aux->native && (isr & DP_INTR_I2C_NACK)) {
396+
aux->aux_error_num = DP_AUX_ERR_NACK;
397+
} else if (!aux->native && (isr & DP_INTR_I2C_DEFER)) {
398+
if (isr & DP_INTR_AUX_XFER_DONE)
399+
aux->aux_error_num = DP_AUX_ERR_NACK;
400+
else
401+
aux->aux_error_num = DP_AUX_ERR_DEFER;
402+
} else if (isr & DP_INTR_AUX_XFER_DONE) {
403+
aux->aux_error_num = DP_AUX_ERR_NONE;
404+
} else {
405+
DRM_WARN("Unexpected interrupt: %#010x\n", isr);
406+
return;
407+
}
420408

421409
complete(&aux->comp);
422410
}

drivers/gpu/drm/msm/dp/dp_catalog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define MSM_DP_CONTROLLER_P0_SIZE 0x0400
3535

3636
#define DP_INTERRUPT_STATUS1 \
37-
(DP_INTR_AUX_I2C_DONE| \
37+
(DP_INTR_AUX_XFER_DONE| \
3838
DP_INTR_WRONG_ADDR | DP_INTR_TIMEOUT | \
3939
DP_INTR_NACK_DEFER | DP_INTR_WRONG_DATA_CNT | \
4040
DP_INTR_I2C_NACK | DP_INTR_I2C_DEFER | \

drivers/gpu/drm/msm/dp/dp_catalog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
/* interrupts */
1515
#define DP_INTR_HPD BIT(0)
16-
#define DP_INTR_AUX_I2C_DONE BIT(3)
16+
#define DP_INTR_AUX_XFER_DONE BIT(3)
1717
#define DP_INTR_WRONG_ADDR BIT(6)
1818
#define DP_INTR_TIMEOUT BIT(9)
1919
#define DP_INTR_NACK_DEFER BIT(12)

0 commit comments

Comments
 (0)