Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2684BC43461 for ; Mon, 7 Sep 2020 18:19:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E72220732 for ; Mon, 7 Sep 2020 18:19:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="hZpY+ABA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E72220732 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B96C6E520; Mon, 7 Sep 2020 18:19:00 +0000 (UTC) Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 12EA16E520 for ; Mon, 7 Sep 2020 18:18:59 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id w2so15123436wmi.1 for ; Mon, 07 Sep 2020 11:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=nmGHPNrS/6S0SVPN+UDSLWRiyfZpZ44FO0zwUXQGhPk=; b=hZpY+ABAxUzZiiEnMcGY2zsoByRD7Qyn3GVNt7pMeFqg40sUBrUExQ3IX3NAtZYDed vpuuoHVdh32ifvExwzoruB17FLiBxcLLWvh6JivS+6V7GpKxu17XBwxDmiAFVWBo3oke VeYhIhUZA5q3aMC5BRIP+qKUUioViLMCnNc3U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=nmGHPNrS/6S0SVPN+UDSLWRiyfZpZ44FO0zwUXQGhPk=; b=qTrUetCI2VqFhyniprezUyOCqjR0/s00Pkip3GgJrtdVch/ZSJ37b2MflvG0LdlruP dHqsRhlptOOLjZfOXqXMjcii50joPKLr10pn11pwy8/9wMdUUq0pLw2olzaatbvVcZ8A FAwue2faWn03T5148j6idvYh3khEN6hgHpJACW4qHBmep5E/a/+fmLXWTUnFrbAfpay6 BixeGY6daV8N2W5iPzBla+JSI4DaoRgXyKEpFKWbTZHcSZ6gYlfSdz7gLROU3LWUw9xC cE0b1A6htrrrj1W0t3+GWygwHNS0YJPABiwDCUVbOJapSaGfp79wsECLBejR0yVQm3on k/Ig== X-Gm-Message-State: AOAM530hXTKMkbDLt6ihuz+01RpFDv2LmeOwUnCPgeOOQW2ps6T/n20x KlXKrO2wzdNgJAF4H6w9e5obwA== X-Google-Smtp-Source: ABdhPJx/Jk99iRJFxTsv1nNiWHcEwaGPbYeF2e2q7j3F1PqjKZLVLTc9yfm/TiCX2Ye++izPL+H2oQ== X-Received: by 2002:a1c:6187:: with SMTP id v129mr528032wmb.35.1599502737762; Mon, 07 Sep 2020 11:18:57 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id v6sm29503897wrt.90.2020.09.07.11.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2020 11:18:56 -0700 (PDT) Date: Mon, 7 Sep 2020 20:18:55 +0200 From: Daniel Vetter To: Laurent Pinchart Subject: Re: [PATCH] drm: mxsfb: check framebuffer pitch Message-ID: <20200907181855.GE2352366@phenom.ffwll.local> Mail-Followup-To: Laurent Pinchart , Stefan Agner , marex@denx.de, airlied@linux.ie, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20200907160343.124405-1-stefan@agner.ch> <20200907161712.GF6047@pendragon.ideasonboard.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200907161712.GF6047@pendragon.ideasonboard.com> X-Operating-System: Linux phenom 5.7.0-1-amd64 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marex@denx.de, kernel@pengutronix.de, dri-devel@lists.freedesktop.org, airlied@linux.ie, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, linux-imx@nxp.com, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Sep 07, 2020 at 07:17:12PM +0300, Laurent Pinchart wrote: > Hi Stefan, > > Thank you for the patch. > > On Mon, Sep 07, 2020 at 06:03:43PM +0200, Stefan Agner wrote: > > The lcdif IP does not support a framebuffer pitch (stride) other than > > the CRTC width. Check for equality and reject the state otherwise. > > > > This prevents a distorted picture when using 640x800 and running the > > Mesa graphics stack. Mesa tires to use a cache aligned stride, which > > s/tires/tries/ > > > leads at that particular resolution to width != stride. Currently > > Mesa has no fallback behavior, but rejecting this configuration allows > > userspace to handle the issue correctly. > > I'm increasingly impressed by how featureful this IP core is :-) > > > Signed-off-by: Stefan Agner > > --- > > drivers/gpu/drm/mxsfb/mxsfb_kms.c | 22 ++++++++++++++++++---- > > 1 file changed, 18 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c > > index b721b8b262ce..79aa14027f91 100644 > > --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c > > +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c > > @@ -403,14 +403,28 @@ static int mxsfb_plane_atomic_check(struct drm_plane *plane, > > { > > struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(plane->dev); > > struct drm_crtc_state *crtc_state; > > + unsigned int pitch; > > + int ret; > > > > crtc_state = drm_atomic_get_new_crtc_state(plane_state->state, > > &mxsfb->crtc); > > > > - return drm_atomic_helper_check_plane_state(plane_state, crtc_state, > > - DRM_PLANE_HELPER_NO_SCALING, > > - DRM_PLANE_HELPER_NO_SCALING, > > - false, true); > > + ret = drm_atomic_helper_check_plane_state(plane_state, crtc_state, > > + DRM_PLANE_HELPER_NO_SCALING, > > + DRM_PLANE_HELPER_NO_SCALING, > > + false, true); > > + if (ret || !plane_state->visible) > > Would it be more explict to check for !plane_state->fb ? Otherwise I'll > have to verify that !fb always implies !visible :-) > > > + return ret; > > + > > + pitch = crtc_state->mode.hdisplay * > > + plane_state->fb->format->cpp[0]; > > This holds on a single line. > > > + if (plane_state->fb->pitches[0] != pitch) { > > + dev_err(plane->dev->dev, > > + "Invalid pitch: fb and crtc widths must be the same"); > > I'd turn this into a dev_dbg(), printing error messages to the kernel > log in response to user-triggered conditions is a bit too verbose and > could flood the log. > > Wouldn't it be best to catch this issue when creating the framebuffer ? Yeah this should be verified at addfb time. We try to validate as early as possible. -Daniel > > > + return -EINVAL; > > + } > > + > > + return 0; > > } > > > > static void mxsfb_plane_primary_atomic_update(struct drm_plane *plane, > > -- > Regards, > > Laurent Pinchart -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel