From patchwork Fri Jan 26 18:29:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "StDenis, Tom" X-Patchwork-Id: 10186709 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 00DDC60383 for ; Fri, 26 Jan 2018 18:29:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5FF9297F7 for ; Fri, 26 Jan 2018 18:29:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA4D029BC8; Fri, 26 Jan 2018 18:29:34 +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=BAD_ENC_HEADER,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 BA4B5297F7 for ; Fri, 26 Jan 2018 18:29:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DC836E637; Fri, 26 Jan 2018 18:29:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0065.outbound.protection.outlook.com [104.47.34.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5165D6E635; Fri, 26 Jan 2018 18:29:28 +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=TBukI+oeq+rm1R9HKSIxJJC9VgiInN+wrZPquxB5pq0=; b=aN9S20XKnxV1yu/hIX13avXYcrxi16iW6NswuKDk4SXMmYD5XGwy/sb9i6BCz0FjzGs74ddURrxCgt1kA+m4hHgxQ7mHy4AhB72CNHfsCln2XJ59V88xBEjSiFKZxJMdr3I9vx7Q46XPZQ1cCNJ7JsOhTjNeEc3o6e5rMLzmLOw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tom.StDenis@amd.com; Received: from fx8.amd.com (165.204.55.251) by DM5PR1201MB0076.namprd12.prod.outlook.com (10.174.106.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Fri, 26 Jan 2018 18:29:26 +0000 From: Tom St Denis To: amd-gfx@lists.freedesktop.org Subject: [PATCH 03/12] drm/ttm: Change ttm_tt page allocations to return errors Date: Fri, 26 Jan 2018 13:29:02 -0500 Message-Id: <20180126182911.20761-4-tom.stdenis@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180126182911.20761-1-tom.stdenis@amd.com> References: <20180126182911.20761-1-tom.stdenis@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: MWHPR03CA0027.namprd03.prod.outlook.com (10.174.173.144) To DM5PR1201MB0076.namprd12.prod.outlook.com (10.174.106.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f10a9fb7-33ef-4a79-1ee1-08d564eabb51 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DM5PR1201MB0076; X-Microsoft-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dbSXTY5j3gRZqRM8rUyzCK6e0/Q2dbCbDXx8/tFB0LSb5pRIHO0gzC8W6BiKB5p94dmpMuDJ14ftIAXFH6fgL5YGNXdpHtPZBN/dnMgM1/7PvDC7Js9rYG7mZqN1Fck0RgsEWex/3q2KhUbIr2pAkVDQcVwN1OEEz9eBoV/JKbrAamOe/Z4+Rn7mlHu7gfs7jBdwlxq+Tqi609uCeQLg88KIgeje/LEqSF9PZi6aNj6Ux5Gkctfj9JrbWgTzwVrI5P+VZGpPpY/QUGRrJst+thXSvb7oVYifOYzmDLF4/fVyViXlGHpL5RhHg8MUYMjkWpacHobznq7JD7KHQUOLDyqe6OtqYSm3DcwEpGqNef0jk7OGKR2zmQ/kQbWX; 4:ADva3GRU2wDXT8ns4q9Vi2KUyDblTOiClDDlmx+Vi6SHONZua+PkWMttkBHA2Go7baFDpyTUkCO9oBua26r/6jE46OyC1AG8TXXSYem1pRi15KA8xQQNBvuMHoFOl41vMxpVXbG849xOVr0ypO3J2Y5Uk1yWMng92m34sF5jy3kujR1ws2GqY6TBP+kuB2QizvMLKnMh2gwQ9u90olvGA0fiWhguOAbYJqBIu+3pXjaFjVs6r66R7Z842urc70uwYkTHK2bJuuMIKeB7nV9BIALlXcDb7wzebNspq+rnMy4CUTguYDWQTwLlePlf2GTP 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)(3231075)(2400081)(944501161)(93006095)(93001095)(6055026)(6041288)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR1201MB0076; BCL:0; PCL:0; RULEID:; SRVR:DM5PR1201MB0076; X-Forefront-PRVS: 05641FD966 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(376002)(396003)(39380400002)(346002)(199004)(189003)(6916009)(2950100002)(6666003)(7736002)(305945005)(5660300001)(1076002)(6486002)(6116002)(3846002)(53936002)(86362001)(51416003)(16526019)(81156014)(7696005)(52116002)(186003)(26005)(8676002)(97736004)(59450400001)(386003)(50226002)(53416004)(76176011)(8936002)(81166006)(25786009)(36756003)(316002)(478600001)(72206003)(47776003)(50466002)(68736007)(16586007)(48376002)(450100002)(66066001)(4326008)(2361001)(106356001)(105586002)(2906002)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0076; H:fx8.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR1201MB0076; 23:wvWxcHECZ1jYxhZ01+PdInrNEtiH81AMile4tUz?= =?us-ascii?Q?ROIdFw+jb32otwNXlpqPj8zeqRPbaT4JqzgpF78pB1OOQgdmqwoaEgVPWPoh?= =?us-ascii?Q?vqDSTO2viqQUqCd+TsDTNQSDit5bddtY+D789vZ3UKkBldT223MvH6zmlM2A?= =?us-ascii?Q?YHBg1aqeCX6kauuUm+UBdJYhNQOZNlnP1kgor2Eg53TXViK0KmTmWwrPKzQo?= =?us-ascii?Q?37idGg1xuQ0YCxR2BhtGdIrsA+NJmQtbyAjvdnKg0VI0t4JY0rNjUYnapygI?= =?us-ascii?Q?OlRVMy3VDeHsNDrzOMj604+tyY4B4BIXFxJj1DDGgDubdDnN2Dd0Q+tsyy57?= =?us-ascii?Q?YmZ8QpuEOkCG56XI+fZA44CNxOCvwfSVwzA0M2BWoS2i740rcqo8UPEmrAG2?= =?us-ascii?Q?lr5Yylasi0CJOVOOSpU9OFElQpkfXZvRVLYb1hJovHRv0rHKHfEANIzkoaxW?= =?us-ascii?Q?x1RxTxubBxTfQY/NGZqoC0M65hX9D0mh4B3FLMhGgWsyCCW3thzeUy1pbd8M?= =?us-ascii?Q?oxXloeNkae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IrAol+Ru+GxOIUxE0fvt1yfcoX5 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2018 18:29:26.4011 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f10a9fb7-33ef-4a79-1ee1-08d564eabb51 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0076 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 --- 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;