From patchwork Mon Feb 27 06:02:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 5883 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2255193wrd; Sun, 26 Feb 2023 22:05:32 -0800 (PST) X-Google-Smtp-Source: AK7set8SvGQJQ23KtSR9vuqEFpoENtTYZhBNrcfGYqmfEDxZm/ObJYsMvvKiGcHZNnBRT1IJ/Ztd X-Received: by 2002:a17:906:13d7:b0:88d:f759:15ae with SMTP id g23-20020a17090613d700b0088df75915aemr34503742ejc.42.1677477932413; Sun, 26 Feb 2023 22:05:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677477932; cv=none; d=google.com; s=arc-20160816; b=JAMznypudYVoWPBrQe7ihSlQH6iM++i6/2fk1xgsxs+lp21nBVl624isHxoQtN259I INZUGtpC7lPUytsrlUrCQejVU65lONXdJkaF6RvHyo3w4T0neOzixrOwLcOArjDaFMDL FwfXFUDHB/JDS/yTakDyi3+TnZENWxvGJY8d387mHFnX1VA2IzE1K0JVwL4D52r2NBXs PBZGTfxy56vhCYRDuAoRnPY0SJqbvUb0IG9m0JICrIkSeHBU6YtNXvvFg6nHDC1KPilw lBQqCfWETy5ntg1fl0UHS8ZTAUgPFs4zHEf/2MQtFMj8okLLy/aaL9wi+IR2T7cHhgxj n+iw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=LkBXL3tCyUbziu4rqAWg+n9g58y/e8yJy6DtbjR2ipk=; b=knOsddxVK69f07b/ujZ0uLILrIKkDft0fyswskE9kLkQ4mRZs+3SybFe+Hm2ac1LjQ dnYkt1K4Eo+kw/EHLfqEZgqw1HNle8zL3sKG22CJ6eCiyXUn3qZMcSwnruPrzNFwxVlP Chtqu36La+f57lCOoMKsdU7Ifp04kAdl0Je6Jm5L2vtfyM/G2vGYerUib5QPzCWxQ4C2 mZXT0x/qRoOzubBFiKFIWaRqdR0wZmlg+LSjUaOAT/smx9TD/2gOPV78WTOZ5+oJiCIx qrwAOxQJQ90JC/5TM87aYuE5Z8jq/JwFcSldINdRBza/96rooNzpH+nEc3bb7nbG5YMJ 1JuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Ab/TyKNN"; 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 a6-20020a1709064a4600b008cd21ca9c7fsi6890455ejv.619.2023.02.26.22.05.09; Sun, 26 Feb 2023 22:05:32 -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="Ab/TyKNN"; 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 S229790AbjB0GDK (ORCPT + 99 others); Mon, 27 Feb 2023 01:03:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbjB0GDI (ORCPT ); Mon, 27 Feb 2023 01:03:08 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 910BA3C07 for ; Sun, 26 Feb 2023 22:03:05 -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 EB83C6602219; Mon, 27 Feb 2023 06:03:01 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1677477783; bh=TtMlJSYZlFYIliVjyv4XDKpNgDOHPfLPGOE0yp3Wc50=; h=From:To:Cc:Subject:Date:From; b=Ab/TyKNN3wPdBRfE7+D7g2uwqN/LH0LHpCWx3xtx/nLNDD2+eySmodOaQSGmSQceh 403hMA/EljYyoNbunZYLBfRNvapnnerqXNo874kLxjJ3KdaYUSOIfIBTnB92WdaXdk cNWwKgpy/QoMEg+0X3Uau0spRlut4VRkm7Bam0Ue8rqxya30lAwl3cdhKykGX+/LWU 3ilFRWJm/qGLmvYM9d30UYFCNgD8Y3/OCsJpH5PndWJUPTYLYq1AUd6s4MhdY6fMnU cbu8sZvYk8I/xG7Qubya46aYpYsxAddwqYOpUvUiRHTumr5JL2rOb8PE7oJTqiWiY3 cK+0/XNbVS+Gg== 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 00/10] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Date: Mon, 27 Feb 2023 09:02:09 +0300 Message-Id: <20230227060219.904986-1-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.39.2 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?1754489941846118559?= X-GMAIL-MSGID: =?utf-8?q?1758963100549552837?= This series: 1. Adds common drm-shmem memory shrinker 2. Enables shrinker for VirtIO-GPU driver 3. Switches Panfrost driver to the common shrinker Changelog: v11:- Rebased on a recent linux-next. Added new patch as a result: drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() It's needed by the virtio-gpu driver to swap-in/unevict shmem object, previously get_pages_sgt() didn't use locking. - Separated the "Add memory shrinker" patch into smaller parts to ease the reviewing, as was requested by Thomas Zimmermann: drm/shmem-helper: Factor out pages alloc/release from drm_gem_shmem_get/put_pages() drm/shmem-helper: Add pages_pin_count field drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin drm/shmem-helper: Factor out unpinning part from drm_gem_shmem_purge() - Addessed the v10 review comments from Thomas Zimmermann: return errno instead of bool, sort code alphabetically, rename function and etc minor changes. - Added new patch to remove the "map->is_iomem" from drm-shmem, as was suggested by Thomas Zimmermann. - Added acks and r-b's that were given to v10. v10:- Was partially applied to misc-fixes/next. https://lore.kernel.org/dri-devel/6c16f303-81df-7ebe-85e9-51bb40a8b301@collabora.com/T/ Dmitry Osipenko (10): drm/shmem-helper: Factor out pages alloc/release from drm_gem_shmem_get/put_pages() drm/shmem-helper: Add pages_pin_count field drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin drm/shmem-helper: Factor out unpinning part from drm_gem_shmem_purge() drm/shmem-helper: Add memory shrinker drm/shmem-helper: Remove obsoleted is_iomem test drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() drm/gem: Add drm_gem_pin_unlocked() drm/virtio: Support memory shrinking drm/panfrost: Switch to generic memory shrinker drivers/gpu/drm/drm_gem.c | 29 ++ drivers/gpu/drm/drm_gem_shmem_helper.c | 453 ++++++++++++++++-- drivers/gpu/drm/panfrost/Makefile | 1 - drivers/gpu/drm/panfrost/panfrost_device.h | 4 - drivers/gpu/drm/panfrost/panfrost_drv.c | 27 +- drivers/gpu/drm/panfrost/panfrost_gem.c | 30 +- drivers/gpu/drm/panfrost/panfrost_gem.h | 9 - .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 122 ----- drivers/gpu/drm/panfrost/panfrost_job.c | 18 +- drivers/gpu/drm/virtio/virtgpu_drv.h | 18 +- drivers/gpu/drm/virtio/virtgpu_gem.c | 52 ++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 37 ++ drivers/gpu/drm/virtio/virtgpu_kms.c | 8 + drivers/gpu/drm/virtio/virtgpu_object.c | 137 ++++-- drivers/gpu/drm/virtio/virtgpu_plane.c | 22 +- drivers/gpu/drm/virtio/virtgpu_vq.c | 40 ++ include/drm/drm_device.h | 10 +- include/drm/drm_gem.h | 3 + include/drm/drm_gem_shmem_helper.h | 69 ++- include/uapi/drm/virtgpu_drm.h | 14 + 20 files changed, 857 insertions(+), 246 deletions(-) delete mode 100644 drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c