Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp631514pxb; Tue, 2 Feb 2021 13:47:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxO5qKUvTx2yAxYZ5JOO3HxLL/oEDf4q9Dr9K0KUEPwtzRBcO39bkd16Xg0/1kQCJM0JXG X-Received: by 2002:a17:907:2d9e:: with SMTP id gt30mr14247ejc.357.1612302439278; Tue, 02 Feb 2021 13:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612302439; cv=none; d=google.com; s=arc-20160816; b=IFeHy5z4dIJZsQvTmUjh8WrhQK6oPEtYPPwJYB59dBIES2Pq5hfzlHk8R8HY4VOIlD 5gr7mh8tY2ga10XWUeh+SlmO5D4EYLBr0tlPqdkz2KtvhuoJ4EAG05AczBypQnWEqKOq ctke7PTfaeA7PjFKsYpH5NgP5JADhqjxG7TcJpfcSmHBfk2RQ44s6TqrgpkkJVqIwcHK 7UUUkCfqPozzViv5kZKnyeQ411TReL1O2atkrAFwo6slhvItkdt/nJBWoxfTY84euSRK c695C2OIBYn1mFC+G1423FfQ21GVl6Z8hZRteaGRSKnwdHbALtSceH58M+/5ny7vF0gB FzYg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZSg7s8PfXVn4fR3ZY1nMJoyv0Hd/7HCZKQBFFmEB8AU=; b=avb5ZPCe3n5LLu6pfq72qEAwCe3LAEsELouPLyjn2sg0Zi3OvXPAhmhBVSQPTnR/oA t5K9y9tkqQk2tRgpxAQ6CQkKjcK/0jMtWn1cJWKMYGCnH+L8aYkTWw7L5yUoxerosbj9 h+ntTmKts1VtX3eN4oT+8ZbR/1CkmJh66hBYE3UOqnd+pNsgob8EX6SLy+/9SfY7cGQF pi/FfVAwIOQQ+nOuGUktSXwJoOvo42De0X+rMFtAJ2xrLtvHSmB6DJw2Tj4ZPoX8t+jX BBsmRCJ6DGdAOhelLTK1YJuELsjoTRykoK7dHFaSqFXbbV1t6Tf0zf+nPIih7/vK3GrE zPZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fib7qLc2; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw9si67097ejb.131.2021.02.02.13.46.55; Tue, 02 Feb 2021 13:47:19 -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=@linuxfoundation.org header.s=korg header.b=fib7qLc2; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233301AbhBBNx4 (ORCPT + 99 others); Tue, 2 Feb 2021 08:53:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:38148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232957AbhBBNrY (ORCPT ); Tue, 2 Feb 2021 08:47:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8AA2A64F97; Tue, 2 Feb 2021 13:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273315; bh=Kt3W7cA1hg+sePDqblda2yarj6vgGtie9dE1Zw3Hj5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fib7qLc2QehfZp9yKA43uML8adp2dGevT2c/c5v2gcTzZuCcuxZgG5OVGYRMKFIaq UZ/z1E+/mSlwE8P/8102AxeeRnEuFz1mVmbUPQVVDH9UMcKXhU0N/Aixw8pYz58NeI y7xO1JW6/uLptAGF3VWQYLsFoY85DR+GnrA5tcX8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dom Cobley , Maxime Ripard , Dave Stevenson , Lucas Nussbaum , Ryutaroh Matsumoto Subject: [PATCH 5.10 060/142] drm/vc4: Correct lbm size and calculation Date: Tue, 2 Feb 2021 14:37:03 +0100 Message-Id: <20210202133000.198376282@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dom Cobley commit 78e5330329ee206d6aa4593a90320fd837f7966e upstream. LBM base address is measured in units of pixels per cycle. That is 4 for 2711 (hvs5) and 2 for 2708. We are wasting 75% of lbm by indexing without the scaling. But we were also using too high a size for the lbm resulting in partial corruption (right hand side) of vertically scaled images, usually at 4K or lower resolutions with more layers. The physical RAM of LBM on 2711 is 8 * 1920 * 16 * 12-bit (pixels are stored 12-bits per component regardless of format). The LBM address indexes work in units of pixels per clock, so for 4 pixels per clock that means we have 32 * 1920 = 60K Fixes: c54619b0bfb3 ("drm/vc4: Add support for the BCM2711 HVS5") Signed-off-by: Dom Cobley Signed-off-by: Maxime Ripard Reviewed-by: Dave Stevenson Tested-By: Lucas Nussbaum Tested-By: Ryutaroh Matsumoto Link: https://patchwork.freedesktop.org/patch/msgid/20210121105759.1262699-1-maxime@cerno.tech Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vc4/vc4_hvs.c | 8 ++++---- drivers/gpu/drm/vc4/vc4_plane.c | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) --- a/drivers/gpu/drm/vc4/vc4_hvs.c +++ b/drivers/gpu/drm/vc4/vc4_hvs.c @@ -618,11 +618,11 @@ static int vc4_hvs_bind(struct device *d * for now we just allocate globally. */ if (!hvs->hvs5) - /* 96kB */ - drm_mm_init(&hvs->lbm_mm, 0, 96 * 1024); + /* 48k words of 2x12-bit pixels */ + drm_mm_init(&hvs->lbm_mm, 0, 48 * 1024); else - /* 70k words */ - drm_mm_init(&hvs->lbm_mm, 0, 70 * 2 * 1024); + /* 60k words of 4x12-bit pixels */ + drm_mm_init(&hvs->lbm_mm, 0, 60 * 1024); /* Upload filter kernels. We only have the one for now, so we * keep it around for the lifetime of the driver. --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -437,6 +437,7 @@ static void vc4_write_ppf(struct vc4_pla static u32 vc4_lbm_size(struct drm_plane_state *state) { struct vc4_plane_state *vc4_state = to_vc4_plane_state(state); + struct vc4_dev *vc4 = to_vc4_dev(state->plane->dev); u32 pix_per_line; u32 lbm; @@ -472,7 +473,11 @@ static u32 vc4_lbm_size(struct drm_plane lbm = pix_per_line * 16; } - lbm = roundup(lbm, 32); + /* Align it to 64 or 128 (hvs5) bytes */ + lbm = roundup(lbm, vc4->hvs->hvs5 ? 128 : 64); + + /* Each "word" of the LBM memory contains 2 or 4 (hvs5) pixels */ + lbm /= vc4->hvs->hvs5 ? 4 : 2; return lbm; }