From patchwork Wed Nov 23 02:57:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 2084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2561172wrr; Tue, 22 Nov 2022 19:02:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4gcIpVAkEHQtoEDxpJWEFEFbD4CXTEIa1HkUKPX2pnQwGCtCbefSpHDRImjJK4mr2mhj7j X-Received: by 2002:aa7:cad7:0:b0:459:443a:faf4 with SMTP id l23-20020aa7cad7000000b00459443afaf4mr24042357edt.297.1669172524612; Tue, 22 Nov 2022 19:02:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669172524; cv=none; d=google.com; s=arc-20160816; b=XSaxSPp5DuiRYita1aA+46aIoVzG6IcOCx4zUJCmyXWvCcjlzk93C+R2mfeK8oRLjW oYniA/fwsqK7dWbJykSSG1lJZUxLu4lEuwNiqWWyftIqMw39QCJQ86KhrbO8BjJ/SziR RMEyCwyuw1Qr9c2JLTmacINh+nZQSnLz/dFMoA9PB9Zea53umXx+Fh54amJCPbzfFonR MwKzZMBUtEc/I0G9tQ/f/TlKZDBlUAtg0gL/ZSGD60Yk4G1ECDl64bnISzaJIyzEgHw2 /OHKNZ6vNLLJ8v/WBCdS2H0iK08Iwh8fpIMH88Xe5Pl3mAALhKPIYtm2Wnv17O/0x0G9 9nYQ== 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=S7mnnr5E834R09zt3I9M9nSKGEtqaQ5hh7qjcRDxGYw=; b=esL6TO9hCTNvOX1f/WP5TBiwd+yyA9r8QNGVWa6+KbnnB/Roxt3jG/Ij1lz1ODqu9s 4ziOgfxTRwH+Yv+e0kcVcG/NbeAWXdhZaSOPHsbHp8l9a/coTl0tkzze+J4sB6X4mCP0 Ium4DlXGVRpo2UHmelGhjIgC4h8JeoPEXq1YBdo2pxWDOrDAgjBbmlQc4CMMS9Gv37Bd u1Ua4CzESCt3NBcBl0/giALuyr0wSZg5LxIyAVcvoDtoKgfkNBn+PkNvBsT/mybrwenr ovXJ5AymE55zK469WUXzVKbtSWzZFEO9ATCvpduzc3GCz5gvYr8/ucWCpym7ggGYeMKA MAIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="NpEL/J33"; 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=NONE sp=NONE 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 i14-20020a05640242ce00b0046751a6076bsi15552906edc.318.2022.11.22.19.01.37; Tue, 22 Nov 2022 19:02:04 -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="NpEL/J33"; 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=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235419AbiKWDA1 (ORCPT + 99 others); Tue, 22 Nov 2022 22:00:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232445AbiKWDAS (ORCPT ); Tue, 22 Nov 2022 22:00:18 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F12797935C for ; Tue, 22 Nov 2022 19:00:14 -0800 (PST) Received: from dimapc.. (109-252-117-140.nat.spd-mgts.ru [109.252.117.140]) (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 E0F606602AE2; Wed, 23 Nov 2022 03:00:10 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1669172412; bh=x3hz4Vm5thETCU9KY+h86Wyft3m6JCCP8AiPr8ByxiU=; h=From:To:Cc:Subject:Date:From; b=NpEL/J33dFC7pRpfHNHQfrNn2EMw/bcciaY8Gt0QyotnbqOk9vvX5AIUjpO4hb+HC VfEKuNcQvYAHMRtoK9ec2cS8OANQhT4Si+HrWG0/95O/A5gTB7P16bHoMyfJjnfThR eOaNnXK1Uwk+TKuM6wRRykuX7O1mRSEpf7Xh/x6pLmwj46fLDOyqLicOrft4CxSlkI EzE+mpi/zZpE0Ik3gtLx2x+QQAg+7h4iSuepwV3kx6cn6WSH/a82l6pFohXNWcQJdn V2EDx7XuHBgPWYT5t0UgY3x5mm7SI34FDYVZIUaqm10XmyLtw/+x+/dJvnXo0WOSQD WsAK+xk1zJDXg== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gustavo Padovan , Daniel Stone , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Clark , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Qiang Yu , Steven Price , Alyssa Rosenzweig , Rob Herring , Sean Paul , Dmitry Baryshkov , Abhinav Kumar Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: [PATCH v9 00/11] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Date: Wed, 23 Nov 2022 05:57:12 +0300 Message-Id: <20221123025723.695075-1-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.38.1 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?1750254249249136496?= X-GMAIL-MSGID: =?utf-8?q?1750254249249136496?= Hello, This series: 1. Makes minor fixes for drm_gem_lru and Panfrost 2. Brings refactoring for older code 3. Adds common drm-shmem memory shrinker 4. Enables shrinker for VirtIO-GPU driver 5. Switches Panfrost driver to the common shrinker Changelog: v9: - Replaced struct drm_gem_shmem_shrinker with drm_gem_shmem and moved it to drm_device, like was suggested by Thomas Zimmermann. - Replaced drm_gem_shmem_shrinker_register() with drmm_gem_shmem_init(), like was suggested by Thomas Zimmermann. - Moved evict() callback to drm_gem_object_funcs and added common drm_gem_object_evict() helper, like was suggested by Thomas Zimmermann. - The shmem object now is evictable by default, like was suggested by Thomas Zimmermann. Dropped the set_evictable/purgeble() functions as well, drivers will decide whether BO is evictable within theirs madvise IOCTL. - Added patches that convert drm-shmem code to use drm_WARN_ON() and drm_dbg_kms(), like was requested by Thomas Zimmermann. - Turned drm_gem_shmem_object booleans into 1-bit bit fields, like was suggested by Thomas Zimmermann. - Switched to use drm_dev->unique for the shmem shrinker name. Drivers don't need to specify the name explicitly anymore. - Re-added dma_resv_test_signaled() that was missing in v8 and also fixed its argument to DMA_RESV_USAGE_READ. See comment to dma_resv_usage_rw(). - Added new fix for Panfrost driver that silences lockdep warning caused by shrinker. Both Panfrost old and new shmem shrinkers are affected. v8: - Rebased on top of recent linux-next that now has dma-buf locking convention patches merged, which was blocking shmem shrinker before. - Shmem shrinker now uses new drm_gem_lru helper. - Dropped Steven Price t-b from the Panfrost patch because code changed significantly since v6 and should be re-tested. v7: - dma-buf locking convention v6: https://lore.kernel.org/dri-devel/20220526235040.678984-1-dmitry.osipenko@collabora.com/ Related patches: Mesa: https://gitlab.freedesktop.org/digetx/mesa/-/commits/virgl-madvise igt: https://gitlab.freedesktop.org/digetx/igt-gpu-tools/-/commits/virtio-madvise https://gitlab.freedesktop.org/digetx/igt-gpu-tools/-/commits/panfrost-madvise I'm going to upstream Mesa and igt patches once the kernel part will land. Dmitry Osipenko (11): drm/msm/gem: Prevent blocking within shrinker loop drm/gem: Add evict() callback to drm_gem_object_funcs drm/panfrost: Don't sync rpm suspension after mmu flushing drm/shmem: Put booleans in the end of struct drm_gem_shmem_object drm/shmem: Switch to use drm_* debug helpers drm/shmem-helper: Don't use vmap_use_count for dma-bufs drm/shmem-helper: Switch to reservation lock drm/shmem-helper: Add memory shrinker drm/gem: Add drm_gem_pin_unlocked() drm/virtio: Support memory shrinking drm/panfrost: Switch to generic memory shrinker Dmitry Osipenko (11): drm/msm/gem: Prevent blocking within shrinker loop drm/panfrost: Don't sync rpm suspension after mmu flushing drm/gem: Add evict() callback to drm_gem_object_funcs drm/shmem: Put booleans in the end of struct drm_gem_shmem_object drm/shmem: Switch to use drm_* debug helpers drm/shmem-helper: Don't use vmap_use_count for dma-bufs drm/shmem-helper: Switch to reservation lock drm/shmem-helper: Add memory shrinker 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 | 53 +- drivers/gpu/drm/drm_gem_shmem_helper.c | 647 +++++++++++++----- drivers/gpu/drm/lima/lima_gem.c | 8 +- drivers/gpu/drm/msm/msm_gem_shrinker.c | 8 +- drivers/gpu/drm/panfrost/Makefile | 1 - drivers/gpu/drm/panfrost/panfrost_device.h | 4 - drivers/gpu/drm/panfrost/panfrost_drv.c | 34 +- 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/panfrost/panfrost_mmu.c | 21 +- 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 | 132 +++- 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 | 19 +- include/drm/drm_gem_shmem_helper.h | 112 +-- include/uapi/drm/virtgpu_drm.h | 14 + 23 files changed, 1010 insertions(+), 409 deletions(-) delete mode 100644 drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c