Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4577680pxj; Wed, 12 May 2021 08:32:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWD2YWJ+Awnnf8oqhz5mVIhKaF0/oab1i0N+ilXQaL2cUqpu8Ax6bBU/RvbmYJ4oAmK88R X-Received: by 2002:aca:4749:: with SMTP id u70mr1107944oia.37.1620833577992; Wed, 12 May 2021 08:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620833577; cv=none; d=google.com; s=arc-20160816; b=tnT5yFMzastf+yySH8/QE/2bmYDT00YjbQVV3gJsYMxGT+oQ3TZfrAo1lGodo52fnZ 6GslqIScaX0ob263yTArIXxXV0ljq9HeFkJ6FlZBF7Kul0UjzcDBfovWq5uSOzWqf/R5 10gOlaWR4OWAaZWEiRSzdrGWGgI24bR8G4Gj1JDhObOwGNyN/hHH0D7fldV6OhC6a30q uBMWBTSMzV/CP0zjYEGzPtOJ4v9ONEjdrV6ZMXuXoXDXtPWLXnwVqftxYiMLRGeGNgV3 OC8iN9+I4PO1/wv/jj2Xbv459riJd6jag7MjJ3W0kD0m3nr2DOTpcTUGtqbZ1Yb8/VXj WkGQ== 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=lCW2AfAaYZ+8Z8J9PA5PSvAldMZnhpKAynlkmB9Wj30=; b=nBHu7AU4oYJbRttkMHpRKzKYxTNN6CBfmNNLbLP+XiPZgmzUS1lemFkKYhPhPhIwn5 lqhv4bzib2jkFm49KBV6erwWHKri6RXD4zj2mV87Ynys0dJUSCcFeKbweTxiQZJxLRXz rRHzICoeHebPme65QqA1JdZ3jPVazpjpPWv6kYo8R3nIBDnuOkX2HfaxwxCjTFqMBaf7 l/9XJzAbM0ylgoNG0XoK7uiGZOVnaNEgH4G98yO7Te/USS1IdQCKiTLxj7W4sB0gIB5l p1bLlXbaAx/0qD6DoTs39ua4FYZD5LBSp6ySq0824lHRVJxhGueSGylmw/Gs1K+gzfi+ 9jlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EeguTN0u; 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 k6si288082oiw.109.2021.05.12.08.32.43; Wed, 12 May 2021 08:32:57 -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=EeguTN0u; 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 S234174AbhELPcQ (ORCPT + 99 others); Wed, 12 May 2021 11:32:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:50640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233922AbhELPPc (ORCPT ); Wed, 12 May 2021 11:15:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 05239613EB; Wed, 12 May 2021 15:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831909; bh=muvyX4utlmUr7p5OAd0hq0r9ApdqIoD/5RVCYCUIPLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EeguTN0uOzW9eoY3Y2jjsgT8iW4NVNi0RopS2MU9zmxZeINEt9YL/X+Nl53M5PQzI vh/JCPsP8TB0OLTICJGNRynLaVkEQIYbmEb8/d+EB77lPvDkK5lv4jZGOw5DpfSsE6 Vw0SczZL6rpuokuqtaWwZtDT5ttaS9Q3D2q1XPEE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Brezillon , Steven Price Subject: [PATCH 5.10 063/530] drm/panfrost: Dont try to map pages that are already mapped Date: Wed, 12 May 2021 16:42:53 +0200 Message-Id: <20210512144821.828427065@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Boris Brezillon commit f45da8204ff1707c529a8769f5467ff16f504b26 upstream. We allocate 2MB chunks at a time, so it might appear that a page fault has already been handled by a previous page fault when we reach panfrost_mmu_map_fault_addr(). Bail out in that case to avoid mapping the same area twice. Cc: Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations") Signed-off-by: Boris Brezillon Reviewed-by: Steven Price Link: https://patchwork.freedesktop.org/patch/msgid/20210205111757.585248-3-boris.brezillon@collabora.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -495,8 +495,14 @@ static int panfrost_mmu_map_fault_addr(s } bo->base.pages = pages; bo->base.pages_use_count = 1; - } else + } else { pages = bo->base.pages; + if (pages[page_offset]) { + /* Pages are already mapped, bail out. */ + mutex_unlock(&bo->base.pages_lock); + goto out; + } + } mapping = bo->base.base.filp->f_mapping; mapping_set_unevictable(mapping); @@ -529,6 +535,7 @@ static int panfrost_mmu_map_fault_addr(s dev_dbg(pfdev->dev, "mapped page fault @ AS%d %llx", as, addr); +out: panfrost_gem_mapping_put(bomapping); return 0;