From patchwork Fri Oct 5 09:26:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru-Cosmin Gheorghe X-Patchwork-Id: 10627701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CF1C1515 for ; Fri, 5 Oct 2018 09:27:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 330752923A for ; Fri, 5 Oct 2018 09:27:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 273512923F; Fri, 5 Oct 2018 09:27:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C17EE2923A for ; Fri, 5 Oct 2018 09:27:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 371E26E781; Fri, 5 Oct 2018 09:27:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on0628.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::628]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87DE46E77F for ; Fri, 5 Oct 2018 09:26:59 +0000 (UTC) Received: from DB6PR0802MB2551.eurprd08.prod.outlook.com (10.172.251.149) by DB6PR0802MB2197.eurprd08.prod.outlook.com (10.172.227.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.22; Fri, 5 Oct 2018 09:26:57 +0000 Received: from DB6PR0802MB2551.eurprd08.prod.outlook.com ([fe80::647d:f29a:a6d3:c8f2]) by DB6PR0802MB2551.eurprd08.prod.outlook.com ([fe80::647d:f29a:a6d3:c8f2%12]) with mapi id 15.20.1207.022; Fri, 5 Oct 2018 09:26:57 +0000 From: Alexandru-Cosmin Gheorghe To: "seanpaul@chromium.org" , "airlied@linux.ie" , "dri-devel@lists.freedesktop.org" , Liviu Dudau , Brian Starkey , "malidp@foss.arm.com" , "gustavo@padovan.org" , "maarten.lankhorst@linux.intel.com" , Ayan Halder , "daniel.vetter@ffwll.ch" , Raymond Smith , David Garbett , Lisa Wu , Matt Szczesiak , Charles Xu , "james qian wang (Arm Technology China)" Subject: [PATCH v3 4/6] drm: Extend framebuffer_check to handle formats with cpp/char_per_block 0 Thread-Topic: [PATCH v3 4/6] drm: Extend framebuffer_check to handle formats with cpp/char_per_block 0 Thread-Index: AQHUXI2PbUrNVDxH0kq6Q9NMVppeMA== Date: Fri, 5 Oct 2018 09:26:57 +0000 Message-ID: <20181005092606.21100-5-alexandru-cosmin.gheorghe@arm.com> References: <20181005092606.21100-1-alexandru-cosmin.gheorghe@arm.com> In-Reply-To: <20181005092606.21100-1-alexandru-cosmin.gheorghe@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1P195CA0039.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::28) To DB6PR0802MB2551.eurprd08.prod.outlook.com (2603:10a6:4:a1::21) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [217.140.106.51] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0802MB2197; 6:XOF9LlhsRQi9tLZDN4wMUDWYYUsaNhYuxeQEEHkRRvDQs0r6GjUh8YIYRNw+Rt1etnxFPmMr+Wm+mLr+l5WkCqgWM6tWHBKNY8BnD5hwlyWw1TYYeMfTT/0ODAHCvS9ygkBZB0e8f/o/jeZqmZtGM5liQchPyu7Kd2DhxYf2u2gV03aR4dRnQ8YsVdP2UafjvdaPVSL6gIUZ8JjtKl6kzGUCRJuXAkOR/jJ5vGPzTz2BqeK7Xz9EDqoelnMWTRx9u6sWQvygP7BsnucRJbuSi0ElZQvMjDeXhidKlKIv0LK0799n2a+YveQKpbDCiI5PfsDUzSyhWN73chxMCdjj93pL48HKazW9PUmP+xFn+UdpF5idt401GIrZcsQC+2Swpp+2Q0Tpw/T4tXfJZkyTZGBNDhLlO5bCVlKcz361H8bIad2KNdy9dxVvKSo2QmkSYkNmhdZemW+HoVidkZav6A==; 5:3xv9+4GwxHQaMIYRqzyJWv+UsFBk3d+Mozuz9tALfmCqNTheYVRXLS6pQYNGd4Kli9aIBBI5wcBzbpiPopBWIrkCJ0+z668RKNHWjYJKrpusmzd270EYjGnIxHWCMUsXvSfMGdR20KkREX2b4HpJfzVPAqSkBYCZwQcb0d9MTz0=; 7:2XQL6xEwj4qImnK+VxKbjwBlno6B11VikV7qMyNAXIe5YpJzgT9/3qmK11IgJ2VJbZsEOABTECjCVfYcijybnvt2ngMPSwzpH8OBxKxL90Pgqh3SvxF/VdS7m4do4zyyGolNjnjZAMbFVCrA/d6ONXJVNlp8gjPIP1dVJ2FSzM58dwbSIqlooIjfzr/1ZqnAm/2OVs0uobSGfa0FexFGhQTLTbla9fYUem197q1GzbmI7f0jA3x5fzFIo0iDH3vl x-ms-office365-filtering-correlation-id: d3ff7512-fdd6-41ea-4ba3-08d62aa4b1fd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0802MB2197; x-ms-traffictypediagnostic: DB6PR0802MB2197: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(201708071742011)(7699051); SRVR:DB6PR0802MB2197; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2197; x-forefront-prvs: 0816F1D86E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(346002)(396003)(39860400002)(376002)(189003)(199004)(72206003)(68736007)(8676002)(26005)(36756003)(14444005)(14454004)(256004)(186003)(11346002)(5024004)(71190400001)(486006)(71200400001)(5660300001)(2616005)(6636002)(2900100001)(105586002)(106356001)(446003)(66066001)(305945005)(6506007)(7736002)(102836004)(8936002)(52116002)(76176011)(81166006)(476003)(99286004)(386003)(110136005)(316002)(54906003)(2201001)(4326008)(5250100002)(6436002)(81156014)(6486002)(2906002)(25786009)(86362001)(1076002)(53936002)(2501003)(6116002)(3846002)(966005)(97736004)(478600001)(6306002)(6512007)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2197; H:DB6PR0802MB2551.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: bFPEdquAM/1VgUvCkwQhfxkKznE6Mm7i9MocV1N+LxWSCbdyaJuaF+knixB3m0IZdVzsED46l2ZXHfu8jAhrohTWj1C1TjqW9iEXToPlX2ZA3hIBk6rj1uVBQbI7IgKrectQlfXC3XnlMNQmJIcRPbjIbCmv60hfyL4GIRm40kAlRPGeSc0rvqEwW6LpISsCs6llMu0JbqlFFrg+2Q5Lo0nNHrR7+ZvjNhPW/CciMxxTKchXtKUkNSvN1Eb0EYy2Ly9fUGMwjFynThiVWMdAnzNf1+N65VG7SwshIkdY7eiFv9ALugmRWjzGuTtgwTBjJPtRGbAVJ+5VFZLlhhbHdgUD6YdVi5cpGyfVAif1RF4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3ff7512-fdd6-41ea-4ba3-08d62aa4b1fd X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Oct 2018 09:26:57.2277 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2197 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: nd , Alexandru-Cosmin Gheorghe Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP For formats that are supported only with non-linear modifiers it doesn't make to much sense to define cpp or char_per_block, so that will be set to 0. This patch adds a restriction to force having a modifier attached when cpp/char_per_block is 0, and to bypass checking the pitch restriction. This had been discussed here. [1] https://people.freedesktop.org/~cbrill/dri-log/?channel=dri-devel&highlight_names=&date=2018-09-13&show_html=true Signed-off-by: Alexandru Gheorghe Reviewed-by: Liviu Dudau --- drivers/gpu/drm/drm_framebuffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 4e14013788cd..66ec126b7faf 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -200,6 +200,10 @@ static int framebuffer_check(struct drm_device *dev, drm_format_info_block_width(info, i) * drm_format_info_block_height(info, i)); + if (!block_size && (r->modifier[i] == DRM_FORMAT_MOD_LINEAR)) { + DRM_DEBUG_KMS("Format requires non-linear modifier for plane %d\n", i); + return -EINVAL; + } if (!r->handles[i]) { DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i); return -EINVAL; @@ -211,7 +215,7 @@ static int framebuffer_check(struct drm_device *dev, if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX) return -ERANGE; - if (r->pitches[i] < min_pitch) { + if (block_size && r->pitches[i] < min_pitch) { DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i); return -EINVAL; }