From patchwork Tue Jul 16 21:37:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11046729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D19CA1510 for ; Tue, 16 Jul 2019 21:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC4AE285DA for ; Tue, 16 Jul 2019 21:40:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AADF128613; Tue, 16 Jul 2019 21:40:03 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 47C22285DA for ; Tue, 16 Jul 2019 21:40:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BD016E0DC; Tue, 16 Jul 2019 21:40:02 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC6E36E0DC; Tue, 16 Jul 2019 21:40:01 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id i18so10069003pgl.11; Tue, 16 Jul 2019 14:40:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oew0rHc9LPVEYVoKj5FLWcwETCU8bWgVAiMOY+m8rQs=; b=tqqy2geeMIJD4WRZmG9z4mWom3L+cT5y6cao4oq09NGFA8zVSA2kkrCtptNzkreKlL XfQQnIjkUhxnrLoKqrqNLIkaBeNuCZg8JYxH4bTZNlsjGBVlAXrYz/6v2PdEObi5xMTT +AeHa8po0fISrqVJnpG+ljzRt4xHsXDRoQbiaAqoK3QXPMRzHI6C6SN+YeEqbf4qHOBE qvfMlr3yblfwe1M6dSopxqvM5xeGfPXJxSTyyNrBYlLOWdcuviXXx5PBt1ooj0uN5+Bs eJEDwrL9wT8UFmefA6+WhW1RyB3iHmrQdvCrtjhtCQLTio0SL4QqIqA1ZIsj4CcE73zX QR+g== X-Gm-Message-State: APjAAAVf5958Rkdg4fjP/dPpKE+89NdTHG2ry1DdAQFJHYIoJNk0g12M kdqFy8dQG6F/3kyoBb7ytmPWs0cZUBg= X-Google-Smtp-Source: APXvYqx+31ux3AoWLdoZRzOA2Sk4B6TvHUXDsOvZ3wbk2EHT9+znE5RnV6rR626W6uSBer+MHEIXzw== X-Received: by 2002:a63:c1c:: with SMTP id b28mr4522700pgl.354.1563313200857; Tue, 16 Jul 2019 14:40:00 -0700 (PDT) Received: from localhost ([100.118.89.203]) by smtp.gmail.com with ESMTPSA id o95sm18933486pjb.4.2019.07.16.14.39.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 14:40:00 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Date: Tue, 16 Jul 2019 14:37:40 -0700 Message-Id: <20190716213746.4670-1-robdclark@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oew0rHc9LPVEYVoKj5FLWcwETCU8bWgVAiMOY+m8rQs=; b=cUmEeelpLLzt9uU8Kc5mtrmDCofKp6X62YT8kg/ywsuaaY8eOtghanE3divC3APozs zMV9jm3NA63gOSuu1qez7JLtbuX3jNGjtG1WOsP/e15FGrjLeXocrvK2uwbZLoEBTgE2 Rzm/RXF2QeCU7EKIKsNnrCjUKiehEqvPsoqntBznIBgG+GAdeBwmIZuXfjiQqJDTMfsC HoWWGDkZx63oyErc2+yq2911qfeYNM4u7m4u01zirPyN0QqnGd9Kg9QyFzDhbPLczZDy ltsboE+bBTErk6of4euwNt+WJMu9sGGruYa+sS9s6DBd8A3MklOaO07qzZWB60JrUjkt pkIQ== Subject: [Intel-gfx] [PATCH v3 1/3] drm/gem: don't force writecombine mmap'ing X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Maxime Ripard , Intel Graphics Development , linux-kernel@vger.kernel.org, David Airlie Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Clark The driver should be in control of this. Signed-off-by: Rob Clark --- It is possible that this was masking bugs (ie. not setting appropriate pgprot) in drivers. I don't have a particularly good idea for tracking those down (since I don't have the hw for most drivers). Unless someone has a better idea, maybe land this and let driver maintainers fix any potential fallout in their drivers? This is necessary for the last patch to fix VGEM brokenness on arm. v3: rebased on drm-tip drivers/gpu/drm/drm_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index e6c12c6ec728..84689ccae885 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1109,7 +1109,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP; vma->vm_private_data = obj; - vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); /* Take a ref for this mapping of the object, so that the fault From patchwork Tue Jul 16 21:37:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11046735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94D981510 for ; Tue, 16 Jul 2019 21:42:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8167328689 for ; Tue, 16 Jul 2019 21:42:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7454B28698; Tue, 16 Jul 2019 21:42:44 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 BC7B828694 for ; Tue, 16 Jul 2019 21:42:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 108B36E0E4; Tue, 16 Jul 2019 21:42:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 63CF46E0E4; Tue, 16 Jul 2019 21:42:41 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id t16so9724737pfe.11; Tue, 16 Jul 2019 14:42:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+natRHZ6L0BuGx+W5tA7MTs43222M5gkM31utxxbCOU=; b=e0m17xVKcUvytXknOsKbXU3B7ReFkn0IMACFGYCdw+7SHsdxzWRy6MkdQMKNdL/wk9 VGYn8RiT0PVG4J0rKwMA25s+SNR1HDmDs0s39FlQAnYdzRIoY8j4h9I5LMufoGPMLC6n mlfricd39YdyUOsVXvUHmdPwbCmzDFa+xqm9oX+IVWltEycISW0Oa0funmgVwPCwYp4n XmfYPMKQUKwLsDYADHN13WY9ebbvdgJjdL+SwisKPdVL7fTirxGVe9ELWWWO/1uhau5f VhbLer+PFRxGV2vom8B/FKBZ4Z0uvbz0cAlGekuB5RiWe0jhD/n2/5E/zU3/16FLARNr MBcw== X-Gm-Message-State: APjAAAURr6xla7d/83hriM1Zt5jv1mWlzB2nNJTyQpwwfP2CPGi1bQXh 0afchu+EaRxnd2xumeQualVgrr1gCF64vg== X-Google-Smtp-Source: APXvYqzfz/S5WZIpSAuwm3Dywv2EHXSbMUU2QF7mDGE4cV/Oh7IH2/0lpwu3uOVqyg5xVISogAbcDA== X-Received: by 2002:a63:1658:: with SMTP id 24mr37706389pgw.167.1563313360593; Tue, 16 Jul 2019 14:42:40 -0700 (PDT) Received: from localhost ([100.118.89.203]) by smtp.gmail.com with ESMTPSA id q22sm18809095pgh.49.2019.07.16.14.42.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 14:42:39 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Date: Tue, 16 Jul 2019 14:37:41 -0700 Message-Id: <20190716213746.4670-2-robdclark@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190716213746.4670-1-robdclark@gmail.com> References: <20190716213746.4670-1-robdclark@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+natRHZ6L0BuGx+W5tA7MTs43222M5gkM31utxxbCOU=; b=kN3NUoT12UjsD2xyZpN8e4MYUo58H5FkPsDaw8dzZE/ejR28e9veipDZu1ue9cFGNJ C9ZB5Ngpuq+di+buJJ/Y47TVf7fsGqHj2vxwz+U3KoDhMp3U07imodBdSnwCXjDsRyKy TVLJsb4D6EpfgBYl20dhWfgQiN4IuioGmF3wHHQZJOPVoT3bwtxGrlqOj6NTIzGPXb3O p3mszmW7RuMgdxXOfE/D3ASRGoZH71QWpyjfEHflYR5LADDR5ggU+8ZzdiCMyypEoFPP vBTopgbzZ2VpMO56qkbzYjBr59Ev6sZ/AffvJvMX6yIH49JK9TZh2AAKuy/8oJCspGrY Yn5Q== Subject: [Intel-gfx] [PATCH v3 2/3] drm: plumb attaching dev thru to prime_pin/unpin X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Biggers , Maxime Ripard , nouveau@lists.freedesktop.org, Gerd Hoffmann , Emil Velikov , Rob Clark , "David \(ChunMing\) Zhou" , amd-gfx@lists.freedesktop.org, David Airlie , Ben Skeggs , Russell King , Dave Airlie , Deepak Sharma , linux-arm-msm@vger.kernel.org, Intel Graphics Development , etnaviv@lists.freedesktop.org, spice-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Thomas Zimmermann , Alex Deucher , freedreno@lists.freedesktop.org, =?utf-8?q?Christian_K=C3=B6nig?= , Lucas Stach Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Clark Needed in the following patch for cache operations. Signed-off-by: Rob Clark --- v3: rebased on drm-tip drivers/gpu/drm/drm_gem.c | 8 ++++---- drivers/gpu/drm/drm_internal.h | 4 ++-- drivers/gpu/drm/drm_prime.c | 4 ++-- drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 4 ++-- drivers/gpu/drm/msm/msm_drv.h | 4 ++-- drivers/gpu/drm/msm/msm_gem_prime.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_gem.h | 4 ++-- drivers/gpu/drm/nouveau/nouveau_prime.c | 4 ++-- drivers/gpu/drm/qxl/qxl_prime.c | 4 ++-- drivers/gpu/drm/radeon/radeon_prime.c | 4 ++-- drivers/gpu/drm/vgem/vgem_drv.c | 4 ++-- include/drm/drm_drv.h | 5 ++--- 12 files changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 84689ccae885..af2549c45027 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1215,22 +1215,22 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent, obj->dev->driver->gem_print_info(p, indent, obj); } -int drm_gem_pin(struct drm_gem_object *obj) +int drm_gem_pin(struct drm_gem_object *obj, struct device *dev) { if (obj->funcs && obj->funcs->pin) return obj->funcs->pin(obj); else if (obj->dev->driver->gem_prime_pin) - return obj->dev->driver->gem_prime_pin(obj); + return obj->dev->driver->gem_prime_pin(obj, dev); else return 0; } -void drm_gem_unpin(struct drm_gem_object *obj) +void drm_gem_unpin(struct drm_gem_object *obj, struct device *dev) { if (obj->funcs && obj->funcs->unpin) obj->funcs->unpin(obj); else if (obj->dev->driver->gem_prime_unpin) - obj->dev->driver->gem_prime_unpin(obj); + obj->dev->driver->gem_prime_unpin(obj, dev); } void *drm_gem_vmap(struct drm_gem_object *obj) diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 51a2055c8f18..e64090373e3a 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -133,8 +133,8 @@ void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); void drm_gem_print_info(struct drm_printer *p, unsigned int indent, const struct drm_gem_object *obj); -int drm_gem_pin(struct drm_gem_object *obj); -void drm_gem_unpin(struct drm_gem_object *obj); +int drm_gem_pin(struct drm_gem_object *obj, struct device *dev); +void drm_gem_unpin(struct drm_gem_object *obj, struct device *dev); void *drm_gem_vmap(struct drm_gem_object *obj); void drm_gem_vunmap(struct drm_gem_object *obj, void *vaddr); diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 189d980402ad..126860432ff9 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -575,7 +575,7 @@ int drm_gem_map_attach(struct dma_buf *dma_buf, { struct drm_gem_object *obj = dma_buf->priv; - return drm_gem_pin(obj); + return drm_gem_pin(obj, attach->dev); } EXPORT_SYMBOL(drm_gem_map_attach); @@ -593,7 +593,7 @@ void drm_gem_map_detach(struct dma_buf *dma_buf, { struct drm_gem_object *obj = dma_buf->priv; - drm_gem_unpin(obj); + drm_gem_unpin(obj, attach->dev); } EXPORT_SYMBOL(drm_gem_map_detach); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c index a05292e8ed6f..67e69a5f00f2 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c @@ -43,7 +43,7 @@ int etnaviv_gem_prime_mmap(struct drm_gem_object *obj, return etnaviv_obj->ops->mmap(etnaviv_obj, vma); } -int etnaviv_gem_prime_pin(struct drm_gem_object *obj) +int etnaviv_gem_prime_pin(struct drm_gem_object *obj, struct device *dev) { if (!obj->import_attach) { struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); @@ -55,7 +55,7 @@ int etnaviv_gem_prime_pin(struct drm_gem_object *obj) return 0; } -void etnaviv_gem_prime_unpin(struct drm_gem_object *obj) +void etnaviv_gem_prime_unpin(struct drm_gem_object *obj, struct device *dev) { if (!obj->import_attach) { struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index ee7b512dc158..0eea68618b68 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -288,8 +288,8 @@ void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); int msm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev, struct dma_buf_attachment *attach, struct sg_table *sg); -int msm_gem_prime_pin(struct drm_gem_object *obj); -void msm_gem_prime_unpin(struct drm_gem_object *obj); +int msm_gem_prime_pin(struct drm_gem_object *obj, struct device *dev); +void msm_gem_prime_unpin(struct drm_gem_object *obj, struct device *dev); void *msm_gem_get_vaddr(struct drm_gem_object *obj); void *msm_gem_get_vaddr_active(struct drm_gem_object *obj); void msm_gem_put_vaddr(struct drm_gem_object *obj); diff --git a/drivers/gpu/drm/msm/msm_gem_prime.c b/drivers/gpu/drm/msm/msm_gem_prime.c index 5d64e0671f7a..cc07bf94e206 100644 --- a/drivers/gpu/drm/msm/msm_gem_prime.c +++ b/drivers/gpu/drm/msm/msm_gem_prime.c @@ -47,14 +47,14 @@ struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev, return msm_gem_import(dev, attach->dmabuf, sg); } -int msm_gem_prime_pin(struct drm_gem_object *obj) +int msm_gem_prime_pin(struct drm_gem_object *obj, struct device *dev) { if (!obj->import_attach) msm_gem_get_pages(obj); return 0; } -void msm_gem_prime_unpin(struct drm_gem_object *obj) +void msm_gem_prime_unpin(struct drm_gem_object *obj, struct device *dev) { if (!obj->import_attach) msm_gem_put_pages(obj); diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.h b/drivers/gpu/drm/nouveau/nouveau_gem.h index fe39998f65cc..91dcf89138f1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.h +++ b/drivers/gpu/drm/nouveau/nouveau_gem.h @@ -32,9 +32,9 @@ extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *, void *, extern int nouveau_gem_ioctl_info(struct drm_device *, void *, struct drm_file *); -extern int nouveau_gem_prime_pin(struct drm_gem_object *); +extern int nouveau_gem_prime_pin(struct drm_gem_object *, struct device *); struct reservation_object *nouveau_gem_prime_res_obj(struct drm_gem_object *); -extern void nouveau_gem_prime_unpin(struct drm_gem_object *); +extern void nouveau_gem_prime_unpin(struct drm_gem_object *, struct device *); extern struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object *); extern struct drm_gem_object *nouveau_gem_prime_import_sg_table( struct drm_device *, struct dma_buf_attachment *, struct sg_table *); diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c index 1fefc93af1d7..dec2d5e37b34 100644 --- a/drivers/gpu/drm/nouveau/nouveau_prime.c +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c @@ -88,7 +88,7 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev, return &nvbo->gem; } -int nouveau_gem_prime_pin(struct drm_gem_object *obj) +int nouveau_gem_prime_pin(struct drm_gem_object *obj, struct device *dev) { struct nouveau_bo *nvbo = nouveau_gem_object(obj); int ret; @@ -101,7 +101,7 @@ int nouveau_gem_prime_pin(struct drm_gem_object *obj) return 0; } -void nouveau_gem_prime_unpin(struct drm_gem_object *obj) +void nouveau_gem_prime_unpin(struct drm_gem_object *obj, struct device *dev) { struct nouveau_bo *nvbo = nouveau_gem_object(obj); diff --git a/drivers/gpu/drm/qxl/qxl_prime.c b/drivers/gpu/drm/qxl/qxl_prime.c index 7d3816fca5a8..21e9b44eb2e4 100644 --- a/drivers/gpu/drm/qxl/qxl_prime.c +++ b/drivers/gpu/drm/qxl/qxl_prime.c @@ -28,14 +28,14 @@ /* Empty Implementations as there should not be any other driver for a virtual * device that might share buffers with qxl */ -int qxl_gem_prime_pin(struct drm_gem_object *obj) +int qxl_gem_prime_pin(struct drm_gem_object *obj, struct device *dev) { struct qxl_bo *bo = gem_to_qxl_bo(obj); return qxl_bo_pin(bo); } -void qxl_gem_prime_unpin(struct drm_gem_object *obj) +void qxl_gem_prime_unpin(struct drm_gem_object *obj, struct device *dev) { struct qxl_bo *bo = gem_to_qxl_bo(obj); diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c index deaffce50a2e..f3442bd860f6 100644 --- a/drivers/gpu/drm/radeon/radeon_prime.c +++ b/drivers/gpu/drm/radeon/radeon_prime.c @@ -83,7 +83,7 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev, return &bo->gem_base; } -int radeon_gem_prime_pin(struct drm_gem_object *obj) +int radeon_gem_prime_pin(struct drm_gem_object *obj, struct device *dev) { struct radeon_bo *bo = gem_to_radeon_bo(obj); int ret = 0; @@ -101,7 +101,7 @@ int radeon_gem_prime_pin(struct drm_gem_object *obj) return ret; } -void radeon_gem_prime_unpin(struct drm_gem_object *obj) +void radeon_gem_prime_unpin(struct drm_gem_object *obj, struct device *dev) { struct radeon_bo *bo = gem_to_radeon_bo(obj); int ret = 0; diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index 76d95b5e289c..e7d12e93b1f0 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c @@ -307,7 +307,7 @@ static void vgem_unpin_pages(struct drm_vgem_gem_object *bo) mutex_unlock(&bo->pages_lock); } -static int vgem_prime_pin(struct drm_gem_object *obj) +static int vgem_prime_pin(struct drm_gem_object *obj, struct device *dev) { struct drm_vgem_gem_object *bo = to_vgem_bo(obj); long n_pages = obj->size >> PAGE_SHIFT; @@ -325,7 +325,7 @@ static int vgem_prime_pin(struct drm_gem_object *obj) return 0; } -static void vgem_prime_unpin(struct drm_gem_object *obj) +static void vgem_prime_unpin(struct drm_gem_object *obj, struct device *dev) { struct drm_vgem_gem_object *bo = to_vgem_bo(obj); diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index b33f2cee2099..2b3d79bde6e1 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -592,20 +592,19 @@ struct drm_driver { */ struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, struct dma_buf *dma_buf); - /** * @gem_prime_pin: * * Deprecated hook in favour of &drm_gem_object_funcs.pin. */ - int (*gem_prime_pin)(struct drm_gem_object *obj); + int (*gem_prime_pin)(struct drm_gem_object *obj, struct device *dev); /** * @gem_prime_unpin: * * Deprecated hook in favour of &drm_gem_object_funcs.unpin. */ - void (*gem_prime_unpin)(struct drm_gem_object *obj); + void (*gem_prime_unpin)(struct drm_gem_object *obj, struct device *dev); /** From patchwork Tue Jul 16 21:37:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11046743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 903F613BD for ; Tue, 16 Jul 2019 21:45:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7544F28689 for ; Tue, 16 Jul 2019 21:45:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6563C28698; Tue, 16 Jul 2019 21:45:03 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 1028328689 for ; Tue, 16 Jul 2019 21:45:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A48856E0F3; Tue, 16 Jul 2019 21:45:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F5EB6E0F3; Tue, 16 Jul 2019 21:45:00 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id f25so10070640pgv.10; Tue, 16 Jul 2019 14:45:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4drR0FDgR1qKvDPf6ArOgp5GWnRtGoeeH0ezG721TC0=; b=ai8rFYoNo6I+tsPofwT4ZAFDaoyUQSVCJbIEoZUsohVzGlkX9R5///NT2nIXZM4uAV PMyu2XvcuAQDwiEGAztoPVWLgU2XFbuCqo8PD4pdZfUtoaFTh/JTz3iFmUGwzld9QiCI y58BJCyT86A2A3+ijeZlH2V5/zbcbp/taPfbOocJjdi11B5lD9QDJdtewzECoj866sYr tR4rQMDUffcnokNVk2PRqhZMvLzAmulGAHmvksMe7JK1SpQuaYE/aCQeH5hoVXGLwRyM sk6yYLSQ5mJd01BMF76SZYXmb90vjLchmAgOW3Jo6gDvv13rhRKss5OjY6RHPr/PML4B kQdw== X-Gm-Message-State: APjAAAXW0ZXc7QULIijgEiARGuc5+rW5gpqCrmAygdWAT9Epev1w73Fr T/+dgJTQGvOGFStuXqO5P6ZYa7ikjk4= X-Google-Smtp-Source: APXvYqxiDio1TWrmNR0NEynX+8QmbTFyvAzkbSoW72UZvLkMfedCjFiKOzRrZlV77GO0V2OJitoyeQ== X-Received: by 2002:a17:90a:5887:: with SMTP id j7mr39000839pji.136.1563313499680; Tue, 16 Jul 2019 14:44:59 -0700 (PDT) Received: from localhost ([100.118.89.203]) by smtp.gmail.com with ESMTPSA id 135sm20978687pfb.137.2019.07.16.14.44.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 14:44:59 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Date: Tue, 16 Jul 2019 14:37:42 -0700 Message-Id: <20190716213746.4670-3-robdclark@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190716213746.4670-1-robdclark@gmail.com> References: <20190716213746.4670-1-robdclark@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4drR0FDgR1qKvDPf6ArOgp5GWnRtGoeeH0ezG721TC0=; b=d0XRWLafSldOVujZRpCkAu9+YwaiUggcPzRRQGuqpuKlW6jllCs6aNRjoFTQhxg4W6 z7ImjRNh5QmIhLrvG3LhZo0PIw8SLsbPLLxFxaZOy4h7hkmlvhGkc1vtL4Gsa4mkCHz1 zJ+OWNjBPEuKNabEYJEFz46fx9LgdzRJWPcElIRSmJJG5lufLlzetP7GPCAmZHS6V2xl 2mxK1+ye+N5ayG7/d9N0ag+WZAL7AAonPq26ki8Ch07dIWP/z73zocHpTVI4WSb32Wj/ 4Wly/viUTLx9SnnoMfTR1xsYZJ0YcZ3G/B7jx6HPwUu0T3GhkwGGo8T1bQV9zgTEmpzR PxIA== Subject: [Intel-gfx] [PATCH v3 3/3] drm/vgem: use normal cached mmap'ings X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Deepak Sharma , Eric Biggers , David Airlie , Intel Graphics Development , linux-kernel@vger.kernel.org, Emil Velikov Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Clark Since there is no real device associated with VGEM, it is impossible to end up with appropriate dev->dma_ops, meaning that we have no way to invalidate the shmem pages allocated by VGEM. So, at least on platforms without drm_cflush_pages(), we end up with corruption when cache lines from previous usage of VGEM bo pages get evicted to memory. The only sane option is to use cached mappings. Signed-off-by: Rob Clark --- v3: rebased on drm-tip drivers/gpu/drm/vgem/vgem_drv.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index e7d12e93b1f0..84262e2bd7f7 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c @@ -259,9 +259,6 @@ static int vgem_mmap(struct file *filp, struct vm_area_struct *vma) if (ret) return ret; - /* Keep the WC mmaping set by drm_gem_mmap() but our pages - * are ordinary and not special. - */ vma->vm_flags = flags | VM_DONTEXPAND | VM_DONTDUMP; return 0; } @@ -310,17 +307,17 @@ static void vgem_unpin_pages(struct drm_vgem_gem_object *bo) static int vgem_prime_pin(struct drm_gem_object *obj, struct device *dev) { struct drm_vgem_gem_object *bo = to_vgem_bo(obj); - long n_pages = obj->size >> PAGE_SHIFT; + long i, n_pages = obj->size >> PAGE_SHIFT; struct page **pages; pages = vgem_pin_pages(bo); if (IS_ERR(pages)) return PTR_ERR(pages); - /* Flush the object from the CPU cache so that importers can rely - * on coherent indirect access via the exported dma-address. - */ - drm_clflush_pages(pages, n_pages); + for (i = 0; i < n_pages; i++) { + dma_sync_single_for_device(dev, page_to_phys(pages[i]), + PAGE_SIZE, DMA_BIDIRECTIONAL); + } return 0; } @@ -328,6 +325,13 @@ static int vgem_prime_pin(struct drm_gem_object *obj, struct device *dev) static void vgem_prime_unpin(struct drm_gem_object *obj, struct device *dev) { struct drm_vgem_gem_object *bo = to_vgem_bo(obj); + long i, n_pages = obj->size >> PAGE_SHIFT; + struct page **pages = bo->pages; + + for (i = 0; i < n_pages; i++) { + dma_sync_single_for_cpu(dev, page_to_phys(pages[i]), + PAGE_SIZE, DMA_BIDIRECTIONAL); + } vgem_unpin_pages(bo); } @@ -382,7 +386,7 @@ static void *vgem_prime_vmap(struct drm_gem_object *obj) if (IS_ERR(pages)) return NULL; - return vmap(pages, n_pages, 0, pgprot_writecombine(PAGE_KERNEL)); + return vmap(pages, n_pages, 0, PAGE_KERNEL); } static void vgem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) @@ -411,7 +415,7 @@ static int vgem_prime_mmap(struct drm_gem_object *obj, fput(vma->vm_file); vma->vm_file = get_file(obj->filp); vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; - vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); return 0; }