Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1647673rdb; Thu, 25 Jan 2024 01:50:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXCZIujyCZUER/bxv3OhJmU9UN4o2JKUsVLr3wqU3S8Vex6Gj7fuFVYjQh9RSKpFaS3XJ6 X-Received: by 2002:a05:6402:221a:b0:55a:6f4b:27cc with SMTP id cq26-20020a056402221a00b0055a6f4b27ccmr438062edb.44.1706176216656; Thu, 25 Jan 2024 01:50:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706176216; cv=pass; d=google.com; s=arc-20160816; b=XHBERzUZGxcajlehqp163Oxh9RShddBIGN8RcS/Bi//brdxg4wSbJKJfJZ0sE+IFEf qU2/x64tSz1lMxsBDcnnic8Vsxpx67w8dQMEtIEbL3wtyTGWxYZ4N2kmVrWtxofBEX+5 jd4ibfqzwMm5vd1P6dE1+oB3UgMYj3eUowtdov4aRtW0YKD/n5Z60A7htUVqOGaFZpxY 1/zpr3rMFZHg2ki82XoNIREr/1RT6etFfD/CB28ly5nQ+KEL4DJvwWtfb+osdD9E/7lx pEGNs5YhLCL/ADqzYHIRYt36GrXulEcbiBvA/IU+0RTMfTrggVeFthfIkDHkYt2SVc6/ oSEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=mn6ijKKBstx//R1yjk+No+1Nxeit5VKF/W6lTpv7xBk=; fh=uxLNaPoPRUzmkUc1KOgGwCEU/bTSjK8Yed2Up6ovXLY=; b=Uqz6vc7X5faIlCCNkgdk5K6K+HAnRXt8bXFIGaeDffp0gfFkoCkQ/Ww4f1l26+HgMD /WGSNMe88VRdjlkatacxUBSeluNZAtsh4vYvI1Xau58VxAObF2dPs8PTuE5o5kdNvA6p nbly1ikgAhiGebmk9WzI+5JJoaCOfelGM6KD1QCFe8J9R6UXx8YaMems5D9z0R7QODyb f/SSwxwwnKL2bkvKzdly1VuuJ8FPuZ79/COR54DKnCvNk/7oU4RMbc4TDdjcyUeBrCAS XJOP+d5Y4E+jx4xjeQSE0Irop8I2idAimpgXOldE/x8EZ0t0KGOVIFv/+qAVVArbjLV5 UwVw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EZ6y5rx1; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-38328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38328-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id eo11-20020a056402530b00b0055cece62afbsi721164edb.361.2024.01.25.01.50.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 01:50:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EZ6y5rx1; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-38328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38328-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6C67F1F337EF for ; Thu, 25 Jan 2024 09:50:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F13B01CAB9; Thu, 25 Jan 2024 09:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="EZ6y5rx1" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 867E91CA9C for ; Thu, 25 Jan 2024 09:49:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706176178; cv=none; b=sHECxM+ulJpOsiqy50ev+gzYYf8M88nxGZRjeHBvPMLIDvG5LSUBe8tEzzF0n2lzeBLjnYZEl72ohJZ2aNanIw+vo/FvIcd97aCbVT3RXCTPkZCqfGd2BEn5LP4ndWxjdQVf1CrHpCvS1mv4MMdZHWBegdcHmmO3x5eTOdM+KXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706176178; c=relaxed/simple; bh=HQx2vEMacjNLr6cTRRgLHLZqhvtOE96szsA/LVX4JrE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=At8eJi7MzOoe57CxXnFwLnBkAE01YEx1b/KVpUQDLyhT+9pqfFsEL54a8DsKFGPXFYrp8J0TQWoWcV7LmV5gqDYSTDWY1FxZaaYlCyvdXiBsrw4ZWLBXEDUkTAmzZn8DlibB8ALeSEe6I+fQyH8Q8Oqq9ctYUmxL/uZsogvHV0k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=EZ6y5rx1; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706176174; bh=HQx2vEMacjNLr6cTRRgLHLZqhvtOE96szsA/LVX4JrE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EZ6y5rx1rs5c/H1Mm5/WsPYmq072lDVv3g4/azho/BQI+gfL1X1NdLC661txD6EK9 NAtmw11ItXkVCKOADazT/9RgJ7CfgKx5LmsP5n4gqoptftm45qdLmJGHka4cMQcx4K EfUVcWmj2pfFcuFQy+qN+wGvbmVV1BF/WWhH3cHRkNidNhZXTgnEaEUKmf3LkvQ0Yb IfIaWiqixDZxjjIdHqGyvU+FZ7MCGImiwmhw32rXbti9wh2NqyDBvijJ6Gy7Lfssx7 +g2FY1QtkqRvY1gbSE7+o4XOtXnq8clp3eCs9Gkf0+BeWwtYG4KnAiiRvWbzVxh8PH e35ZZEFEDtyHg== Received: from localhost (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by madrid.collaboradmins.com (Postfix) with ESMTPSA id A79D6378000B; Thu, 25 Jan 2024 09:49:33 +0000 (UTC) Date: Thu, 25 Jan 2024 10:49:32 +0100 From: Boris Brezillon To: Dmitry Osipenko Cc: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Christian =?UTF-8?B?S8O2bmln?= , Qiang Yu , Steven Price , Emma Anholt , Melissa Wen , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v19 30/30] drm/panfrost: Switch to generic memory shrinker Message-ID: <20240125104932.478fa5bd@collabora.com> In-Reply-To: <20240105184624.508603-31-dmitry.osipenko@collabora.com> References: <20240105184624.508603-1-dmitry.osipenko@collabora.com> <20240105184624.508603-31-dmitry.osipenko@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 5 Jan 2024 21:46:24 +0300 Dmitry Osipenko wrote: > --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c > +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c > @@ -328,6 +328,7 @@ int panfrost_mmu_map(struct panfrost_gem_mapping *mapping) > struct panfrost_device *pfdev = to_panfrost_device(obj->dev); > struct sg_table *sgt; > int prot = IOMMU_READ | IOMMU_WRITE; > + int ret = 0; > > if (WARN_ON(mapping->active)) > return 0; > @@ -335,15 +336,32 @@ int panfrost_mmu_map(struct panfrost_gem_mapping *mapping) > if (bo->noexec) > prot |= IOMMU_NOEXEC; > > + if (!obj->import_attach) { > + /* > + * Don't allow shrinker to move pages while pages are mapped. > + * It's fine to move pages afterwards because shrinker will > + * take care of unmapping pages during eviction. > + */ That's not exactly what this shmem_pin() is about, is it? I think it's here to meet the drm_gem_shmem_get_pages_sgt() rule stating that pages must be pinned while the sgt returned by drm_gem_shmem_get_pages_sgt() is manipulated. You actually unpin the GEM just after the mmu_map_sg() call, which means pages could very well be reclaimed while the MMU still has a mapping referencing those physical pages. And that's fine, because what's supposed to protect against that is the fence we register to the GEM resv at job submission time. > + ret = drm_gem_shmem_pin(shmem); > + if (ret) > + return ret; > + } > + > sgt = drm_gem_shmem_get_pages_sgt(shmem); > - if (WARN_ON(IS_ERR(sgt))) > - return PTR_ERR(sgt); > + if (WARN_ON(IS_ERR(sgt))) { > + ret = PTR_ERR(sgt); > + goto unpin; > + } > > mmu_map_sg(pfdev, mapping->mmu, mapping->mmnode.start << PAGE_SHIFT, > prot, sgt); > mapping->active = true; > > - return 0; > +unpin: > + if (!obj->import_attach) > + drm_gem_shmem_unpin(shmem); > + > + return ret; > }