Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3519158pxf; Mon, 15 Mar 2021 11:21:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnbcv42jDaS5IvcrY+6ils8Vq2heEHayazctzz61e0z9A09kPm8mY74/HL4dRyIWPUvV5b X-Received: by 2002:a17:906:3952:: with SMTP id g18mr9407382eje.104.1615832462094; Mon, 15 Mar 2021 11:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832462; cv=none; d=google.com; s=arc-20160816; b=ZNVtvX+1XTOiLg1YUvl6/TDr1MYKaJznOjiKLOW+Eh1UliuVrhrCB6U06RetCTcEjf e7yQWPxxm0IvHBSaZSgLZKNpKdaCFwm8yWGzbt6GLQZ0iguo1V+oXP9bOOcBrnPDchdG 0/mwofBF+ujgd0dEZ2PGGpd4poc9cVmRRzkhmxfbDeawwx+OmZBLsYhONp3EB4hcn1dd f7GI4d54CqGduJVRrJIvm0yWyCjC5EoP3V/mkj9EpyMMZImPHUvA0Xe8SQl2odL7jVLy SBcl025KTrgYgvGLyDm5+r8DFZJP6oApk06bDtmORK/DLe6c0RquLz+rsxKPPCCH9N5W FVfA== 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=1hd1AwOWZ+HhOKHcmRnQozL3ITirnc0QIRL0ipZ1Xwg=; b=u5rB9pGWBVoDj5zKPHkijrgUpxXctKpWLTanNPzVcgm9qF4H5316xPUnBPvDzcHtY0 Y1MbKqmyYDQrYzyAdeigXNRf3EAmORWJeGyLnOz2TXt+zJWfct+AKITxwW3rS6mhuIgj YIv2laFCjqx1btKKwF7a7GvcGJvciEjoUxdHPaIO1jDsn8BQlOeRLozlAeRbWEm6pQY7 K+wODt0ec6bHp+Y+CiWJocm+8Xh80NnrwrnfziBSsuOVGh9cSiLZ8QOaLpWa9Bq86pg1 lDkO3NpROMppg9kngqmuvLWWiIsLLa5SyzWM6mdy/BK0efc5bg6MTlFf21znCuD4SV52 jPHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NagDYlMU; 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 gr2si11689173ejb.65.2021.03.15.11.20.39; Mon, 15 Mar 2021 11:21:02 -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=NagDYlMU; 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 S237499AbhCOOR5 (ORCPT + 99 others); Mon, 15 Mar 2021 10:17:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:36764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231673AbhCON7k (ORCPT ); Mon, 15 Mar 2021 09:59:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 01FF164F07; Mon, 15 Mar 2021 13:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816763; bh=+6XnFK6k1kgA4CbStrWf4Fa4e0eBbvtL+qYw5ciU/Ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NagDYlMUm4j0050NBeN0eXe+fQxQOKeDqyp1mScfC10pFCAEUpRA6GRT5OJdLx3oj QBDou6/VKVqkCWPIdB3SFjtFz+YPQRQ1raEH0DXVK1e5qxD6w1fw11fMreaPAVOV5Y kLNmsBqcYi7eb4ee5NNuavFC0bB7EgcsueduzEjw= 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.11 110/306] drm/shmem-helpers: vunmap: Dont put pages for dma-buf Date: Mon, 15 Mar 2021 14:52:53 +0100 Message-Id: <20210315135511.364599516@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 @@ -357,13 +357,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, map); - else + } else { vunmap(shmem->vaddr); + drm_gem_shmem_put_pages(shmem); + } shmem->vaddr = NULL; - drm_gem_shmem_put_pages(shmem); } /*