From patchwork Mon Jan 29 13:55:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "StDenis, Tom" X-Patchwork-Id: 10189747 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 8A78F6020C for ; Mon, 29 Jan 2018 13:55:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78AFD209CE for ; Mon, 29 Jan 2018 13:55:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D32922299; Mon, 29 Jan 2018 13:55: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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, 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 EF21F209CE for ; Mon, 29 Jan 2018 13:55:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E05816E4C0; Mon, 29 Jan 2018 13:55:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0044.outbound.protection.outlook.com [104.47.38.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 23BFF6E4AF; Mon, 29 Jan 2018 13:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MO9iw84qL7gAYpoZeYXMI1H8DZG7h436TKuGKgoqDrA=; b=Z9de6oHlE5Wc8Skh1DZktCReSj/OVMDenSPfEfRFUdr/c9MfwWvTSE/SazvCWuIe9eBB1Yv52bLSZEpdgDoqasmRdj/dinplMWV8+xgLaule78UCziE0skpZptGXZ+HobbrwZpp6oBLwaZCJmmXyTMJTnfRAIRV+qlX57houWlM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tom.StDenis@amd.com; Received: from fx8.amd.com (165.204.55.251) by DM5PR1201MB0075.namprd12.prod.outlook.com (10.174.106.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Mon, 29 Jan 2018 13:55:28 +0000 From: Tom St Denis To: amd-gfx@lists.freedesktop.org Subject: [PATCH 04/12] drm/ttm: Change ttm_tt page allocations to return errors Date: Mon, 29 Jan 2018 08:55:05 -0500 Message-Id: <20180129135513.22538-5-tom.stdenis@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180129135513.22538-1-tom.stdenis@amd.com> References: <20180129135513.22538-1-tom.stdenis@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: CY4PR14CA0027.namprd14.prod.outlook.com (10.172.162.141) To DM5PR1201MB0075.namprd12.prod.outlook.com (10.174.106.17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7eac1bb7-6e03-4c26-5a78-08d5671ff4e3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DM5PR1201MB0075; X-Microsoft-Exchange-Diagnostics: 1; DM5PR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/C2Mtx+Tc4d8Z/urPXGanhxBCuJxHFmVfroLebfdY7tmCL+KGFpI8wxCNuo04GKMoid6lLYBLW1dm92RzrIsqwLbEv7IvVxAHuod9J6ULLaq+iYCR9zAr/jBcn9M2c+BQk5jNB0YrcgqrftE9OR2rlNGwJCy4Ot76tdktjGw/tJYqTaKD/DBVHYe5eiWGOYMGRnacLtFzU/WP3TbPN30M3+KOn3E1begHgLy3nkcVcD3q6TTSJC8bhfISdmVmp2hDd8V59wqkJkoIfXR12K5R/Qm1w7c1mzb31RO3B9wA8Rl9+Kq0fc4BDfhLRfpn9jt2sHNg+fdT134kPD8aGVdBfr3ug1mM1L; 4:Wdc2gqJ2BzF20YC89dv4/CYjE4oxXxQI5YXJVwOoKXw5R64GkCfaqkJ9XY9ntO2d5WvQOUTPID6DR2fUcIGXJKXl4cfX6vFShxAQ0szlLM5mBdvM4lQ+sAtxbQZzMQFKJcZ9bqWX+kiXhYr5u/MiiwDSPm2YoPaeoTnv+PwkJ74v4D72pp9PKKrduwCt3LcoECF2KjgzfUL9YsKQLnB8DqSgTzlRGa8spzXF89GqvsZxs5caOE7MRA5L8PmwRBkusPEPZeqyAq6RaNqbM1GcFuLTgOT+k7gLezezVlVpqhcCPdBxjwdz1/upBqq26+WA X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231101)(944501161)(93006095)(93001095)(6055026)(6041288)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:DM5PR1201MB0075; BCL:0; PCL:0; RULEID:; SRVR:DM5PR1201MB0075; X-Forefront-PRVS: 0567A15835 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39380400002)(396003)(39860400002)(346002)(366004)(189003)(199004)(59450400001)(76176011)(478600001)(7696005)(450100002)(7736002)(52116002)(6486002)(23676004)(86362001)(305945005)(2870700001)(53936002)(66066001)(5660300001)(72206003)(47776003)(4326008)(386003)(81166006)(97736004)(2361001)(25786009)(2351001)(106356001)(316002)(6666003)(8936002)(2950100002)(16526019)(2906002)(81156014)(68736007)(6916009)(186003)(36756003)(105586002)(8676002)(53416004)(50226002)(1076002)(3846002)(6116002)(50466002)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0075; H:fx8.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjEyMDFNQjAwNzU7MjM6WmhoczkrN1EwTXlUVnJPcTRPNkpHUHQy?= =?utf-8?B?Ykg5SVVteU9zRGxSajM0dERCaFR2NzVycWNYWjJabnRlVjFoU05CeWUwYkJ1?= =?utf-8?B?SE5Nb0RWTVl6S1ZLaXp5OUloNEZzYmU4eDJ3R2RaM2NXRTdxWGh4azhJdE5J?= =?utf-8?B?ZFJGRVlialBoNzNDcHhWOWhIN3dMR3JFS21GUVVkcUV4VFpkSmZDTnd5ZDlU?= =?utf-8?B?aDhXK2pjUC90MFptZysvVWdNeEdYbUlkaHN0eDhaOXIzM1RvY256Yk9iWHgy?= =?utf-8?B?TmtZd0JNZWhlazJ2RTNQOE5TUzhzZnR0eWhnM0UxU0hLd3dNRGs4NU1YSk9y?= =?utf-8?B?eGh2M2NGM1c3RVJPSHhRM0N2Q3dVMk5yOXlEa3RpSHhDK0ZYMFhMZDl0Y3hC?= =?utf-8?B?aEIyTWtNSjZDWnlJcndubkR1TmExSnVNWlZWYW53bWl1M1JhVEdEL2RMWEJ1?= =?utf-8?B?dGpRa1ZQbUM5eHpFV1pBemluRnp4L2VUMXJXd0hSaWQvSzkxU3NEdFIxUVl0?= =?utf-8?B?b0NMR3RYSDc4QkUxTHNuZVoyUHNGT29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n2qq/L5ao8gsG3lKSYVjd2m2nw8QjV/+OZjhSuTvpmdYFYzcxJzU28Ooj/kfdqKadeq+9Qtbe5DSzRtLKlM8U/++sFvc/aEZU/eyK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0075; 20:1vN21IfvljnaG0vFhPy3UpMbxJHDqoTu4YURCL5pmhi280k0KVVE154z3b5i0jh5U3LGcJJ7zQe+e0pW5yMzdgZXQ98/vv4TByIB6hLBFBrZ+FNfQ/lFYZ/9z3D6IN1mqIL3Io6RwBZEptEden7eKT2wj0LvlcnSOdk0uMcmnCEtvvnFvFu+ZjYn+VJc1ESIAxGDxZEiKRiBaO2KLFmxH2sNv9VtdeSxyFZkOava1bQ77hVwFs+Odn36iuxqMoGo X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2018 13:55:28.6418 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7eac1bb7-6e03-4c26-5a78-08d5671ff4e3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0075 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: Tom St Denis , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Explicitly return errors in ttm_tt_alloc_page_directory() and ttm_dma_tt_alloc_page_directory() instead of relying on further logic to detect errors. Signed-off-by: Tom St Denis Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_tt.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 9e4d43d68e91..e90d3ed6283f 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -50,19 +50,25 @@ /** * Allocates storage for pointers to the pages that back the ttm. */ -static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm) +static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm) { ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*), GFP_KERNEL | __GFP_ZERO); + if (!ttm->pages) + return -ENOMEM; + return 0; } -static void ttm_dma_tt_alloc_page_directory(struct ttm_dma_tt *ttm) +static int ttm_dma_tt_alloc_page_directory(struct ttm_dma_tt *ttm) { ttm->ttm.pages = kvmalloc_array(ttm->ttm.num_pages, sizeof(*ttm->ttm.pages) + sizeof(*ttm->dma_address), GFP_KERNEL | __GFP_ZERO); + if (!ttm->ttm.pages) + return -ENOMEM; ttm->dma_address = (void *) (ttm->ttm.pages + ttm->ttm.num_pages); + return 0; } #ifdef CONFIG_X86 @@ -197,8 +203,7 @@ int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev, ttm->state = tt_unpopulated; ttm->swap_storage = NULL; - ttm_tt_alloc_page_directory(ttm); - if (!ttm->pages) { + if (ttm_tt_alloc_page_directory(ttm)) { ttm_tt_destroy(ttm); pr_err("Failed allocating page table\n"); return -ENOMEM; @@ -230,8 +235,7 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, ttm->swap_storage = NULL; INIT_LIST_HEAD(&ttm_dma->pages_list); - ttm_dma_tt_alloc_page_directory(ttm_dma); - if (!ttm->pages) { + if (ttm_dma_tt_alloc_page_directory(ttm_dma)) { ttm_tt_destroy(ttm); pr_err("Failed allocating page table\n"); return -ENOMEM;