Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp117491pxu; Thu, 10 Dec 2020 20:27:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3lQoTANfcVUtX1VmvsAX+Bq+Di2GDJAtEuAcx/CPeqGxOEho0sI4vS3pw19vMkqLknOMZ X-Received: by 2002:aa7:c919:: with SMTP id b25mr9698214edt.108.1607660859888; Thu, 10 Dec 2020 20:27:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607660859; cv=none; d=google.com; s=arc-20160816; b=GUCMs4no0GmRWhDIGMBKz+II+dduIU8q8be3s+PcW7AuvK2IzuT4jBM30Q9V4xwiyO e0qV6w1BcxnM41BzaQMyyBplWRxHiK84zb5UVWF04rxrBbBrIttxcqhgiXWc0Vtzm2AU nga/LqqvWbRB+hosecFjsPRKsc08gL0ys2Um9c6rxUM2TppJc8m4D9t7qge4zfENWwTD 8Cr1vtKnK+B8QcrtffifCA2EvIWLaxfEqJicMiuFSnNuV7o4OwvejeXHRYxrtIIN2YAi q9EIQQHEV4nrnDXrFdxxDrDeb5yT/4R2yOEaB9/VHemlKgVVI+PTB1XSVb2XP8ga6w7d B2xw== 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:dkim-signature; bh=+8Peq+aA0pf7+XBnW4o9oio5mhtAYTcXdLqVFsQqfiA=; b=prF6c3ITRJDM5pOalRNZ1FGgOUOPGg6DG2ycXG7BXcCXr8JEeRtA0rKus2TdFh9HhY COMqt8syQaEqbJKl+RaPhwqVQdFJI20lrF5iEqW1MfneRW6jOhYtgCGCCgCy2hGmWvxd MDELWwpY/2ekDLQ/MBwjtXNBTbv0ExZFj6DoOMhXfPElKl+OLAB9Toiu4K925rtOb2Ni v5i4tLXCi4EKKaM4qIzIk5Drmy4yXODSuNVkP0FkgQMgnStVPnc8v968UuLY76NMzYvL 0Rw28EgTVVeq3BT/7xs91RdzBYJplVVyirdzHe/xstQtxoIKNb9QBSyWg8c85SfuNPTG qITA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm1 header.b=fQvsria5; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=NzYOiw8y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm4si3869394ejb.283.2020.12.10.20.27.16; Thu, 10 Dec 2020 20:27:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm1 header.b=fQvsria5; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=NzYOiw8y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389995AbgLJOHD (ORCPT + 99 others); Thu, 10 Dec 2020 09:07:03 -0500 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:49809 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389126AbgLJNsC (ORCPT ); Thu, 10 Dec 2020 08:48:02 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.west.internal (Postfix) with ESMTP id 037C7EC0; Thu, 10 Dec 2020 08:46:54 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 10 Dec 2020 08:46:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=+8Peq+aA0pf7+ XBnW4o9oio5mhtAYTcXdLqVFsQqfiA=; b=fQvsria5XvwY+V4dl+JNKr3FZX9M6 d+1O5uIqXC51gdbrNsO/7qhAHl0BvNPDgBf8sZYVJMJIY7/HC4M6IhIeQDZ4ZOuc JODf1wp9bPHvZ3wtT6DaFEw/uZBQ42XZQlIFPgz2SnpoXNScxChtMOlwaPBiSh9+ /hgLnxei4WImhKzj2wydujo20VRRLTlwciz+31jsgebDLLTkNScrqFGQH+z7VOym R6IIqolSr5WvVWpa9eJ6uTF7/BstxOQdfU07+LnIn/nJmrhg9PUjzYUWb9SS6J6Y ZJqwIN8gW71fc7TttEBQJTi3uEM2wT+7aCucikUFs1s6eSHGyZ1lI8PFw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=+8Peq+aA0pf7+XBnW4o9oio5mhtAYTcXdLqVFsQqfiA=; b=NzYOiw8y g//hMBaNu/MNPxcjNtWSBOyj3+gvUGSfqvfrnVHy7OHQufOARZp4zweXON+vjRGw iJdWF92hhuO8Ir++YTZlV93jDZfso8vOpCGLFjKYdcXz+4njSTAsJvnA5JZfPAvJ d0c+k8tVrUQ45ZY0izCOs3TrrZ4o6NXNk9ziBc5NukQCqSVsCC5xEIuNsIFcT33P 2aiqTA1uS8DBNPOYXlfIOz8Qqa2oXq6LmUurjGjvH+/jeisogugAXjr/G5h1ytM5 M7lULzE6c1Du6zrTKcuSOKkDN6k31Fj8LVhIWFGrXencgDJZ3qp3KiMgX2zMpPDf xXqJDPOLihuTqA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudektddgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id DBDBA108005C; Thu, 10 Dec 2020 08:46:53 -0500 (EST) From: Maxime Ripard To: Eric Anholt , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie Cc: Jason Cooper , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, Marc Zyngier , linux-media@vger.kernel.org, Hans Verkuil , linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Thomas Gleixner , Dave Stevenson , linux-rpi-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Dom Cobley Subject: [PATCH 03/15] drm/vc4: hdmi: Fix register offset with longer CEC messages Date: Thu, 10 Dec 2020 14:46:36 +0100 Message-Id: <20201210134648.272857-4-maxime@cerno.tech> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201210134648.272857-1-maxime@cerno.tech> References: <20201210134648.272857-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dom Cobley The code prior to 311e305fdb4e ("drm/vc4: hdmi: Implement a register layout abstraction") was relying on the fact that the register offset was incremented by 4 for each readl call. That worked since the register width is 4 bytes. However, since that commit the HDMI_READ macro is now taking an enum, and the offset doesn't increment by 4 but 1 now. Divide the index by 4 to fix this. Fixes: 311e305fdb4e ("drm/vc4: hdmi: Implement a register layout abstraction") Signed-off-by: Dom Cobley Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 3df1747dd917..28b78ea885ea 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1434,13 +1434,20 @@ static irqreturn_t vc4_cec_irq_handler_thread(int irq, void *priv) static void vc4_cec_read_msg(struct vc4_hdmi *vc4_hdmi, u32 cntrl1) { + struct drm_device *dev = vc4_hdmi->connector.dev; struct cec_msg *msg = &vc4_hdmi->cec_rx_msg; unsigned int i; msg->len = 1 + ((cntrl1 & VC4_HDMI_CEC_REC_WRD_CNT_MASK) >> VC4_HDMI_CEC_REC_WRD_CNT_SHIFT); + + if (msg->len > 16) { + drm_err(dev, "Attempting to read too much data (%d)\n", msg->len); + return; + } + for (i = 0; i < msg->len; i += 4) { - u32 val = HDMI_READ(HDMI_CEC_RX_DATA_1 + i); + u32 val = HDMI_READ(HDMI_CEC_RX_DATA_1 + (i >> 2)); msg->msg[i] = val & 0xff; msg->msg[i + 1] = (val >> 8) & 0xff; @@ -1533,11 +1540,17 @@ static int vc4_hdmi_cec_adap_transmit(struct cec_adapter *adap, u8 attempts, u32 signal_free_time, struct cec_msg *msg) { struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); + struct drm_device *dev = vc4_hdmi->connector.dev; u32 val; unsigned int i; + if (msg->len > 16) { + drm_err(dev, "Attempting to transmit too much data (%d)\n", msg->len); + return -ENOMEM; + } + for (i = 0; i < msg->len; i += 4) - HDMI_WRITE(HDMI_CEC_TX_DATA_1 + i, + HDMI_WRITE(HDMI_CEC_TX_DATA_1 + (i >> 2), (msg->msg[i]) | (msg->msg[i + 1] << 8) | (msg->msg[i + 2] << 16) | -- 2.28.0