From patchwork Thu Nov 13 02:33:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haixia Shi X-Patchwork-Id: 5293531 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 75865C11AC for ; Thu, 13 Nov 2014 02:34:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A45CF201EF for ; Thu, 13 Nov 2014 02:34:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9EE8B201C0 for ; Thu, 13 Nov 2014 02:33:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63EBB6E404; Wed, 12 Nov 2014 18:33:58 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ie0-f176.google.com (mail-ie0-f176.google.com [209.85.223.176]) by gabe.freedesktop.org (Postfix) with ESMTP id C13496E404 for ; Wed, 12 Nov 2014 18:33:57 -0800 (PST) Received: by mail-ie0-f176.google.com with SMTP id rd18so14839292iec.21 for ; Wed, 12 Nov 2014 18:33:57 -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=GZyhomMegKRJLpX6vYJZEpl/1OJF+oWFSp4Xlozv8Es=; b=O+Ve3uVheeWLBufWutM970HdbbYEj+9yshJDd0qMKFKbWuSrzkvKVke4o4Cb9a4tFr 6nANmLUmsvJLoOwnIhzgiFqosxH2IoxFh6QbIONR6BK2iAuOpRYcNlaP7/q+OqME/fuU 1mLRlQkamWj1/MTz5siN6tfjQlXWkSq+NOWcc= 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=GZyhomMegKRJLpX6vYJZEpl/1OJF+oWFSp4Xlozv8Es=; b=Hs0ZGXY3zoVsRrk3zO6v1rPYZNK8iX4WYVP2INFqQoO0Jo+1kkqEITL19wlwaiSY+T XzrrZKId2Lkr7kxAEuifyh2vTPT7cML/pg7NvpDfsaDt/O2nR18oGL7UkFZT1IkVkp34 cxIaE4GtNvJ4tV+s8Xubh0TI/9IgP4Aai6e7qtAvVKVe7lG1btAnZXhaHZ21GXkx8eNV 05dkQJ42T8nZfvLYOygyWFVboyDVPt2oSyMU6SOSemJZ/A3uZoccHlS0hTk4uNa04cs9 VU0KdUfv05lfizZwGvuWYrLDxVBAKj1mrpi5XJcmyi5wdhRekMezSCulTHZFGaVAzAPl 2AOA== X-Gm-Message-State: ALoCoQkNMY+jmlsL2aT7ZtxReMqzbHgsVjFhyw/0v5pi+PNDuffftL0P6vz/UHkv1eqpR8oNDAA7 X-Received: by 10.43.132.137 with SMTP id hu9mr2231023icc.27.1415846037346; Wed, 12 Nov 2014 18:33:57 -0800 (PST) Received: from localhost ([2620:0:1000:1600:59a4:92a1:44ec:94e9]) by mx.google.com with ESMTPSA id fk8sm8816325igb.9.2014.11.12.18.33.56 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 12 Nov 2014 18:33:56 -0800 (PST) From: Haixia Shi To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/udl: add cache flags definitions for udl_gem_object Date: Wed, 12 Nov 2014 18:33:52 -0800 Message-Id: <1415846033-3271-1-git-send-email-hshi@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 MIME-Version: 1.0 Cc: 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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 By default set udl_gem_object as cacheable, but set WC flag when attaching dmabuf. In udl_gem_mmap() update cache attributes based on the flags, similar to exynos_drm_gem_mmap(). Change-Id: I00e5e67f2285d66adcf2ae652a9d59f12af64541 Signed-off-by: Haixia Shi Reviewed-by: Sonny Rao Reviewed-by: Olof Johansson Reviewed-by: Stéphane Marchesin --- drivers/gpu/drm/udl/udl_drv.h | 4 ++++ drivers/gpu/drm/udl/udl_gem.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index c7490a2..3082780 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h @@ -25,6 +25,9 @@ #define DRIVER_MINOR 0 #define DRIVER_PATCHLEVEL 1 +#define UDL_BO_CACHEABLE (1 << 0) +#define UDL_BO_WC (1 << 1) + struct udl_device; struct urb_node { @@ -69,6 +72,7 @@ struct udl_gem_object { struct page **pages; void *vmapping; struct sg_table *sg; + unsigned int flags; }; #define to_udl_bo(x) container_of(x, struct udl_gem_object, base) diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index 8044f5f..e00459d 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c @@ -25,6 +25,7 @@ struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev, return NULL; } + obj->flags = UDL_BO_CACHEABLE; return obj; } @@ -56,6 +57,23 @@ udl_gem_create(struct drm_file *file, return 0; } +static void update_vm_cache_attr(struct udl_gem_object *obj, + struct vm_area_struct *vma) +{ + DRM_DEBUG_KMS("flags = 0x%x\n", obj->flags); + + /* non-cacheable as default. */ + if (obj->flags & UDL_BO_CACHEABLE) { + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); + } else if (obj->flags & UDL_BO_WC) { + vma->vm_page_prot = + pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); + } else { + vma->vm_page_prot = + pgprot_noncached(vm_get_page_prot(vma->vm_flags)); + } +} + int udl_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) @@ -77,6 +95,8 @@ int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) vma->vm_flags &= ~VM_PFNMAP; vma->vm_flags |= VM_MIXEDMAP; + update_vm_cache_attr(to_udl_bo(vma->vm_private_data), vma); + return ret; } @@ -279,6 +299,7 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev, } uobj->base.import_attach = attach; + uobj->flags = UDL_BO_WC; return &uobj->base;