From patchwork Tue Nov 25 20:04:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haixia Shi X-Patchwork-Id: 5382531 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EE95AC11AC for ; Tue, 25 Nov 2014 20:04:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C377201ED for ; Tue, 25 Nov 2014 20:04:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8824E2011B for ; Tue, 25 Nov 2014 20:04:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38A426E236; Tue, 25 Nov 2014 12:04:29 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F4DA6E236 for ; Tue, 25 Nov 2014 12:04:27 -0800 (PST) Received: by mail-ie0-f180.google.com with SMTP id rp18so1301461iec.11 for ; Tue, 25 Nov 2014 12:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=V7sx+Nt6Zqm2qb16ycC7yGkUH/lFiY3l/Ew6zX0edQM=; b=VCl4Hcrd/VB1ikU+d8gsMa6IIpdIOHZfpEA12sIaJ4+pstgdSGeIsdXRdMm9sMJgKl yeDlY2FGwJ7urOhJM+UTyjFEc8ec/E+dx0xDtl7oX4vBI48Wvtnf/NySgSR3NOUtIEDx 6wQ2/jqfXjgyLKO3CHPvhZC8v4ebPOlHWO0Zo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=V7sx+Nt6Zqm2qb16ycC7yGkUH/lFiY3l/Ew6zX0edQM=; b=mxG9Mx5PWiE4MJr6VT0QY+mJ2g82UQ7J1qbRPLu0lbow2wQ2ZzmkYA/k84tXQ8PHmv wBziaVKdsuNtAEtri58Ga7JxfHEsiIsqlxH9w0X/5w8+I6VwhZq5/IF2shG11tl2mqCF 1QLshPxrnlPLGyGzMcLeQxaX3xrifeGPVWqsKiE9G1rU+PLeLkfm/Q4d5RZM2Z+AwdI1 El7qUo2GTbDXT0Y8K7rqdVSbI/s6pQnNZOyWvbDqM71slt8ZLqoNdp7g1Lt8Wpcj4+nQ iG+rMQsP9aw9sQn9izMkkQgtRiOq9ZRRwV+yIStxFZwD2QkTJn6RlXpxRkZKEsik5aQt 5zIg== X-Gm-Message-State: ALoCoQmnwiHmx+x7AMHpdHp9jD/0+ReUgCYEeCUgQbe3ERYewFld0tBx6Z+On8hTNaVcn4tzd7cd X-Received: by 10.50.93.6 with SMTP id cq6mr19465147igb.7.1416945867247; Tue, 25 Nov 2014 12:04:27 -0800 (PST) Received: from localhost ([2620:0:1000:1600:21b6:de1c:1714:f317]) by mx.google.com with ESMTPSA id w7sm1049738iod.8.2014.11.25.12.04.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 25 Nov 2014 12:04:26 -0800 (PST) From: Haixia Shi To: dri-devel@lists.freedesktop.org, dan.carpenter@oracle.com Subject: [PATCH 1/2] drm/udl: handle page mapping in dmabuf export. Date: Tue, 25 Nov 2014 12:04:02 -0800 Message-Id: <1416945843-19569-1-git-send-email-hshi@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c MIME-Version: 1.0 Cc: airlied@redhat.com, Haixia Shi 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Fixes dmabuf export failure with -E_NOMEM when the page is not mapped. Signed-off-by: Haixia Shi Reviewed-by: Stéphane Marchesin --- drivers/gpu/drm/udl/udl_dmabuf.c | 7 +++++-- drivers/gpu/drm/udl/udl_drv.h | 2 ++ drivers/gpu/drm/udl/udl_gem.c | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_dmabuf.c b/drivers/gpu/drm/udl/udl_dmabuf.c index 1d85c3a..2425b76 100644 --- a/drivers/gpu/drm/udl/udl_dmabuf.c +++ b/drivers/gpu/drm/udl/udl_dmabuf.c @@ -90,8 +90,11 @@ static struct sg_table *udl_map_dma_buf(struct dma_buf_attachment *attach, return &udl_attach->sgt; if (!obj->pages) { - DRM_ERROR("pages is null.\n"); - return ERR_PTR(-ENOMEM); + ret = udl_gem_get_pages(obj); + if (ret) { + DRM_ERROR("failed to map pages.\n"); + return ERR_PTR(ret); + } } page_count = obj->base.size / PAGE_SIZE; diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index 1b132d7..80adbac 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h @@ -129,6 +129,8 @@ struct dma_buf *udl_gem_prime_export(struct drm_device *dev, struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev, struct dma_buf *dma_buf); +int udl_gem_get_pages(struct udl_gem_object *obj); +void udl_gem_put_pages(struct udl_gem_object *obj); int udl_gem_vmap(struct udl_gem_object *obj); void udl_gem_vunmap(struct udl_gem_object *obj); int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index cd3482d..2a0a784 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c @@ -127,7 +127,7 @@ int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) } } -static int udl_gem_get_pages(struct udl_gem_object *obj) +int udl_gem_get_pages(struct udl_gem_object *obj) { struct page **pages; @@ -143,7 +143,7 @@ static int udl_gem_get_pages(struct udl_gem_object *obj) return 0; } -static void udl_gem_put_pages(struct udl_gem_object *obj) +void udl_gem_put_pages(struct udl_gem_object *obj) { if (obj->base.import_attach) { drm_free_large(obj->pages);