From patchwork Thu Nov 1 15:11:31 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: 10664091 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 F3543157A for ; Thu, 1 Nov 2018 15:11:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E34332BF83 for ; Thu, 1 Nov 2018 15:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6EBE2C02E; Thu, 1 Nov 2018 15:11:45 +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 75FD72C03C for ; Thu, 1 Nov 2018 15:11:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 404B06E3AF; Thu, 1 Nov 2018 15:11:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30080.outbound.protection.outlook.com [40.107.3.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 970CE6E392 for ; Thu, 1 Nov 2018 15:11:34 +0000 (UTC) Received: from DB6PR0802MB2551.eurprd08.prod.outlook.com (10.172.251.149) by DB6PR0802MB2246.eurprd08.prod.outlook.com (10.172.227.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.25; Thu, 1 Nov 2018 15:11:31 +0000 Received: from DB6PR0802MB2551.eurprd08.prod.outlook.com ([fe80::19ca:93bb:bc0:985a]) by DB6PR0802MB2551.eurprd08.prod.outlook.com ([fe80::19ca:93bb:bc0:985a%7]) with mapi id 15.20.1273.027; Thu, 1 Nov 2018 15:11:31 +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" , "maxime.ripard@bootlin.com" , "maarten.lankhorst@linux.intel.com" , Ayan Halder , "daniel.vetter@ffwll.ch" , "james qian wang (Arm Technology China)" Subject: [RESEND v7 4/7] drm: Extend framebuffer_check to handle formats with cpp/char_per_block 0 Thread-Topic: [RESEND v7 4/7] drm: Extend framebuffer_check to handle formats with cpp/char_per_block 0 Thread-Index: AQHUcfUr8T4hS6Q7kEKSCwfi4KyA7A== Date: Thu, 1 Nov 2018 15:11:31 +0000 Message-ID: <20181101151051.1509-5-alexandru-cosmin.gheorghe@arm.com> References: <20181101151051.1509-1-alexandru-cosmin.gheorghe@arm.com> In-Reply-To: <20181101151051.1509-1-alexandru-cosmin.gheorghe@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0001.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::13) 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; DB6PR0802MB2246; 6:G2dCr1AA7s5DOYhfYTC5pBk+t5Z2Qk4wsFp/2lk1dpWGo0Y5sIzKGB0L+9vlGB/TLwE00kJgG1igz+bQlksgnxHty22pSwPNkjep3nLBEs4OMIKQFelk8u2CztJfa6plhNTdfsDsPG7nwFVcKB3SLCa34LrAuwOiFAJwyqTTY3jsJSs6+lBfoE1Dsnhcd2/B9UykPJ+FZfJHF24+x74svgJF6fTQM7yxTC220OTH39wrR9UHsq2nNN8J5vufiRrr9EvVbYIo8ujxC1cnoKI21ZE5gGYLL/8yANg1xh5BDRsD4DN8i+8FN/uLaZayWHENmEugXnFTELBHJhBf78vWBZuv/R4Kw8gR5XpH8v+isgzNzRhz+bEmADrQFAFs/6hiifq0wrab/WeM28AtBGRXnAq29z4+uK1UasCYHqbcWtZlke/bjhvB/BDipnuTUAOrJg8zFmKY3r1ckSqDBznBsw==; 5:eN+e5Cc+dUA06uydDBHivrtxZZFhCTcyaGiurupIMnw/AnW4jrNHfNPmifbN1eVi6a1kX70x80sua7mPFiblz+4lfzSkhpZc7lAuH0F+KK9NOKwRaatR69NuBXY4ZwDwtz7UM8DU9lsJQOJmV6RhpQs1tKpmXgQDc0PavQ7d5SM=; 7:tBxPJy5z9UC4FCWNeAwK6joq6RzqqwwpG493sFlp6IutL437NmMy2md6VJjylxnYiuMApf5jeddR+tkqNWOONEE2Cns35hWEq6VqfQEWPjgs5zW1sb3V137YdB+d0Z4UbPDw5wPiDdOKFfs77axlqw== x-ms-office365-filtering-correlation-id: 981386ab-c94d-4084-f377-08d6400c4e1a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB6PR0802MB2246; x-ms-traffictypediagnostic: DB6PR0802MB2246: 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)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231382)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:DB6PR0802MB2246; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2246; x-forefront-prvs: 0843C17679 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(366004)(376002)(346002)(396003)(136003)(39860400002)(189003)(199004)(66066001)(68736007)(486006)(106356001)(6486002)(6306002)(53936002)(105586002)(97736004)(6436002)(5250100002)(25786009)(8936002)(6512007)(36756003)(4326008)(2501003)(81156014)(478600001)(6116002)(316002)(6506007)(386003)(76176011)(3846002)(6636002)(1076002)(110136005)(102836004)(86362001)(71190400001)(2201001)(71200400001)(72206003)(5660300001)(966005)(8676002)(81166006)(14454004)(186003)(14444005)(5024004)(11346002)(256004)(2616005)(2900100001)(476003)(446003)(52116002)(54906003)(2906002)(99286004)(305945005)(26005)(7736002)(921003)(1121003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2246; 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: 7KC+qGHdQmZa+bUaWcsx1pO0PtiSLNXWpdG/gqxcQa6mXM9cIw5VTwvBQWlGcoaHC4dT2KGuD3ZFROupBuct0SFL7k787ITT3DHD9Q831KT0sbyoRCXzBMUYnqquXuEqBeN9dXsnfmWoqNmH3Lx6epXwmREd0gOcKghPZlgkee2YBCwzGih5YXHZl4CqB7KUR5YZGpb+fc2lEtntDJRaHk7cUD7CQG2sZwEHogU1qgAQ0ScCgypb+RmfcJ5JNV9Z6s+MVflBa6iKyPVGz6IvtF+Ps6C4mPUB2Rpdqj3sLJl0aegCMPFKpHS3RLs4cC7F5QinNjtqmM048NYr5K0q+LW62cJLZD+qkQP0JN2Nfh8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 981386ab-c94d-4084-f377-08d6400c4e1a X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2018 15:11:31.7010 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2246 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 Reviewed-by: Brian Starkey Signed-off-by: Alexandru Gheorghe Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_framebuffer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 6aca8a1ccdb6..167c1c4544af 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -195,8 +195,14 @@ static int framebuffer_check(struct drm_device *dev, for (i = 0; i < info->num_planes; i++) { unsigned int width = fb_plane_width(r->width, info, i); unsigned int height = fb_plane_height(r->height, info, i); + unsigned int block_size = info->char_per_block[i]; u64 min_pitch = drm_format_info_min_pitch(info, i, width); + 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; @@ -208,7 +214,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; }