Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3518984pxf; Mon, 15 Mar 2021 11:20:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWrXmZDc9zpxURQLb1/nQ3ccKmJ1XV/QDq4FB4LqywyYPUbk3jmhDttDORoTBgyU/dfpOT X-Received: by 2002:a05:6402:12cf:: with SMTP id k15mr30668435edx.192.1615832446031; Mon, 15 Mar 2021 11:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832446; cv=none; d=google.com; s=arc-20160816; b=q0/c7wSo8AgboyBO4IHXE3Wu/xevsOp8LCla/9oQoj5sc5ti300xRVcu6PClkis5Ft 4FrlnvqRfKeyqyi90hlKsajB84iEbhCifzMJf31AR3f3huIQJSU0w88OJQ459S1XZafr 9xQZ2qtLzsiK+Gr2L+n2Z1WVgrXFQSQJwUZpt4/NDNMn40DkYizlqcgJZZEtOW0PPePl 132Us65dHANgEvKRlTivIiseL8iNB9epxebjmTGh84oY2iVOVxqfTPce63MDgSF37K9G pKHlKr3pHRg+xduyLyMtdf+Gj3Eh9dEI7TChP/FS1CnuZZp7LangrWa+3JoP+ZuoBMSr xIVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/d0V/KcM+6jMh2TyENESkfEShFqsapyMT7wyWlcFmh4=; b=KI0n+sPhUe1/wfMhCwnzmtIPsk37IU+SbnzgJSeFF5k71+ZTy9HDSDcjXwdQsEsW1s ypGVm8NvdCM+mt0ObwMxs3bqci3xfR93LxioX9B3fauUdX+93sn1sSuuYXO9rz9hXp7v jAxP72NzRdIQieZewQZzkE1SsLlzh4e1hDKt/ULrUAxTMeau5mCTZyaWKdZEAwhIV7Vm tugKjvzkUaioF1YzF/2KdwowOxbxGDCE7iv79e/nyRrqCRHan+3OfWb/id3yhKVpRIyI x8Yv4GQbxYstF8SkO15ZzKC7P1o4WgInegflniMwgADJv1ku8uLODO1UnMEbeu1Y/VYq lZmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZDwHe8Wj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si10840806eju.454.2021.03.15.11.20.23; Mon, 15 Mar 2021 11:20:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZDwHe8Wj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbhCOOTT (ORCPT + 99 others); Mon, 15 Mar 2021 10:19:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:35446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbhCON7s (ORCPT ); Mon, 15 Mar 2021 09:59:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 63FC364F38; Mon, 15 Mar 2021 13:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816756; bh=4Q0p/+jF15brPB709+DeieT+pei2ctwos3jXZVuZKwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZDwHe8Wj1r81/w7sGl+KmkJCOkKzRpXbSnb4n+OtCNrvdbNZmSw0LOQWoBc+duNN7 PAsDVmfDZeaTW6w/EwOLOUvpgu9aJT0DiBroiHLt3EfvhPDlOOybvLV00UbxFWyslQ y2YSOeqz5p5HSsTPbk9QEnpENyYQ+CbZ07UlMO5E= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Daniel Vetter , Thomas Zimmermann , Maarten Lankhorst Subject: [PATCH 5.10 096/290] drm/shmem-helpers: vunmap: Dont put pages for dma-buf Date: Mon, 15 Mar 2021 14:53:09 +0100 Message-Id: <20210315135545.164674055@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Noralf Trønnes commit 64e194e278673bceb68fb2dde7dbc3d812bfceb3 upstream. dma-buf importing was reworked in commit 7d2cd72a9aa3 ("drm/shmem-helpers: Simplify dma-buf importing"). Before that commit drm_gem_shmem_prime_import_sg_table() did set ->pages_use_count=1 and drm_gem_shmem_vunmap_locked() could call drm_gem_shmem_put_pages() unconditionally. Now without the use count set, put pages is called also on dma-bufs. Fix this by only putting pages if it's not imported. Signed-off-by: Noralf Trønnes Fixes: 7d2cd72a9aa3 ("drm/shmem-helpers: Simplify dma-buf importing") Cc: Daniel Vetter Cc: Thomas Zimmermann Acked-by: Thomas Zimmermann Tested-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/20210219122203.51130-1-noralf@tronnes.org (cherry picked from commit cdea72518a2b38207146e92e1c9e2fac15975679) Signed-off-by: Thomas Zimmermann Signed-off-by: Maarten Lankhorst Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_gem_shmem_helper.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -340,13 +340,14 @@ static void drm_gem_shmem_vunmap_locked( if (--shmem->vmap_use_count > 0) return; - if (obj->import_attach) + if (obj->import_attach) { dma_buf_vunmap(obj->import_attach->dmabuf, shmem->vaddr); - else + } else { vunmap(shmem->vaddr); + drm_gem_shmem_put_pages(shmem); + } shmem->vaddr = NULL; - drm_gem_shmem_put_pages(shmem); } /*