From patchwork Fri Jan 8 09:43:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 359365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50E14C433E0 for ; Fri, 8 Jan 2021 09:45:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD3DD233EA for ; Fri, 8 Jan 2021 09:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728009AbhAHJpJ (ORCPT ); Fri, 8 Jan 2021 04:45:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:36772 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727649AbhAHJpJ (ORCPT ); Fri, 8 Jan 2021 04:45:09 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0A672AFA8; Fri, 8 Jan 2021 09:43:47 +0000 (UTC) From: Thomas Zimmermann To: sumit.semwal@linaro.org, christian.koenig@amd.com, airlied@redhat.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, kraxel@redhat.com, hdegoede@redhat.com, sean@poorly.run, eric@anholt.net, sam@ravnborg.org Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, virtualization@lists.linux-foundation.org, Thomas Zimmermann Subject: [PATCH v4 05/13] drm/mgag200: Use drm_gem_shmem_vmap_local() in damage handling Date: Fri, 8 Jan 2021 10:43:32 +0100 Message-Id: <20210108094340.15290-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108094340.15290-1-tzimmermann@suse.de> References: <20210108094340.15290-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Damage handling in mgag200 requires a short-term mapping of the source BO. Use drm_gem_shmem_vmap_local(). Signed-off-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/mgag200/mgag200_mode.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 1dfc42170059..a33e28d4c5e9 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1552,22 +1552,32 @@ mgag200_handle_damage(struct mga_device *mdev, struct drm_framebuffer *fb, struct drm_rect *clip) { struct drm_device *dev = &mdev->base; + struct drm_gem_object *obj = fb->obj[0]; struct dma_buf_map map; void *vmap; int ret; - ret = drm_gem_shmem_vmap(fb->obj[0], &map); + ret = dma_resv_lock(obj->resv, NULL); if (drm_WARN_ON(dev, ret)) - return; /* BUG: SHMEM BO should always be vmapped */ + return; + ret = drm_gem_shmem_vmap_local(obj, &map); + if (drm_WARN_ON(dev, ret)) + goto err_dma_resv_unlock; /* BUG: SHMEM BO should always be vmapped */ vmap = map.vaddr; /* TODO: Use mapping abstraction properly */ drm_fb_memcpy_dstclip(mdev->vram, vmap, fb, clip); - drm_gem_shmem_vunmap(fb->obj[0], &map); + drm_gem_shmem_vunmap_local(obj, &map); + dma_resv_unlock(obj->resv); /* Always scanout image at VRAM offset 0 */ mgag200_set_startadd(mdev, (u32)0); mgag200_set_offset(mdev, fb); + + return; + +err_dma_resv_unlock: + dma_resv_unlock(obj->resv); } static void