[PATCH v24 11/15] media: qcom: camss: tpg: Add support for v2.4.0 TPG
Hangxiang Ma
hangxiang.ma at oss.qualcomm.com
Sun Nov 8 18:20:54 PST 2026
On 11/7/2026 11:09 PM, bod at kernel.org wrote:
> On 2026-11-02 10:52 +0000, sashiko-bot at kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>> - [Medium] media: qcom: camss: uninitialized hw_version check in tpg_reset()
>> --
>>
>> commit ea18d39e5144ca1e8d628aa5ab708e84983e10a3
>> Author: Hangxiang Ma <hangxiang.ma at oss.qualcomm.com>
>>
>> media: qcom: camss: tpg: Add support for v2.4.0 TPG
>>
>> This commit adds support for TPG hardware version 2.4.0 on Kaanapali,
>> controlling test-enable and hardware reset via the TPG_CTRL_CMD register and
>> routing the TPG output into CSID 1080 RX through the CSI2 TPG mux.
>>
>>> diff --git a/drivers/media/platform/qcom/camss/camss-tpg-gen1.c b/drivers/media/platform/qcom/camss/camss-tpg-gen1.c
>>> index d29de5f93c18e..cabbb2638cf38 100644
>>> --- a/drivers/media/platform/qcom/camss/camss-tpg-gen1.c
>>> +++ b/drivers/media/platform/qcom/camss/camss-tpg-gen1.c
>>
>> [ ... ]
>>
>>> @@ -164,18 +167,26 @@ static int tpg_stream_on(struct tpg_device *tpg)
>>
>> [ ... ]
>>
>>> static int tpg_reset(struct tpg_device *tpg)
>>> {
>>> - writel(0, tpg->base + TPG_CTRL);
>>> - writel(1, tpg->base + TPG_CLEAR);
>>> + if (tpg->hw_version < TPG_HW_VER_2_4_0)
>>> + writel(0, tpg->base + TPG_CTRL);
>>
>> [Severity: Medium]
>> As reported by Sashiko on v17 [1], is tpg->hw_version initialized when
>> tpg_reset() is called for the first time from tpg_set_power()?
>>
>> In drivers/media/platform/qcom/camss/camss-tpg.c, tpg_set_power() calls
>> reset() before hw_version() populates tpg->hw_version from the
>> TPG_HW_VERSION register:
>>
>> drivers/media/platform/qcom/camss/camss-tpg.c:tpg_set_power() {
>> ...
>> tpg->res->hw_ops->reset(tpg);
>>
>> tpg->res->hw_ops->hw_version(tpg);
>> ...
>> }
>>
>> On the first power-on after probe, tpg->hw_version is still 0, so
>> tpg->hw_version < TPG_HW_VER_2_4_0 evaluates to true and tpg_reset() writes
>> 0 to TPG_CTRL even on v2.4.0 hardware. Should tpg_set_power() call
>> hw_version(tpg) before reset(tpg), or should tpg_reset() read the version if
>> needed?
>
> Hangxiang can you have a look at this, seems credible to me.
>
>> [1] https://lore.kernel.org/r/20260929061248.E035C1F000FF@smtp.kernel.org
>>
>> --
>> Sashiko AI review · https://sashiko.dev/#/patchset/20261102-kaanapali-camss-v24-0-d6b8f3f6f66f@oss.qualcomm.com?part=11
>>
>
Hi Bryan, You're right. I had previously argued that the TPG_HW_VERSION
register always resets to 0x20040000, but that doesn't help here.
tpg->hw_version is only populated by hw_version(), which tpg_set_power()
calls after reset(). So on the first power-on after probe, tpg_reset()
still sees hw_version == 0 and takes the legacy path.
This went unnoticed in my local and E2E testing because the extra write
to TPG_CTRL happens to be harmless on v2.4.0, but the logic is wrong
regardless.
---
Best Regards,
Hangxiang
More information about the linux-phy
mailing list