From patchwork Fri Feb 7 20:36:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 3607631 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4C3C89F390 for ; Fri, 7 Feb 2014 20:37:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 820592016C for ; Fri, 7 Feb 2014 20:37:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 927AB20131 for ; Fri, 7 Feb 2014 20:37:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C759105798; Fri, 7 Feb 2014 12:37:16 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yh0-f49.google.com (mail-yh0-f49.google.com [209.85.213.49]) by gabe.freedesktop.org (Postfix) with ESMTP id CE2A1105785 for ; Fri, 7 Feb 2014 12:37:14 -0800 (PST) Received: by mail-yh0-f49.google.com with SMTP id t59so3093267yho.8 for ; Fri, 07 Feb 2014 12:37:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NjxReDspL8eaJKLnDsbBMdpBOT5ppmbQ1hR4cIRF3UY=; b=l2b9F9Ca9CeGJ5ELh099lqgdAFL0Zvt4h7QM+rCy0wen3pCvND79Wz1XwixG39aFIr fqsz53C1tGCRgUF+PoB1g1PCDndrVt+xrdyDXsDIlBrs6rKsoFjSnUQ9K+m1oPW/JMbT 8CXkWpdgkASYcK8UJ2rzyEE3sNrJiERrZrD9Uw+3kD9+X7fxFTdm4Ft3uzDYgYfUM0S8 7K+yMrpTXRztNy2mawxdEzyEB5dnZC/WmjXQrymVN0seuk4aUjFMRsAaQbeA35xUeOAx JhGES37Cj/ALWFG4KjHgncI+Va1lJ8sXd6yjobYcByixntbR9Y/+4eXP6B4jqSEXf4iX qKEQ== X-Received: by 10.236.222.231 with SMTP id t97mr1601664yhp.125.1391805433829; Fri, 07 Feb 2014 12:37:13 -0800 (PST) Received: from localhost.localdomain ([189.67.97.168]) by mx.google.com with ESMTPSA id q9sm13697981yhk.16.2014.02.07.12.37.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Feb 2014 12:37:13 -0800 (PST) From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Fri, 7 Feb 2014 18:36:59 -0200 Message-Id: <1391805427-4576-2-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1391805427-4576-1-git-send-email-rodrigo.vivi@gmail.com> References: <1391805427-4576-1-git-send-email-rodrigo.vivi@gmail.com> Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH 1/9] drm/i915: Propagate errors on failed PPGTT X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Widawsky Clean up the return values/error handling so it's obvious what is going on. This was tripped over in the PPGTT branch where code was added to do a ret = foo() near the top, and this ended up bypassing some error cases later. These errors shouldn't exist with today's code, but a future patch will add a ret = ..., and this the value of ret needs to be set explicitly. v2: Missed an error in alloc_page for gen6 Signed-off-by: Ben Widawsky Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/i915_gem_gtt.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 6e858e1..2996c83 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -362,7 +362,7 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm) static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size) { struct page *pt_pages; - int i, j, ret = -ENOMEM; + int i, j, ret; const int max_pdp = DIV_ROUND_UP(size, 1 << 30); const int num_pt_pages = GEN8_PDES_PER_PAGE * max_pdp; @@ -408,14 +408,17 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size) temp = pci_map_page(ppgtt->base.dev->pdev, &ppgtt->pd_pages[i], 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); - if (pci_dma_mapping_error(ppgtt->base.dev->pdev, temp)) + ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, temp); + if (ret) goto err_out; ppgtt->pd_dma_addr[i] = temp; ppgtt->gen8_pt_dma_addr[i] = kmalloc(sizeof(dma_addr_t) * GEN8_PDES_PER_PAGE, GFP_KERNEL); - if (!ppgtt->gen8_pt_dma_addr[i]) + if (!ppgtt->gen8_pt_dma_addr[i]) { + ret = -ENOMEM; goto err_out; + } for (j = 0; j < GEN8_PDES_PER_PAGE; j++) { struct page *p = &pt_pages[i * GEN8_PDES_PER_PAGE + j]; @@ -423,7 +426,8 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size) p, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); - if (pci_dma_mapping_error(ppgtt->base.dev->pdev, temp)) + ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, temp); + if (ret) goto err_out; ppgtt->gen8_pt_dma_addr[i][j] = temp; @@ -907,14 +911,18 @@ alloc: for (i = 0; i < ppgtt->num_pd_entries; i++) { ppgtt->pt_pages[i] = alloc_page(GFP_KERNEL); - if (!ppgtt->pt_pages[i]) + if (!ppgtt->pt_pages[i]) { + ret = -ENOMEM; goto err_pt_alloc; + } } ppgtt->pt_dma_addr = kcalloc(ppgtt->num_pd_entries, sizeof(dma_addr_t), GFP_KERNEL); - if (!ppgtt->pt_dma_addr) + if (!ppgtt->pt_dma_addr) { + ret = -ENOMEM; goto err_pt_alloc; + } for (i = 0; i < ppgtt->num_pd_entries; i++) { dma_addr_t pt_addr;