From patchwork Thu May 14 20:22:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11549735 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71FBA912 for ; Thu, 14 May 2020 20:23:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4FC38206D8 for ; Thu, 14 May 2020 20:23:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="b9EI9yfm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FC38206D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 02CD86E0AD; Thu, 14 May 2020 20:23:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2BAB56E0AD for ; Thu, 14 May 2020 20:23:04 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id g12so34656534wmh.3 for ; Thu, 14 May 2020 13:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JRs5CU7GCWwRnWiOKlI7YecBg0ycRjhicdBVLDNYVWw=; b=b9EI9yfm8lf+BKEol4YcKL97AJBGzIC4lzcoGXYXQOYsVy8XS+kA3WdEqJGO0QEK5d a8Tq0Y4FI+yb3jFB2/7ySUIRU3FTAY7qtdb4QLNFwHrqk7plBpbhb7Lw1858qs/v8QLs KaEIgd32kLkS3LcOjpKRhghq4Igmsp3OugipA= 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=JRs5CU7GCWwRnWiOKlI7YecBg0ycRjhicdBVLDNYVWw=; b=nXXRtdr876Bv0+kJmOqEbVoavC3+jUBTw4jpxiqFUB1AYE/q01uWt0r0NFn7tIkn5y Td9SSJg55nBB7u9aH00SsL2hH/ZQppotZ0wrgSsDLvC+WtXZHM/OQEIEoKU2pLO3/6tv lodvBqdFRR3wSkY3k2IxgL3fn8P7pNIk1FAEOUtuxA00gorMXq3PletexsymF+/1vmRB cC3NSIkhV1kQYX3KxhRIOcdAaFgif6OT0ibbvHeAzPY13RQ307BU4g963pz62pNbMkHi zCYrg5XOm+DHwbjJ5UDrv8rpcJpo5kND1MnlyozUltQXjVynYdw2ozkvZyFgLd8V8lRN IE2Q== X-Gm-Message-State: AOAM533xapQ82Mzb08wsYGKKoUh5MzgxD4UspLarBNdWmJhkJaPtV6RN dheYXWgUzpbZv9SEYB//rC2Vy09l2Zc= X-Google-Smtp-Source: ABdhPJzyccl1mV4XJi4CbAsEjT1XeZQpj4rVc0OF0ECx7sS1tHHeaPkzaLfT0/cJnWDnCp+YysvsvQ== X-Received: by 2002:a05:600c:230e:: with SMTP id 14mr95650wmo.45.1589487782556; Thu, 14 May 2020 13:23:02 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id l18sm263837wmj.22.2020.05.14.13.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 13:23:01 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm/shmem-helpers: Don't call get/put_pages on imported dma-buf in vmap Date: Thu, 14 May 2020 22:22:56 +0200 Message-Id: <20200514202256.490926-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.26.2 In-Reply-To: <6910cb3c-7169-fe1c-efc1-3acb8a218384@suse.de> References: <6910cb3c-7169-fe1c-efc1-3acb8a218384@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Gerd Hoffmann , Thomas Zimmermann , Daniel Vetter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There's no direct harm, because for the shmem helpers these are noops on imported buffers. The trouble is in the locks these take - I want to change dma_buf_vmap locking, and so need to make sure that we only ever take certain locks on one side of the dma-buf interface: Either for exporters, or for importers. v2: Change the control flow less compared to what's there (Thomas) Cc: Thomas Zimmermann Cc: Gerd Hoffmann Cc: Rob Herring Cc: Noralf Trønnes Acked-by: Thomas Zimmermann Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_gem_shmem_helper.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 2a70159d50ef..9540478e0434 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -252,15 +252,15 @@ static void *drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem) if (shmem->vmap_use_count++ > 0) return shmem->vaddr; - ret = drm_gem_shmem_get_pages(shmem); - if (ret) - goto err_zero_use; - if (obj->import_attach) { shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf); } else { pgprot_t prot = PAGE_KERNEL; + ret = drm_gem_shmem_get_pages(shmem); + if (ret) + goto err_zero_use; + if (!shmem->map_cached) prot = pgprot_writecombine(prot); shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT, @@ -276,7 +276,8 @@ static void *drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem) return shmem->vaddr; err_put_pages: - drm_gem_shmem_put_pages(shmem); + if (!obj->import_attach) + drm_gem_shmem_put_pages(shmem); err_zero_use: shmem->vmap_use_count = 0;