Message ID | 20230404104800.301150-2-angelogioacchino.delregno@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2927701vqo; Tue, 4 Apr 2023 03:49:18 -0700 (PDT) X-Google-Smtp-Source: AKy350Zj7n2HTBW5mRyVxod9MusJ+yUu1KIMZZkGuCexgy0ajJgNJYejgI+iilFY95YgcMK0UVN1 X-Received: by 2002:a17:906:a858:b0:931:91a:fa4f with SMTP id dx24-20020a170906a85800b00931091afa4fmr1927613ejb.41.1680605358322; Tue, 04 Apr 2023 03:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605358; cv=none; d=google.com; s=arc-20160816; b=LTGSDZE2jAHX8Rvh3nDWZCIvOAfS4/sQIj923VGz45Srm0XreMqkbfmhDQDLLtI5bu UaVI4xX6+FtvnHfQSlGuUlqPZN2Dll1GF1d8sFFAxBef9PO9Cw5KrGXX9LkpF2O0STWU 7II53xH13xSjsBbLN57BRmmO5QjMsyCsPEDL4o4xwf8VFYK65Ii2s9KYcJdbDJp09N8h X+zEezXCy8RY7l2KVrR/+iOnTic4fAIRoIubgWfOIwvWyKxnZGTRNKHwlwd++nnT7UhV tueXhg9Z7hHY79niLPkQ9+vQKcYy9htlcWrM0cZU1POi3qBYpr9qYH3oQKnNd/A6Qnwt r1qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mVHWryi7FLI6xgM1V7O/CpgS+CHXop+pa1pZRj1UBLM=; b=Tz7UHuvcEkM+UANHmfRSSjHJBbQHpwX/hRFSvY106JkPbZcnqtPYwEEHNsTXNlMNAn BqvPN453E+7PTKfPXmAbQarAKT1FLAF9zslY2R/B5d2NRA9IGJRYZMsWFp3i2HryfU8F OILXckx9BL5soQ/+giSeczqxnqm4+CE70asd+ybpJmHlL0QhdAL3FN4GzLl5M+8dShB/ 2bHCktzbLg66i9qYTNwyB04BpoDMzkEWRi823qUdnIrf9CcwQeIHO6LOLFX0IRv8LYIA dq7b2ahWKlfzfzHTteBrv47NXRcXFbYbUgfmoLv2TMV3IG5Uz9bZxVtiLARS44TeEiIN Ngog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kWfqTIxK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a50ea84000000b00502b7d134b1si2643899edo.475.2023.04.04.03.48.54; Tue, 04 Apr 2023 03:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kWfqTIxK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234556AbjDDKsQ (ORCPT <rfc822;lkml4gm@gmail.com> + 99 others); Tue, 4 Apr 2023 06:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234526AbjDDKsL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 4 Apr 2023 06:48:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E5A0199C for <linux-kernel@vger.kernel.org>; Tue, 4 Apr 2023 03:48:09 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2C69A660314D; Tue, 4 Apr 2023 11:48:06 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605286; bh=aTfefQf7wUPldM8GfwxyIBQhpoEf1h/RP3aMOHoG5mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kWfqTIxKcDdyeFg0DuDrmjBHofBlnVH8+mggL2nm6pPo3GMHiqcATAJRE/eU6dzOH 3+rdxbDZ0Xvla3h4ldRGLQqF3TX9/US1lXUBG5GgY3HMsDhcsyS71IrTFdeV5/CRsP 6TqKWiAomBXeW+FBFbA0RkYreM6xM8wGfGQCXA/jofm+D+2uQvsHm9NEHgDaJ9PcJz nlAh4El7NDHGRAhSsIpV1d/LK9H4B3HOqGB+gfwZf7hHvzR8Q9ElFd9h8ahLJbStZI eIBOjEaOMUTJ03A34oQA/QWSKXlAA48mLtlaIYd3z971cmmTbneceyiyu2hb+GzJd/ 0wZtvdnFDljhQ== From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org Subject: [PATCH v3 1/9] drm/mediatek: dp: Cache EDID for eDP panel Date: Tue, 4 Apr 2023 12:47:52 +0200 Message-Id: <20230404104800.301150-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242444368748236?= X-GMAIL-MSGID: =?utf-8?q?1762242444368748236?= |
Series |
MediaTek DisplayPort: support eDP and aux-bus
|
|
Commit Message
AngeloGioacchino Del Regno
April 4, 2023, 10:47 a.m. UTC
Since eDP panels are not removable it is safe to cache the EDID:
this will avoid a relatively long read transaction at every PM
resume that is unnecessary only in the "special" case of eDP,
hence speeding it up a little, as from now on, as resume operation,
we will perform only link training.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/gpu/drm/mediatek/mtk_dp.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
Comments
On 04/04/2023 12:47, AngeloGioacchino Del Regno wrote: > Since eDP panels are not removable it is safe to cache the EDID: > this will avoid a relatively long read transaction at every PM > resume that is unnecessary only in the "special" case of eDP, > hence speeding it up a little, as from now on, as resume operation, > we will perform only link training. > > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> > --- > drivers/gpu/drm/mediatek/mtk_dp.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c > index 1f94fcc144d3..84f82cc68672 100644 > --- a/drivers/gpu/drm/mediatek/mtk_dp.c > +++ b/drivers/gpu/drm/mediatek/mtk_dp.c > @@ -118,6 +118,7 @@ struct mtk_dp { > const struct mtk_dp_data *data; > struct mtk_dp_info info; > struct mtk_dp_train_info train_info; > + struct edid *edid; > > struct platform_device *phy_dev; > struct phy *phy; > @@ -1993,7 +1994,11 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, > usleep_range(2000, 5000); > } > > - new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); > + /* eDP panels aren't removable, so we can return a cached EDID. */ > + if (mtk_dp->edid && mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) > + new_edid = drm_edid_duplicate(mtk_dp->edid); > + else > + new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); Maybe it would make sense to add a macro for the check of mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP it would make the code more readable. > > /* > * Parse capability here to let atomic_get_input_bus_fmts and > @@ -2022,6 +2027,10 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, > drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); > } > > + /* If this is an eDP panel and the read EDID is good, cache it for later */ > + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP && !mtk_dp->edid && new_edid) > + mtk_dp->edid = drm_edid_duplicate(new_edid); > + How about putting this in an else if branch of mtk_dp_parse_capabilities. At least we could get rid of the check regarding if new_edid != NULL. I was thinking on how to put both if statements in one block, but I think the problem is, that we would leak memory if the capability parsing failes due to the call to drm_edid_duplicate(). Correct? Regards, Matthais > return new_edid; > }. / >
Il 12/04/23 09:08, Matthias Brugger ha scritto: > > > On 04/04/2023 12:47, AngeloGioacchino Del Regno wrote: >> Since eDP panels are not removable it is safe to cache the EDID: >> this will avoid a relatively long read transaction at every PM >> resume that is unnecessary only in the "special" case of eDP, >> hence speeding it up a little, as from now on, as resume operation, >> we will perform only link training. >> >> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> >> --- >> drivers/gpu/drm/mediatek/mtk_dp.c | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c >> index 1f94fcc144d3..84f82cc68672 100644 >> --- a/drivers/gpu/drm/mediatek/mtk_dp.c >> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c >> @@ -118,6 +118,7 @@ struct mtk_dp { >> const struct mtk_dp_data *data; >> struct mtk_dp_info info; >> struct mtk_dp_train_info train_info; >> + struct edid *edid; >> struct platform_device *phy_dev; >> struct phy *phy; >> @@ -1993,7 +1994,11 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge >> *bridge, >> usleep_range(2000, 5000); >> } >> - new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); >> + /* eDP panels aren't removable, so we can return a cached EDID. */ >> + if (mtk_dp->edid && mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) >> + new_edid = drm_edid_duplicate(mtk_dp->edid); >> + else >> + new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); > > Maybe it would make sense to add a macro for the check of mtk_dp->bridge.type == > DRM_MODE_CONNECTOR_eDP > it would make the code more readable. > I had the same idea... but then avoided that because in most (if not all?) of the DRM drivers (at least, the one I've read) this check is always open coded, so I wrote it like that for consistency and nothing else. I have no strong opinions on that though! >> /* >> * Parse capability here to let atomic_get_input_bus_fmts and >> @@ -2022,6 +2027,10 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge >> *bridge, >> drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); >> } >> + /* If this is an eDP panel and the read EDID is good, cache it for later */ >> + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP && !mtk_dp->edid && new_edid) >> + mtk_dp->edid = drm_edid_duplicate(new_edid); >> + > > How about putting this in an else if branch of mtk_dp_parse_capabilities. At least > we could get rid of the check regarding if new_edid != NULL. > > I was thinking on how to put both if statements in one block, but I think the > problem is, that we would leak memory if the capability parsing failes due to the > call to drm_edid_duplicate(). Correct? > Correct. The only other "good" place would be in the `if (new_edid)` conditional, but that wouldn't be as readable as it is right now... Cheers, Angelo
On 12/04/2023 10:06, AngeloGioacchino Del Regno wrote: > Il 12/04/23 09:08, Matthias Brugger ha scritto: >> >> >> On 04/04/2023 12:47, AngeloGioacchino Del Regno wrote: >>> Since eDP panels are not removable it is safe to cache the EDID: >>> this will avoid a relatively long read transaction at every PM >>> resume that is unnecessary only in the "special" case of eDP, >>> hence speeding it up a little, as from now on, as resume operation, >>> we will perform only link training. >>> >>> Signed-off-by: AngeloGioacchino Del Regno >>> <angelogioacchino.delregno@collabora.com> >>> --- >>> drivers/gpu/drm/mediatek/mtk_dp.c | 11 ++++++++++- >>> 1 file changed, 10 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c >>> b/drivers/gpu/drm/mediatek/mtk_dp.c >>> index 1f94fcc144d3..84f82cc68672 100644 >>> --- a/drivers/gpu/drm/mediatek/mtk_dp.c >>> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c >>> @@ -118,6 +118,7 @@ struct mtk_dp { >>> const struct mtk_dp_data *data; >>> struct mtk_dp_info info; >>> struct mtk_dp_train_info train_info; >>> + struct edid *edid; >>> struct platform_device *phy_dev; >>> struct phy *phy; >>> @@ -1993,7 +1994,11 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge >>> *bridge, >>> usleep_range(2000, 5000); >>> } >>> - new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); >>> + /* eDP panels aren't removable, so we can return a cached EDID. */ >>> + if (mtk_dp->edid && mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) Maybe better like this: if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP && mtk_dp->edid) To in sync with the if statement below. Anyway we are only concerned if it's an eDP so check that first (and hope the compiler will do so as well ;) With that: Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> >>> + new_edid = drm_edid_duplicate(mtk_dp->edid); >>> + else >>> + new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); >> >> Maybe it would make sense to add a macro for the check of mtk_dp->bridge.type >> == DRM_MODE_CONNECTOR_eDP >> it would make the code more readable. >> > > I had the same idea... but then avoided that because in most (if not all?) of the > DRM drivers (at least, the one I've read) this check is always open coded, so I > wrote it like that for consistency and nothing else. > > I have no strong opinions on that though! > I think the only reasonable solution would be a macro like: DRM_CONNECTOR_MODE_IS(mtk_dp->bridge.type, eDP) which in the end is longer then open-code it, so probably just leave it as it is. >>> /* >>> * Parse capability here to let atomic_get_input_bus_fmts and >>> @@ -2022,6 +2027,10 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge >>> *bridge, >>> drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); >>> } >>> + /* If this is an eDP panel and the read EDID is good, cache it for later */ >>> + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP && !mtk_dp->edid && >>> new_edid) >>> + mtk_dp->edid = drm_edid_duplicate(new_edid); >>> + >> >> How about putting this in an else if branch of mtk_dp_parse_capabilities. At >> least we could get rid of the check regarding if new_edid != NULL. >> >> I was thinking on how to put both if statements in one block, but I think the >> problem is, that we would leak memory if the capability parsing failes due to >> the call to drm_edid_duplicate(). Correct? >> > > Correct. The only other "good" place would be in the `if (new_edid)` conditional, > but that wouldn't be as readable as it is right now... > > Cheers, > Angelo >
diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 1f94fcc144d3..84f82cc68672 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -118,6 +118,7 @@ struct mtk_dp { const struct mtk_dp_data *data; struct mtk_dp_info info; struct mtk_dp_train_info train_info; + struct edid *edid; struct platform_device *phy_dev; struct phy *phy; @@ -1993,7 +1994,11 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, usleep_range(2000, 5000); } - new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); + /* eDP panels aren't removable, so we can return a cached EDID. */ + if (mtk_dp->edid && mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) + new_edid = drm_edid_duplicate(mtk_dp->edid); + else + new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); /* * Parse capability here to let atomic_get_input_bus_fmts and @@ -2022,6 +2027,10 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); } + /* If this is an eDP panel and the read EDID is good, cache it for later */ + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP && !mtk_dp->edid && new_edid) + mtk_dp->edid = drm_edid_duplicate(new_edid); + return new_edid; }