From patchwork Mon Jan 23 13:46:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 9533405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 185E66020B for ; Mon, 23 Jan 2017 20:13:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 057552839C for ; Mon, 23 Jan 2017 20:13:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE692283EB; Mon, 23 Jan 2017 20:13:29 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 5A67C283E1 for ; Mon, 23 Jan 2017 20:13:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3363E6E5FA; Mon, 23 Jan 2017 20:13:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 21270 seconds by postgrey-1.35 at gabe; Mon, 23 Jan 2017 20:13:25 UTC Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0068.outbound.protection.outlook.com [104.47.2.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id EBCA86E5FA for ; Mon, 23 Jan 2017 20:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=OThj7kzHBiu4DLQwFRKZaPmVvxiVGXPRWdnq0RGTJ6k=; b=HqCtglZ8LSngqoExweJ0Ki4P9jRVpm8kagkzBaskbimUy+F6tbTrds6eGbhpGkZH3exqZDZTWCh4mN6coNAdx32Rk59UNrY5XOqEQ4Zy6pTVgC3frUk2yPEM+sRf0BkB3fmGFeNUb6CxwWtz3AKjgDTFlOytukpB1hR1xJdVD68= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; Received: from e110433-lin.cambridge.arm.com (217.140.96.140) by AM4PR08MB0881.eurprd08.prod.outlook.com (10.164.83.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Mon, 23 Jan 2017 13:46:47 +0000 From: Mihail Atanassov To: DRI devel Subject: [PATCH 2/2] drm: mali-dp: Check for sufficient address space Date: Mon, 23 Jan 2017 13:46:42 +0000 Message-ID: <1485179202-16118-2-git-send-email-mihail.atanassov@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485179202-16118-1-git-send-email-mihail.atanassov@arm.com> References: <1485179202-16118-1-git-send-email-mihail.atanassov@arm.com> MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: HE1PR0701CA0044.eurprd07.prod.outlook.com (10.168.191.12) To AM4PR08MB0881.eurprd08.prod.outlook.com (10.164.83.27) X-MS-Office365-Filtering-Correlation-Id: c7e46b7b-1ed0-428f-0593-08d443964710 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM4PR08MB0881; X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0881; 3:feC1jV66r6bLTmJ+7um3lrhxXtJ1Bp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AoJ0x9q0lebsBO+yamFouWY6ZIlpT4o9/b6Cg7hNN2Eo79RjUeOgJtLnKJdW7O5MTtxZJHRvQ02O8w4Kk6l1YDo5hElwaH8AifFIDXNh644Jlx6K3Eb/JUiYbIGUbmpk= NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123558021)(20161123555025)(20161123562025)(20161123564025)(6072148); SRVR:AM4PR08MB0881; BCL:0; PCL:0; RULEID:; SRVR:AM4PR08MB0881; X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0881; 4:xOYaZ0Hi9pKauHb5OT0AdgcDd7Rr8fu7hXg5Ie8eX+Jc85ZHBVCYrw5/m8UDYFzqbTS8oPRaAE+YaVt/jLZhOViJN6lG4wBTC7kizcohDzMC02ds/vq/SqW39Ro4xZ6IjLvRic+qTstuKzB2pgrzQ2IgbEmjmOFICZFsZyi0/PBajAGN6LHkL6uG5kxWKR/193gRICw46Tsx/31j9qWZX4KZKqlRJyYzRhXaUgXrM4s6WtShh4jc7BvqkBouVARNDgFaFZxIoNJfkz+IawPr5avmXotTF8os9Ec8o+1BA9TLeFv3jzUc2uP9j8/P9FBUoLI0lq0exCe1m2SgIAp0yGM1DEMv/JWzS5zzvh3ZZ9L82+be4DAEGcytx3cR2IS3c/keCBYsY8hOp+z3T1f0XtfKEPDN9/KAoZPsUguPsc+x2MFL7iKBoh1pwdwhJ9lvvGHSaeMWLF6J+eFf8249J9YpQUsALksXo0kSRmG+tbUIhkjh26W+oql/rDigaj1xoQ0eRTX6wwzOSRc+6v3f2QtMzWNVlUntIl2OTWd14rltKfZWaqCeoy1R/0WMEak/7DDyakGEJDAlL6sdYJKBENx+lNrdLxiwRSldQNrgHeZssvuMoI9VdZQWOj3ISeGc0C/0aEvoJalSG2hRAW+ETxBCZULO+6Q6hGVzMCblYuw= X-Forefront-PRVS: 0196A226D1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39850400002)(39860400002)(39840400002)(199003)(189002)(54906002)(92566002)(81156014)(4326007)(50226002)(25786008)(5003940100001)(8676002)(81166006)(33646002)(3846002)(6116002)(106356001)(50466002)(110136003)(305945005)(7736002)(66066001)(189998001)(105586002)(48376002)(76176999)(42186005)(36756003)(50986999)(68736007)(2950100002)(47776003)(6666003)(101416001)(53936002)(5660300001)(6486002)(6916009)(86362001)(38730400001)(2906002)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR08MB0881; H:e110433-lin.cambridge.arm.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR08MB0881; 23:ZIdQU566XIO2oeAThIQwYiH71NypRHxmfLXtiAW/N?= =?us-ascii?Q?fqakhARplSo674t56EdkL5+fVpJ7v1qkFYF32n7YD/KO9Cpdh5+swozNNUkt?= =?us-ascii?Q?DnCaGyD8hGXc01LZPFbyblfnlm0heEmNdBKQlCTO/0274fCicwySab4f+iDE?= =?us-ascii?Q?B0fg4relR80dbnY/WNWTAHtchkPbXmcXOxmJnt0BYK57J9Y+bxSZu/lws/MW?= =?us-ascii?Q?6LrPaEYVcoDXwJC194EcZYK2mvAfaq7jobVcbV9fHE7/QIGOP3qFQnWr26tY?= =?us-ascii?Q?5Bww7nqZ+sJ0Jp1LpyY35x/tyMgIh3gRVRTDqgW9NnLchz7WP7dxGMRrs4dj?= =?us-ascii?Q?NARu7Abb46cj9tYlrj3Qk4bHGP3Tt0PQAcT2ykkMhyOeW++FroBvKW+XWrUT?= =?us-ascii?Q?Z63t9Ttuwo7MW+tHXqEIBvnTw69mNczflaCvfHmTNqvmB8EScoSXNXx6uznU?= =?us-ascii?Q?Yfje0cw/60KO3toVXHqNioinS4+JklF+Hs1+lol4+AJ0yfQlrwhxpptcwvON?= =?us-ascii?Q?19n4yOW9IEXhvkoUk8oyeE3Myz6Jpgfehv0gTREt1Wq0Fsw8s4/8z1Gt/NFV?= =?us-ascii?Q?s+7yqngm2OakUG9vOos8jj6JRY6Mry2N/I0qMnf7uFKO69HO6jEnCUE8bIqO?= =?us-ascii?Q?7E1cU3+ihwRjXqK3W4aCEAo9/GdMopYdqjgaTIHejpWtWCcoFuAlqVIdEYBy?= =?us-ascii?Q?CmuWl65t1Ijt12uviCvNuUMG+3GidUmcq3LMoNKRNVxyDdsP1TYfvUqeG1lO?= =?us-ascii?Q?XGBAMdvQqnZyKScFl1bRGziRGh6wMankkEc1oKOU4STTwW04PZjBAHdnGAEr?= =?us-ascii?Q?NOm+Z8Qj71xxhczpqgBsbOPQlz2Y0z09f0erzKzwCi/1y7aC7HDXBN+XZgDh?= =?us-ascii?Q?1s96o1QfxeRzPwqk73MAqX5v7tLsVr+M1jWyH3bU9BWzAVcfUxN9XZ9MaO0l?= =?us-ascii?Q?MQx9Fg8rXItm3oEBA4V6O8nl84j2a82AoydpfKWYxCeTwrU9I8X+bb0IWmH/?= =?us-ascii?Q?jj6996bz255LtRPgeC5PRZFb1vbLwib56nZf0mjltkmpjnmy2l6jihLdrAlB?= =?us-ascii?Q?YWoFZWaaAt3I+QL1mHJ58XM4E3X/WHv/41gYGj0fDL8tnnkJQ8/GIjct4IhB?= =?us-ascii?Q?joMYPlHyHu/fZElIWwwnweldI2HQ/owLKi3jRuVOdP6N6fuh7QNcv7KKwRif?= =?us-ascii?Q?3lw6s0+z2Fq7xE=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0881; 6:caug5j85pXLyvVA8A/6Jxy6G2ev3X1JckrgbhsXXujvg0RBkp5J9tvjwec9AQRFVnRNVGnTx8TJlSYWA340S3H2pLg7xHytrsUvdhewgsIzs22du1X4raxM87m5UdCHXT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GDLcSY01QC1D50ky8cJ7JCSkkg7kdSJDwD2UaziHKx2bdWIsW/43I+nWcoSXUftq9o0MLKDUeQK+yeraDwOY86TMe3wfH+HLQ==; 23:Ayr7C8Ry2aJeAPMvJPn959tOlNv1Tc7rqfj3yJZF+w52c0K8FQyZwusc6dHd7nz8bTsDW4ex51diFbgHfMhL4ow4kBhdAeEy0QKp0p07wlvB6IPZd+Iq+lCvBRV9v1149RqOza7AlNq82wIv39hQsQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2017 13:46:47.6985 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB0881 X-OriginatorOrg: arm.com Cc: nd@arm.com, Liviu Dudau , LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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" X-Virus-Scanned: ClamAV using ClamSMTP If the device-tree 'reg' node doesn't reserve enough space for the DP, fail to bind. Reviewed-by: Brian Starkey Signed-off-by: Mihail Atanassov --- drivers/gpu/drm/arm/malidp_drv.c | 20 ++++++++++++++++++++ drivers/gpu/drm/arm/malidp_regs.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c index 43238f4..66622a5 100644 --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c @@ -296,6 +296,20 @@ static bool malidp_is_compatible_hw_id(struct malidp_hw_device *hwdev, return true; } +static bool malidp_is_sufficient_address_space(const struct resource *res, + const struct of_device_id *dev_id) +{ + resource_size_t res_size = resource_size(res); + const char *compatstr_dp500 = "arm,mali-dp500"; + + if (!strnstr(dev_id->compatible, compatstr_dp500, + sizeof(dev_id->compatible))) + return res_size >= MALIDP550_ADDR_SPACE_SIZE; + else if (res_size < MALIDP500_ADDR_SPACE_SIZE) + return false; + return true; +} + #define MAX_OUTPUT_CHANNELS 3 static int malidp_bind(struct device *dev) @@ -376,6 +390,12 @@ static int malidp_bind(struct device *dev) goto query_hw_fail; } + if (!malidp_is_sufficient_address_space(res, dev_id)) { + DRM_ERROR("Insufficient address space in device-tree.\n"); + ret = -EINVAL; + goto query_hw_fail; + } + if (!malidp_is_compatible_hw_id(hwdev, dev_id)) { ret = -EINVAL; goto query_hw_fail; diff --git a/drivers/gpu/drm/arm/malidp_regs.h b/drivers/gpu/drm/arm/malidp_regs.h index 7a89997..e0651d2 100644 --- a/drivers/gpu/drm/arm/malidp_regs.h +++ b/drivers/gpu/drm/arm/malidp_regs.h @@ -95,6 +95,7 @@ #define MALIDP_PRODUCT_ID(__core_id) ((u32)(__core_id) >> 16) /* register offsets and bits specific to DP500 */ +#define MALIDP500_ADDR_SPACE_SIZE 0x01000 #define MALIDP500_DC_BASE 0x00000 #define MALIDP500_DC_CONTROL 0x0000c #define MALIDP500_DC_CONFIG_REQ (1 << 17) @@ -127,6 +128,7 @@ #define MALIDP500_CONFIG_ID 0x00fd4 /* register offsets and bits specific to DP550/DP650 */ +#define MALIDP550_ADDR_SPACE_SIZE 0x10000 #define MALIDP550_DE_CONTROL 0x00010 #define MALIDP550_DE_LINE_COUNTER 0x00014 #define MALIDP550_DE_AXI_CONTROL 0x00018