Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3756779pxk; Tue, 8 Sep 2020 01:22:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQQB1TL9Yc0WOVue2lGLkUDTNSpKnQHzHTzpHgokkZYGt7CIJxhSaQJHyBRucrge7KVXPp X-Received: by 2002:a50:8d4b:: with SMTP id t11mr26442695edt.5.1599553334356; Tue, 08 Sep 2020 01:22:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599553334; cv=none; d=google.com; s=arc-20160816; b=PWAJQOyoqIvPdr65MRv96VEUHcNTmYTcDNC4axmEo6+I9S5vO0oVYhnaiuTc0EoEce y06lXnFG63O7NxOT6UnbRGjXvNYNNxympZlNNpOFGcqDBt7FtvgH/lm0HDABNZMg6MFx hGrrftjSDVaCG4bU62yYuFrlSoec89/kEpUUc7tx38Y2lBBEIoWoHqIMYQAnlAFHnAci y+JbCxwviqo0hYHbAlE8GDDSsFsrefGDsKOhKpcMCsyuMLIVmFFHwBJBSTCfOk5PcyMM Ft5f5937qsqSGdrVWiSKZvBhbqObxv3CKU/j6lWmhmApaMXU+MzufLD9tO8Aa1K0Talu qIBQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=4eo8hs8HzetIEb9ibaaRaZuLk1d4NQhqq0X0s00zao4=; b=f5ZyKTcyIhDrCI+ct2XpDsFf+xwEW3P83O+RtVSzROvgJfJpDOsCY01oT3w6T/8cjk OmN/6wxUesKotBoSkqJ3lT+HNUxEAa5I7zvT0ZsIECXs8ZPzO0AAZS22njpOswI08trx +wOrpRuy1DK2Q37FTgHapvbYVvabDr05Vi7baChXEjv0NlyGnU6FBKckZ1cQPgy1zXOd G4I36Yx9wRSpNOpR14j8fMB1iopTZA00/jX07RmgltM/KOSGsFDfR2qQqCpX++WH2MZU c6pjtq6XjI95vfxZp22HCRPt1wdUKp2fn82Tf6YCuUIkMub+zTLEOhVPxGNpCPF8q4Dv L80w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MKLCvQoo; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm19si10463251ejb.332.2020.09.08.01.21.52; Tue, 08 Sep 2020 01:22:14 -0700 (PDT) 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=@ti.com header.s=ti-com-17Q1 header.b=MKLCvQoo; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729921AbgIHITE (ORCPT + 99 others); Tue, 8 Sep 2020 04:19:04 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:49162 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729554AbgIHITC (ORCPT ); Tue, 8 Sep 2020 04:19:02 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0888ITMI075895; Tue, 8 Sep 2020 03:18:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1599553109; bh=4eo8hs8HzetIEb9ibaaRaZuLk1d4NQhqq0X0s00zao4=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=MKLCvQooUkJ1q9w460K7G/4x+lYIEwCtwqnkxihR5/16AjtXRZkcUYAduUV/FBbsU 2eMDFi3HgH0Dt2wMUQccqQSW7nqAarGYzYRo3KKDRc9aLyoL19zruegCnpm7jsR+/g HCmFxnHuuEyM7H5I42Ah/XZkvJgVOycZyE9/qESE= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0888ITxQ048580 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Sep 2020 03:18:29 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 8 Sep 2020 03:18:29 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Tue, 8 Sep 2020 03:18:29 -0500 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0888IPRk107862; Tue, 8 Sep 2020 03:18:26 -0500 Subject: Re: [PATCH] drm: mxsfb: check framebuffer pitch To: Stefan Agner , Laurent Pinchart , CC: , , , , , , , , , , References: <20200907160343.124405-1-stefan@agner.ch> <20200907161712.GF6047@pendragon.ideasonboard.com> <20200907181855.GE2352366@phenom.ffwll.local> <86615b4b1551d4a6f1cfcc13b38e616c@agner.ch> From: Tomi Valkeinen Message-ID: Date: Tue, 8 Sep 2020 11:18:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <86615b4b1551d4a6f1cfcc13b38e616c@agner.ch> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 08/09/2020 10:55, Stefan Agner wrote: > On 2020-09-07 20:18, Daniel Vetter wrote: >> 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 >> > > Sounds sensible. From what I can tell fb_create is the proper callback > to implement this at addfb time. Will give this a try. > > FWIW, I got the idea from drivers/gpu/drm/tilcdc/tilcdc_plane.c. Maybe > should be moved to addfb there too? But you don't know the crtc width when creating the framebuffer. Tomi -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki