Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2160693ybl; Thu, 29 Aug 2019 04:31:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIqDTe69fg5VAvKckp10ObqVIeaPKQTmy27f+78DEMq0uNj9e/Zbc1K9Bb+EXXMxaoHYM2 X-Received: by 2002:a63:d315:: with SMTP id b21mr8048201pgg.326.1567078313875; Thu, 29 Aug 2019 04:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567078313; cv=none; d=google.com; s=arc-20160816; b=KT9mkARcW6xz3pTOIvIkBfZkrWUm2IVsfa7JXrC9x9G2KY3G7NcCU+D+Et+FdLVjyW ZozlX9d0ewO4nMBHPnBRlVA7Rt/YNLQaRqZdY1hze4te4o9ZChutNIogs+tlUFohS86I JdET0s33UL6A6nmyLnfJMbP4q5ztVni7BlqVmW3YDjLJKjKHGbKpv3zXAjA8tmaZrcjb hRSAa9cBBdpAFlPvYIGsktKAYQo+ddm86bDchyB5Bre4yx1pA1RC9YqG1ix7nXr0jA/K Aelhj556lQIe0ITCicagTdUlcpuaI4kRb5t/WtXYQmc3SFxKPhTmhX/0MjVBHggJpy4I KAag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sEwoPbDamCypphVCfnHI38mxCoalth15ATon4F4FB+E=; b=aEj+gcnDn9suY+/CCAAQEC5cwWDGeEhs6Ne9qPbP/KmCNSQjUF8fluR84jQWbNw6AO kOS0R+5Ky1wf4NuPjS135g+ywrlQWHdo41xrtPhgNLMgCFPJKiOm3+rgvm4iSpq3zJuM wUPM5FYfyvxppeBcVzTkOsPf6Ly0vOHCBsoxxIWIRhiaZsGqRev/A+IjhjC7/xihLL4j yzDP3A0IXymURgaN7PRwF6gV64aNOl92ZtKV3OwKI/JT6mTPH2/vFFEvb1O/EP9huTsi S/oCnjtHICP0Rk0yAT9qlVg7pPDLrJwNOMVU321cDbJg9Hm9R2GJ7V+SpMDQ3K26FOKz K+CA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q145si2306105pfc.31.2019.08.29.04.31.37; Thu, 29 Aug 2019 04:31:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728249AbfH2Lah (ORCPT + 99 others); Thu, 29 Aug 2019 07:30:37 -0400 Received: from inva021.nxp.com ([92.121.34.21]:49330 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728010AbfH2La0 (ORCPT ); Thu, 29 Aug 2019 07:30:26 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 912F420033A; Thu, 29 Aug 2019 13:30:24 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 842CB200335; Thu, 29 Aug 2019 13:30:24 +0200 (CEST) Received: from fsr-ub1664-120.ea.freescale.net (fsr-ub1664-120.ea.freescale.net [10.171.82.81]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id D5BD320613; Thu, 29 Aug 2019 13:30:23 +0200 (CEST) From: Robert Chiras To: =?UTF-8?q?Guido=20G=C3=BCnther?= , Marek Vasut , Stefan Agner , David Airlie , Daniel Vetter , Rob Herring , Mark Rutland , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 08/14] drm/mxsfb: Add max-memory-bandwidth property for MXSFB Date: Thu, 29 Aug 2019 14:30:09 +0300 Message-Id: <1567078215-31601-9-git-send-email-robert.chiras@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1567078215-31601-1-git-send-email-robert.chiras@nxp.com> References: <1567078215-31601-1-git-send-email-robert.chiras@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because of stability issues, we may want to limit the maximum bandwidth required by the MXSFB (eLCDIF) driver. Signed-off-by: Robert Chiras Tested-by: Guido Günther --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 48 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/mxsfb/mxsfb_drv.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index f95ba63..d8686c7 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -158,6 +158,49 @@ static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = { .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, }; +enum drm_mode_status mxsfb_pipe_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) +{ + struct drm_simple_display_pipe *pipe = + container_of(crtc, struct drm_simple_display_pipe, crtc); + struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe); + u32 bpp; + u64 bw; + + if (!pipe->plane.state->fb) + bpp = 32; + else + bpp = pipe->plane.state->fb->format->depth; + + bw = mode->crtc_clock * 1000; + bw = bw * mode->hdisplay * mode->vdisplay * (bpp / 8); + bw = div_u64(bw, mode->htotal * mode->vtotal); + + if (mxsfb->max_bw && (bw > mxsfb->max_bw)) + return MODE_BAD; + + return MODE_OK; +} + +static int mxsfb_pipe_check(struct drm_simple_display_pipe *pipe, + struct drm_plane_state *plane_state, + struct drm_crtc_state *crtc_state) +{ + struct drm_framebuffer *fb = plane_state->fb; + struct drm_framebuffer *old_fb = pipe->plane.state->fb; + + /* force 'mode_changed' when fb pitches changed, since + * the pitch related registers configuration of LCDIF + * can not be done when LCDIF is running. + */ + if (old_fb && likely(!crtc_state->mode_changed)) { + if (old_fb->pitches[0] != fb->pitches[0]) + crtc_state->mode_changed = true; + } + + return 0; +} + static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) @@ -244,6 +287,8 @@ static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe *pipe) } static struct drm_simple_display_pipe_funcs mxsfb_funcs = { + .mode_valid = mxsfb_pipe_mode_valid, + .check = mxsfb_pipe_check, .enable = mxsfb_pipe_enable, .disable = mxsfb_pipe_disable, .update = mxsfb_pipe_update, @@ -283,6 +328,9 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) if (IS_ERR(mxsfb->clk_disp_axi)) mxsfb->clk_disp_axi = NULL; + of_property_read_u32(drm->dev->of_node, "max-memory-bandwidth", + &mxsfb->max_bw); + ret = dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)); if (ret) return ret; diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h index 8fb65d3..a178173 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h @@ -32,6 +32,8 @@ struct mxsfb_drm_private { struct drm_connector *connector; struct drm_panel *panel; struct drm_bridge *bridge; + + u32 max_bw; }; int mxsfb_setup_crtc(struct drm_device *dev); -- 2.7.4