From patchwork Wed Mar 7 21:58:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 130922 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp5699781lja; Wed, 7 Mar 2018 14:00:38 -0800 (PST) X-Google-Smtp-Source: AG47ELuDe4DSz3cs3rSVooL+KhvcxA/MGyC2ROf0SbTN8HEuxEqA4wEEAsFMWZh7cFVUcj+2ieoN X-Received: by 10.98.165.4 with SMTP id v4mr19096572pfm.51.1520460038568; Wed, 07 Mar 2018 14:00:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520460038; cv=none; d=google.com; s=arc-20160816; b=XlAgB2GcId6Ezc9MM4upsa5XUXNKAwFLUxG/NKHzMO7ZmofOlnG5w42wp57FBmMyuM 6YFQYn+QUZcyq0WWK50X/UrRNP+9BHZBKwg1BPavoPvtIspig5crYaSBuxqMrXLWpMxB fgQb6+GcWS4s3KPFF1D2i9zCXsxXQ3VP3IYTgenZqBFeZHC2kifajn204N/YTRBQbbPS 7MpZEZwDe33OiPcqKuRkVh9aUFQitLN84bECx+eRyUk+/ptfyh8pnY40fGHkU/O+IVls TENQQcRes6UkL1GSTKD9vAdOOrb7NeO6FjIEKEGo4ppIp6PCkcph8+yV8QX2JbN41oMY o+Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=4cnH828/teYORF4QvJUZi0HA5qwYQvqYXUH8jSTKPy8=; b=Xyk+neH5nuA+2pGllybFBnsjmWTsyGC+CR5T+NX+r8fxhKBX101D16yt8vDvjbaPpI GcUzhNb4W3Lxoj5Yu87y8CD3c0cPPHLUvlz0LS9AYpPxnP55Jfa1GdmlK4xUund18e1j srUlvGwWmsORHutui+0q00tSUri7rTyjYMFjzWjfCj9e9yTUHO9/D8iac7la/OK68x2b OTctg2L3Tbyvp1kP+LZCG+fiH07ZoQ0lPbU9ZhljL7lv8tPDS+HQrgkay+ygWwqfej5U o238gmZEsAA0fq02TVO2I6k5W3i9Y21z9RNWCh+Q18noDe/F9eK/aVtepBnf5aDBx2xl TZRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OWVT8xNc; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id b6-v6si8716154plx.302.2018.03.07.14.00.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Mar 2018 14:00:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OWVT8xNc; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E450F6E208; Wed, 7 Mar 2018 22:00:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 65A676E208 for ; Wed, 7 Mar 2018 22:00:34 +0000 (UTC) Received: by mail-lf0-x244.google.com with SMTP id h127-v6so5451898lfg.12 for ; Wed, 07 Mar 2018 14:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=44MtWOqMq9qtQXRbrJF1fXZNR67Y9n+q+5Nce9uQxKk=; b=OWVT8xNcxFpwglcUeI/lmj+QwyVaCxdjP41RY7FAesbCJw9O2xTZadzgihr207fkAh 7zo0+fb/ql/6LNlcMDHoWZi7zsSetW98nsNHXDS5IQA5BR9W0VVstqF7+rvOcFgUUgSv S/8gAVBfZEwK0tjmW2jQxhg/5lyN0WlIaOt10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=44MtWOqMq9qtQXRbrJF1fXZNR67Y9n+q+5Nce9uQxKk=; b=FgoPimojENHE+HNcBYZeZ2vz/Cryyqzzx0k5YNoOfhnmEHUh5SfOEzU16i8zjDXKTk Qhnv0HeJir5PP/fYg/0hplY+D1NNS2DNDfyF2V4SgXd0XrN2HY23wCS1XwKBRbMpoL2A YOfvaA7Egf7P4vIxCluz/ZoEQe8pIhMY3MacZE8YWhtB5Ert3sHIXZDY3cq7cI1ZLb56 XFoGc+L8qXmfdCy6kBj2uTfos9ZKbVUtClVWXoxBrTGmGaiqPKGnLq1wtvJv1yRUBDug 86fQJowIzJWdC6jOAsrNMiuagwOI4/VAbDdmHL3IObA1QP6v2ccKRn6MponFCO2CNYpL pOWA== X-Gm-Message-State: AElRT7FEVyNl+X/THnFIEBHNh3e8QEmJkpp69Sf6suSvV+OpoFU8Qhj8 UKlN/JdyLnlp91wl/PivZn683g== X-Received: by 10.25.19.226 with SMTP id 95mr17563610lft.57.1520460031120; Wed, 07 Mar 2018 14:00:31 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id m131sm2811897lfg.48.2018.03.07.14.00.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Mar 2018 14:00:30 -0800 (PST) From: Linus Walleij To: Daniel Vetter , Jani Nikula , Sean Paul , Eric Anholt Subject: [PATCH v5] drm/pl111: Use max memory bandwidth for resolution Date: Wed, 7 Mar 2018 22:58:19 +0100 Message-Id: <20180307215819.15814-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We were previously selecting 1024x768 and 32BPP as the default set-up for the PL111 consumers. This does not work on elder systems: the device tree bindings support a property "max-memory-bandwidth" in bytes/second that states that if you exceed this the memory bus will saturate. The result is flickering and unstable images. Parse the "max-memory-bandwidth" and respect it when intializing the driver. On the RealView PB11MP, Versatile and Integrator/CP we get a nice console as default with this code. Reviewed-by: Eric Anholt Signed-off-by: Linus Walleij --- ChangeLog v4->v5: - Rebase on top of drm-next and resend so the patch applies and produce a reasonable link. I have no clue why patch does not apply, it looks like it should, but the git moves in mysterious ways. ChangeLog v3->v4: - Switch the noisy DRM_INFO for DRM_DEBUG_KMS - Collect Eric's review tag ChangeLog v2->v3: - Account for the case where there is no bandwidth limitation so priv->memory_bw is zero. Then just accept any modes. ChangeLog v1->v2: - Exploit the new .mode_valid() callback we added to the simple KMS helper. - Use the hardcoded bits per pixel per variant instead of trying to be heuristic about this setting for now. --- drivers/gpu/drm/pl111/pl111_display.c | 36 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/pl111/pl111_drm.h | 1 + drivers/gpu/drm/pl111/pl111_drv.c | 6 ++++++ 3 files changed, 43 insertions(+) diff --git a/drivers/gpu/drm/pl111/pl111_display.c b/drivers/gpu/drm/pl111/pl111_display.c index 5b8368c76734..310646427907 100644 --- a/drivers/gpu/drm/pl111/pl111_display.c +++ b/drivers/gpu/drm/pl111/pl111_display.c @@ -50,6 +50,41 @@ irqreturn_t pl111_irq(int irq, void *data) return status; } +static enum drm_mode_status +pl111_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) +{ + struct drm_device *drm = crtc->dev; + struct pl111_drm_dev_private *priv = drm->dev_private; + u32 cpp = priv->variant->fb_bpp / 8; + u64 bw; + + /* + * We use the pixelclock to also account for interlaced modes, the + * resulting bandwidth is in bytes per second. + */ + bw = mode->clock * 1000; /* In Hz */ + bw = bw * mode->hdisplay * mode->vdisplay * cpp; + bw = div_u64(bw, mode->htotal * mode->vtotal); + + /* + * If no bandwidth constraints, anything goes, else + * check if we are too fast. + */ + if (priv->memory_bw && (bw > priv->memory_bw)) { + DRM_DEBUG_KMS("%d x %d @ %d Hz, %d cpp, bw %llu too fast\n", + mode->hdisplay, mode->vdisplay, + mode->clock * 1000, cpp, bw); + + return MODE_BAD; + } + DRM_DEBUG_KMS("%d x %d @ %d Hz, %d cpp, bw %llu bytes/s OK\n", + mode->hdisplay, mode->vdisplay, + mode->clock * 1000, cpp, bw); + + return MODE_OK; +} + static int pl111_display_check(struct drm_simple_display_pipe *pipe, struct drm_plane_state *pstate, struct drm_crtc_state *cstate) @@ -348,6 +383,7 @@ static int pl111_display_prepare_fb(struct drm_simple_display_pipe *pipe, } static struct drm_simple_display_pipe_funcs pl111_display_funcs = { + .mode_valid = pl111_mode_valid, .check = pl111_display_check, .enable = pl111_display_enable, .disable = pl111_display_disable, diff --git a/drivers/gpu/drm/pl111/pl111_drm.h b/drivers/gpu/drm/pl111/pl111_drm.h index 2a93e0134061..8639b2d4ddf7 100644 --- a/drivers/gpu/drm/pl111/pl111_drm.h +++ b/drivers/gpu/drm/pl111/pl111_drm.h @@ -65,6 +65,7 @@ struct pl111_drm_dev_private { struct drm_simple_display_pipe pipe; void *regs; + u32 memory_bw; u32 ienb; u32 ctrl; /* The pixel clock (a reference to our clock divider off of CLCDCLK). */ diff --git a/drivers/gpu/drm/pl111/pl111_drv.c b/drivers/gpu/drm/pl111/pl111_drv.c index e92a406c9ea9..4621259d5387 100644 --- a/drivers/gpu/drm/pl111/pl111_drv.c +++ b/drivers/gpu/drm/pl111/pl111_drv.c @@ -257,6 +257,12 @@ static int pl111_amba_probe(struct amba_device *amba_dev, drm->dev_private = priv; priv->variant = variant; + if (of_property_read_u32(dev->of_node, "max-memory-bandwidth", + &priv->memory_bw)) { + dev_info(dev, "no max memory bandwidth specified, assume unlimited\n"); + priv->memory_bw = 0; + } + /* The two variants swap this register */ if (variant->is_pl110) { priv->ienb = CLCD_PL110_IENB;