From patchwork Mon Jul 17 14:14:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 121368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1148446vqt; Mon, 17 Jul 2023 07:31:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTHYKt1hQCEoBMXGrC+6gwk6h3+yskOkO07KMVe0k1/XkfQ6FOK6IFKags2JZilnkaAv5b X-Received: by 2002:a17:902:e54a:b0:1b8:b564:b531 with SMTP id n10-20020a170902e54a00b001b8b564b531mr13885153plf.60.1689604265905; Mon, 17 Jul 2023 07:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689604265; cv=none; d=google.com; s=arc-20160816; b=HQ9ceYpQuDg/9I4nnlvZlVnrpgSs9mqdcMCqz1DfS9SKIzLqrhw4sYjSZhakgWVNMJ LjU+d3CPnSnGNty+aNO7fdBTHjyoT7jQh0zmz/JK6t9kuR3CbMDQt35DsGcLbv666CXg bGJ1ic5UuF/NyLs84rt59A8Fq4ff/pXOhf+epf1kGTA8nZgftsnPPXTZd8KFm9CA0rFF Vx89uluqyDhwaUQ4K7gsD0oxe6CK06skxVN/J0xmx7tD4566YKSkvcQ9onGdpCxDShWM DwQbSToOFyxcmwHuIas1kM/BxmaEdCBveRlZfGQDW+WnMoAlL3PSmtO6gVET3lMupvIO Jgdw== 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=qKUquht6FkZ7UbaykQu1vWdkqUBNavxHAwysVBfLzvU=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=jngwEXaM149alIqtFdOdjYrdgLvks0atY9FlQSLgGLEnQG9oOjv9PusazjikxQXBXx kl55uuV8B5F3+LCK7HuucyKPKPa79M7y2dLMwTM2LDxH6F/OgGnIMRPtDLXSk5IAIGpy N8PBEs/Q/V+NLVY4fZoML982+JwRWG6jgR8Ck3DgfGzlDhN5XOQpxDLYtOF2P3ZV4sHP RQ/baOke837ImwiYgES+tiONjC6Oyvvxy+XSKMK2TZoDgfrZ4QBAWEVBCIGVLOQIjSOn kFc7sd+DcUcZOMggbUD82+cPLoqxQheC7zZ0rVM8Yb7CAW0TcBCAYM1S2u9OnkOgSiy6 OE+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TeYzdmgz; 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 n9-20020a170903404900b001b80643d647si11099338pla.146.2023.07.17.07.30.52; Mon, 17 Jul 2023 07:31:05 -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=TeYzdmgz; 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 S232120AbjGQOOz (ORCPT + 99 others); Mon, 17 Jul 2023 10:14:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232139AbjGQOOw (ORCPT ); Mon, 17 Jul 2023 10:14:52 -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 2EBE01A2 for ; Mon, 17 Jul 2023 07:14:46 -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 A4BF16607014; Mon, 17 Jul 2023 15:14:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1689603284; bh=9oUBdhJxcjM5c8eCCSSOcqllo9ke9sPNjeRntNkLNoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TeYzdmgz451EjrdZo/zdtYmOyZJdAqLoIhaELRWmIqur4GlMcs3zKmEo90E72X8Ty 3HVRCAt2HIi3mYzFGcG808hwhyH2r3PVBb78RQ8gRjoOzHlNdFReAc1xMiudCTe3ph 1tFbXQLW3OpziaEM8CIatOvs/QJerwnhFza1tA4RtdQ9cc/yOA621C+xxGk7ztRUpe /wYMEc7oK6M0TRiPp8Bk2ds0C7RBLmpaGKd/iC0iFjt/KsJvWCG+ugSc8g4P3wNo6d u5vQfYYh7hc3HDfWv53eyb+5WwQzF+Km0k0CZZaaoZncB246/sYKB8FAvAYiqRc8+k mCnkzDomm7B4Q== From: AngeloGioacchino Del Regno 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, nfraprado@collabora.com Subject: [PATCH v6 01/11] drm/mediatek: dp: Add missing error checks in mtk_dp_parse_capabilities Date: Mon, 17 Jul 2023 16:14:28 +0200 Message-Id: <20230717141438.274419-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230717141438.274419-1-angelogioacchino.delregno@collabora.com> References: <20230717141438.274419-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771678482521931473 X-GMAIL-MSGID: 1771678482521931473 If reading the RX capabilities fails the training pattern will be set wrongly: add error checking for drm_dp_read_dpcd_caps() and return if anything went wrong with it. While at it, also add a less critical error check when writing to clear the ESI0 IRQ vector. Fixes: f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver") Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_dp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 64eee77452c0..c58b775877a3 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1588,7 +1588,9 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp) u8 val; ssize_t ret; - drm_dp_read_dpcd_caps(&mtk_dp->aux, mtk_dp->rx_cap); + ret = drm_dp_read_dpcd_caps(&mtk_dp->aux, mtk_dp->rx_cap); + if (ret < 0) + return ret; if (drm_dp_tps4_supported(mtk_dp->rx_cap)) mtk_dp->train_info.channel_eq_pattern = DP_TRAINING_PATTERN_4; @@ -1615,10 +1617,13 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp) return ret == 0 ? -EIO : ret; } - if (val) - drm_dp_dpcd_writeb(&mtk_dp->aux, - DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0, - val); + if (val) { + ret = drm_dp_dpcd_writeb(&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0, + val); + if (ret < 0) + return ret; + } } return 0;