From patchwork Tue Apr 23 16:09:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Coster X-Patchwork-Id: 13640304 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1FA83C4345F for ; Tue, 23 Apr 2024 16:10:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 309EE11347C; Tue, 23 Apr 2024 16:10:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=imgtec.com header.i=@imgtec.com header.b="EDVSKn9Z"; dkim=pass (1024-bit key; unprotected) header.d=IMGTecCRM.onmicrosoft.com header.i=@IMGTecCRM.onmicrosoft.com header.b="VRYrGmcz"; dkim-atps=neutral Received: from mx08-00376f01.pphosted.com (mx08-00376f01.pphosted.com [91.207.212.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD1F811347C for ; Tue, 23 Apr 2024 16:10:11 +0000 (UTC) Received: from pps.filterd (m0168888.ppops.net [127.0.0.1]) by mx08-00376f01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43NE6DHA004668; Tue, 23 Apr 2024 17:09:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h= from:to:cc:subject:date:message-id:content-type:mime-version; s= dk201812; bh=4J3718iqHmUqRJ30WshlhjiS880Y34b0ConiL9B6o84=; b=EDV SKn9Zr+FwViT6DC0iOmaju5rxkNqCbKVLwfcRfWlLvZvVWeFp8c4xhutDDVUSPL7 +i5HVjn8tkUDqgeisDzLENNmzVjXAMBuMjXG77A9swn70PqDxNSxqhLmO4OIB6Ev hXFjywCsTCgo714cRUXuk9TNC4Ag+uqmRn7ai7ZkEwQDCAGwacPmouVvfA8mtHXy M8Ahlsb5gmpYUrZ1yTQxKVsBZMHz3QQm5JH/kdG8yjgJKNwVwfY9SdLtKDdeyKpC tuKuqwnV3H7aB+fC4wUjOUxwnhT+nusfhaHxm93S0BMlilpMSUn+pSnHm3/jfCFA aK0mcNnF79yYln7ElMQ== Received: from hhmail04.hh.imgtec.org ([217.156.249.195]) by mx08-00376f01.pphosted.com (PPS) with ESMTPS id 3xm3ynkmy2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 23 Apr 2024 17:09:45 +0100 (BST) Received: from HHMAIL04.hh.imgtec.org (10.100.10.119) by HHMAIL04.hh.imgtec.org (10.100.10.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Tue, 23 Apr 2024 17:09:44 +0100 Received: from LO2P265CU024.outbound.protection.outlook.com (40.93.67.0) by email.imgtec.com (10.100.10.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37 via Frontend Transport; Tue, 23 Apr 2024 17:09:44 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EXkaM3em+jnlnxkvrDIw5NeFYplcF9Zr8HHCpEczNaArp1+CX+sODKRLXSnbq87DDKGDzhAM0gjw8lZZHrFEFXbhkEkCw18AQffqNP9MB/tlgdPm2QOPCQBrQZZgXzC4zjKX3IwY1+DPbLTwW3F4HKGREkqxCFw4nZCOAmFzGkBhqBEABKSC9vWW7G3ExwFjDAjI73/5s9pfK2s7Jhd6kntDyPANNiw3fU6u1KnIQC/fhBNldJd8k0XHBx1oawDwR3mBNdZywA3rinwMQPtvvgRB3eFyglL2qSheZFCFKskm2my3H+BSFFsVV/3u4oLqzoHAXQrYlT9WGvpbF6ZoLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4J3718iqHmUqRJ30WshlhjiS880Y34b0ConiL9B6o84=; b=VHEE2IwQp5ObCfQgSAReCtj/wRrGH4XjD4YZ6K0YCKvHXtvLb10hXWt6fIsjC8RN9UJdd5KHjyuzxdbd/1uUzwsgwxJX0Ga2jTgxr6BUKzS7J5fw41Brsnx/AjEYL2iPtI0J/sar2W3L1luYUc0gHia4HOwp5pAYif8snc0Imq6c3vKyuZILOF5ONQCT6kD72ffy5NL4LXnnp/ufiPbJJAiRVgIYCvxhB9FL3VdlZBadK5yUa2W9YhILjkiN+g5cO25X3alTuN+Ziykz9ourOzy4ptg5zoDIpn1/TN51f6u7U+js+qczDjMKGnEvwTphPMrPemePHzTebshuIv7xfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=imgtec.com; dmarc=pass action=none header.from=imgtec.com; dkim=pass header.d=imgtec.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=IMGTecCRM.onmicrosoft.com; s=selector2-IMGTecCRM-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4J3718iqHmUqRJ30WshlhjiS880Y34b0ConiL9B6o84=; b=VRYrGmczYn3SBpk0g09WRWQJOOq/l/G5Iis896A+Jp3a2tBVfCQWMfK/00Xpc9dEicIk6SCcrXebibYEDrHIkL0mV2FB0ibdgjll/azvoHRdQeI7y5ZH34gfqbAygLPgTtMfhc3EDKSW8C39EL0RFYUY9q8CQ0YKXKKYGPy9FtM= Received: from CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:e7::8) by LO7P265MB7763.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:413::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 16:09:42 +0000 Received: from CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM ([fe80::8e9d:6b2f:9881:1e15]) by CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM ([fe80::8e9d:6b2f:9881:1e15%6]) with mapi id 15.20.7472.044; Tue, 23 Apr 2024 16:09:40 +0000 From: Matt Coster To: "dri-devel@lists.freedesktop.org" CC: Frank Binns , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH] drm/imagination: Ensure PVR_MIPS_PT_PAGE_COUNT is never zero Thread-Topic: [PATCH] drm/imagination: Ensure PVR_MIPS_PT_PAGE_COUNT is never zero Thread-Index: AQHalZilaE7HTvidvkqz+oS3jgfrlg== Date: Tue, 23 Apr 2024 16:09:40 +0000 Message-ID: <489aa9ab-3de1-4bfb-aaae-b093536d16ce@imgtec.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CWXP265MB3397:EE_|LO7P265MB7763:EE_ x-ms-office365-filtering-correlation-id: 8b5774a2-9685-4059-4cc1-08dc63afc7f2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: =?utf-8?q?oTKFJlhLFzHiIjoJImAd0p4ZTnEGQuC?= =?utf-8?q?R06bJbC41gl62vBf7XdMHXvsvNFEpA8hxExxU9Zn7sWR9Rie8dAFA652Z3LHuXf5T?= =?utf-8?q?wC4zRgscbQsaOLeV/4ARTEU8yS1rVKi4gb0s5ZuubN2oWCYA2gXMxsEqMovpU6xgy?= =?utf-8?q?6yBbcbbm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4DOR4galj04PmhpQy0ZPMeeAT9TPCTv94IXeaHfAxpMvLTHKOswNrym?= =?utf-8?q?e41bDPfRA5RNORU2pjSHeiUxMhHf6MYtVyCLcQQo6Ie3vgRJOzK0/XfTsmdcKTjuO?= =?utf-8?q?Tqtm1NW/oK22aIXRE1SpSotRHs1z2r0X0F1dUhzYkohLtEU8H9u7jHkHzFlP/7NQR?= =?utf-8?q?tZnwHKCCuqvx64vu33lATaI44M8tkYKPrgTIxPoLNf9FiBmz+f9IZFllYaLLlprkZ?= =?utf-8?q?zD/+60m+BHiFHJrTBt/ZUzZQJKMZ0EsH5PA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(376005)(366007)(1800799015)(38070700009); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?GSrp7wkmfodJU+fZo/aPI5DJZhVd?= =?utf-8?q?Ttu1kEyiJZ7XirgH+FmJj84ep6jzxGAvGz4ZpVRcxalHOdhiRAEXoyaIi7RMWcqqh?= =?utf-8?q?PBeRQrybXT3we/awEb1tkPqgdBJJE4Z/bsk+8V1OX06uN7yFHKbapm/QwU/irkpPY?= =?utf-8?q?mCkSq9Eql5weeqVjkESTA+8RByOBTqAti50XwcVTLypi50EgPgB2ZGEkcyE3xTW1n?= =?utf-8?q?6lU2YjM8ozUSsYcyUJ1eRJYe0RNT2cW/iPuf6n0igGlfnAqscJyOY6Ff5hiyhmaNx?= =?utf-8?q?k2sKuMhiBzIXaf0FSTaTgDjY2OEs3GuXIl5XHzIPF4VjTYsKzivwJvSizZUkBBAng?= =?utf-8?q?WSAkLOk+t+mqyOtrTtW+Sx4CbAWImxJlHX+wl6wgFg1Ri02WFyYtSw/yCKOGyTH9b?= =?utf-8?q?tAkOHha6/s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zRJKFu2wNIwzl0MrS42B+m0ya9PAfG/6karhPdG7mkvGRZ6x3lpEWuCoUHuX?= =?utf-8?q?TnCw632LsdHR97lxAfnbr/ui9G6JJGScFl+/MYu7NjkqIiyvKt8iHI6oYBVl8xfPt?= =?utf-8?q?i5Dx8o0HBUWbVJt3+Kkgw2FNYHQ1sSD104FkFD/OSgQexCGWnUucMCeojGlUzSFGs?= =?utf-8?q?sA3AEONz8jtpz+G3KO5b3Ojg3n2ovLi9IfTYX9/AyWIx11klPaUwV1b2R+ro0yokj?= =?utf-8?q?GgCnSZchHeyrvpR9Z1b6dkJ4tFty0O3Cjw=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 8b5774a2-9685-4059-4cc1-08dc63afc7f2 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Apr 2024 16:09:40.4216 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0d5fd8bb-e8c2-4e0a-8dd5-2c264f7140fe X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: g+xJniw2dtE2t6Um5XXVwZsS/8mrbjPgCP3ADmaafmob3b1PMreFimD8bgOAM2urGTswppNws/uxOkAdaiuWmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO7P265MB7763 X-OriginatorOrg: imgtec.com X-EXCLAIMER-MD-CONFIG: 15a78312-3e47-46eb-9010-2e54d84a9631 X-Proofpoint-ORIG-GUID: maMLkjh2kXjMdu3vORVVTkqNisJ4tLbF X-Proofpoint-GUID: maMLkjh2kXjMdu3vORVVTkqNisJ4tLbF 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When the host page size was more than 4 times larger than the FW page size, this macro evaluated to zero resulting in zero-sized arrays. Use DIV_ROUND_UP() to ensure the correct behavior. Reported-by: 20240228012313.5934-1-yaolu@kylinos.cn Closes: https://lore.kernel.org/dri-devel/20240228012313.5934-1-yaolu@kylinos.cn Fixes: 927f3e0253c1 ("drm/imagination: Implement MIPS firmware processor and MMU support") Signed-off-by: Matt Coster Reviewed-by: Frank Binns --- drivers/gpu/drm/imagination/pvr_fw_mips.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) base-commit: e95752752eaf06c860811ac5ddf9badf6c1b43ca diff --git a/drivers/gpu/drm/imagination/pvr_fw_mips.h b/drivers/gpu/drm/imagination/pvr_fw_mips.h index 408dbe63a90c..a0c5c41c8aa2 100644 --- a/drivers/gpu/drm/imagination/pvr_fw_mips.h +++ b/drivers/gpu/drm/imagination/pvr_fw_mips.h @@ -7,13 +7,14 @@ #include "pvr_rogue_mips.h" #include +#include #include /* Forward declaration from pvr_gem.h. */ struct pvr_gem_object; -#define PVR_MIPS_PT_PAGE_COUNT ((ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K) \ - >> PAGE_SHIFT) +#define PVR_MIPS_PT_PAGE_COUNT DIV_ROUND_UP(ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K, PAGE_SIZE) + /** * struct pvr_fw_mips_data - MIPS-specific data */