From patchwork Mon Feb 27 06:02:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 61739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2255370wrd; Sun, 26 Feb 2023 22:06:01 -0800 (PST) X-Google-Smtp-Source: AK7set9DNXg8isJIkygNJFpwHOaST/XuEwPXKPKJ9KO/xs9ZNiUOJTe+QU6PLvW/jvS26PZRUTzc X-Received: by 2002:a17:907:75e9:b0:86f:b99c:ac8d with SMTP id jz9-20020a17090775e900b0086fb99cac8dmr30022837ejc.44.1677477961475; Sun, 26 Feb 2023 22:06:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677477961; cv=none; d=google.com; s=arc-20160816; b=xeDU05gqWlsy3qgrD97OfHUwoe5B54PNwetlmdXBCEruVUABHhEtyDlQjTmgO49dkA RI3faHoWfLVzqbo+KWPcSiFvcDYfW4jR1O3ZfOtmSkPMORLuBeeYGGvscg6N+ZwbFz2j lTuc45GmWX3Iznd0RJSgECVd5XjeArmdnQDOMCwHdcav17GFZaivVKWolasPA20CGd1f FlNpbAGuVCp8SnyJYTpgTLPNyMKgxuoiW229rJNyB4pWOboRDsqpbXKzq/BpkM6VCyDw IpLB+q3qOTUhyTIYEF+L41nbgO2XUr6//DqdLK8Btd3mHhkpOQlp9+aTF4HaT5QRjNwn wZrw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7xs1etOnNOodSt6Bzn86Lf/P1VbnY0HORQPBcg3YRAs=; b=d0TTpR2Y/tuNfQS9/98mvqivHTKsTeiE2x3awteO31iwgIV3eat5iSLDsQmkyRWtNF +Tavjs1ieouMgmYMsgxB0z8rPbxw9QQeJKCWqDHcto7CfDSb3yDQ0ARtfg9h8ggg9UA3 xCuwBA3yxhnSlKnG3yvYurZuE+FWKzMIzXHPf8Vd0JShz/FcXhiueS2fxAv3/LjFCGTF csC/0MiP5eQfwvJrSfMUwtCY2sC/omgAWrfIFhEQV+CgAooNsAHuJwOcwkvgDrmhyRsY Onmpuy/A2+lrOJtvpklgTPd+tQBPP/iXo7i8pQzjulARs7RfOqrgU0SBeO42m76Zg8ET /h3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TRexFYfM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a170906600f00b008d68d018141si5735392ejj.402.2023.02.26.22.05.39; Sun, 26 Feb 2023 22:06:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TRexFYfM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbjB0GDb (ORCPT + 99 others); Mon, 27 Feb 2023 01:03:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbjB0GDR (ORCPT ); Mon, 27 Feb 2023 01:03:17 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39EAA5C6 for ; Sun, 26 Feb 2023 22:03:09 -0800 (PST) Received: from workpc.. (109-252-117-89.nat.spd-mgts.ru [109.252.117.89]) (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: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id DF9986602CEE; Mon, 27 Feb 2023 06:03:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1677477788; bh=RC/OqRUY9IcjI/95DJDJLW/5aJlYWOkRZhNC1rLGKS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TRexFYfMG4ozQRYEkKuKKl4j2/SOF9MjJmwjYY/nKYIv2bwoUt5mNbFbXUBsXiDOU 53oOY+6zaBM4wPHqfn81wHEjHndc2AjHuTaGOxJe7TE4kJaJ3CX/6TFrRw3cf4fvne sp/CZh9Abu+Jd/PBiQYPoq4bbh+36m04lVWlp1/B9JTaRL0iNdJFsgoRVaLziCl4af gmvtA0Yju0aAAxuOtbewTWfnJ0NWZfmPFWlZMelaq0JZK9TorFNHbEXqcOe7CGfZn6 Jqe9zrV86YWXgM4sUjKaa4P/dsfk8EpQN48FWD1VaS4fVnxtjusK8Qf2azcHezB7K3 r+vbvELY/0GYw== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gustavo Padovan , Daniel Stone , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Qiang Yu , Steven Price , Alyssa Rosenzweig , Rob Herring Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: [PATCH v11 03/10] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin Date: Mon, 27 Feb 2023 09:02:12 +0300 Message-Id: <20230227060219.904986-4-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230227060219.904986-1-dmitry.osipenko@collabora.com> References: <20230227060219.904986-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758963131193484862?= X-GMAIL-MSGID: =?utf-8?q?1758963131193484862?= The vmapped pages shall be pinned in memory. Previously get/put pages were implicitly pinning/unpinning the pages. This will no longer be the case with addition of memory shrinker because pages_use_count>0 won't determine whether pages are pinned anymore, while the new pages_pin_count will do that. Switch the vmap/vunmap to use pin/unpin functions in a preparation of addition of the memory shrinker support. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 97b40676bdfa..2b1eef335bf6 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -357,7 +357,7 @@ int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, return 0; } - ret = drm_gem_shmem_get_pages(shmem); + ret = drm_gem_shmem_pin(shmem); if (ret) goto err_zero_use; @@ -380,7 +380,7 @@ int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, err_put_pages: if (!obj->import_attach) - drm_gem_shmem_put_pages(shmem); + drm_gem_shmem_unpin(shmem); err_zero_use: shmem->vmap_use_count = 0; @@ -417,7 +417,7 @@ void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, return; vunmap(shmem->vaddr); - drm_gem_shmem_put_pages(shmem); + drm_gem_shmem_unpin(shmem); } shmem->vaddr = NULL;