Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7599502rwb; Wed, 23 Nov 2022 08:23:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lXBtJ5G4vEj1ENTXK/fDu9CxAp2imGlJUK9BlhpJpfWrBHsOKpADxb5lxT1lVs8cKqTTX X-Received: by 2002:a63:711e:0:b0:477:5654:c37e with SMTP id m30-20020a63711e000000b004775654c37emr16818970pgc.206.1669220633575; Wed, 23 Nov 2022 08:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669220633; cv=none; d=google.com; s=arc-20160816; b=nJkjHtPB0uMDMCKoTSc1lMc0jc1gGJuSSWFymyk+mO8CF2RbSQWhXDKQlBT1bbM18D ShhSKe0oN69YI4o1OoZELkeOqpCvR6y4lq/ntiqN54WEVbM0uvkOP9W5hL6GSxRq8yhP pw0yiD25mXNIDmIc2hDWukpsCzSVsBpkvQ8r54znCMGpZ7HtwTujq8qncdSibd9mHOqj +75WKUzbfKyQVNg4glJeLj4yww0s1Ra4EWrZ+ubaCTTwrZDL2AoFtqJ1RWbhUTFBbnSo E2KKn+NC+WPiog5+79DnPW89dVjiBdwYuC0EbxBozGah7Y1PUNDPNjozo+ICn62KDZry XAIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=UbkE+A51liIEWNUzbp1hjqTrhgIT6hzSQvv5BbYWYgc=; b=GpPBUj/NFoKFcbNCgj99p7pc8vYmNy11jNkzcAxlYy6dvk7Cu8GZwJ9bFR43UP0gtN VScbZayTUmy2PKrx4/iurn8Xa9gNFBo8psV2nwCmm5jTyxqrvrxcXlDnciLEanqnqKn+ hOE1QlbDAL9b38Pu02tz+gSUjDJAZdYdlOzHmhKp1WZQRirx4BnxOClI8KUgx64+kNJn Vyo7l4zuiRRfQx5hrkHcpgaVIEAz6oi3Ce132QfZA2OTHSE7vkbLmlB3jjPhjDSoFhsE QjsI398SYjWJ+cfFsU2IAnf3Sn/eBD+NHa99+0Nyu/fxm1auFhRqKUJ0t2rawqJJz6Zf naKw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a170903124600b001869c2b3a3csi17347687plh.537.2022.11.23.08.23.40; Wed, 23 Nov 2022 08:23:53 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237667AbiKWP7O (ORCPT + 88 others); Wed, 23 Nov 2022 10:59:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239018AbiKWP6c (ORCPT ); Wed, 23 Nov 2022 10:58:32 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 58FA9627EA for ; Wed, 23 Nov 2022 07:58:21 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3D6161FB; Wed, 23 Nov 2022 07:58:27 -0800 (PST) Received: from [10.57.87.10] (unknown [10.57.87.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 262FE3F73B; Wed, 23 Nov 2022 07:58:16 -0800 (PST) Message-ID: Date: Wed, 23 Nov 2022 15:58:14 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v9 03/11] drm/gem: Add evict() callback to drm_gem_object_funcs Content-Language: en-GB To: Dmitry Osipenko , 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 , Alyssa Rosenzweig , Rob Herring , Sean Paul , Dmitry Baryshkov , Abhinav Kumar Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org References: <20221123025723.695075-1-dmitry.osipenko@collabora.com> <20221123025723.695075-4-dmitry.osipenko@collabora.com> From: Steven Price In-Reply-To: <20221123025723.695075-4-dmitry.osipenko@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 On 23/11/2022 02:57, Dmitry Osipenko wrote: > Add new common evict() callback to drm_gem_object_funcs and corresponding > drm_gem_object_evict() helper. This is a first step on a way to providing > common GEM-shrinker API for DRM drivers. > > Suggested-by: Thomas Zimmermann > Signed-off-by: Dmitry Osipenko > --- > drivers/gpu/drm/drm_gem.c | 15 +++++++++++++++ > include/drm/drm_gem.h | 12 ++++++++++++ > 2 files changed, 27 insertions(+) > > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c > index 299bca1390aa..c0510b8080d2 100644 > --- a/drivers/gpu/drm/drm_gem.c > +++ b/drivers/gpu/drm/drm_gem.c > @@ -1458,3 +1458,18 @@ drm_gem_lru_scan(struct drm_gem_lru *lru, > return freed; > } > EXPORT_SYMBOL(drm_gem_lru_scan); > + > +/** > + * drm_gem_object_evict - helper to evict backing pages for a GEM object > + * @obj: obj in question > + */ > +bool > +drm_gem_object_evict(struct drm_gem_object *obj) > +{ > + dma_resv_assert_held(obj->resv); > + > + if (obj->funcs->evict) > + return obj->funcs->evict(obj); > + > + return false; > +} This function needs exporting for the module build to work correctly. Steve > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h > index b46ade812443..add1371453f0 100644 > --- a/include/drm/drm_gem.h > +++ b/include/drm/drm_gem.h > @@ -172,6 +172,16 @@ struct drm_gem_object_funcs { > * This is optional but necessary for mmap support. > */ > const struct vm_operations_struct *vm_ops; > + > + /** > + * @evict: > + * > + * Evicts gem object out from memory. Used by the drm_gem_object_evict() > + * helper. Returns true on success, false otherwise. > + * > + * This callback is optional. > + */ > + bool (*evict)(struct drm_gem_object *obj); > }; > > /** > @@ -480,4 +490,6 @@ unsigned long drm_gem_lru_scan(struct drm_gem_lru *lru, > unsigned long *remaining, > bool (*shrink)(struct drm_gem_object *obj)); > > +bool drm_gem_object_evict(struct drm_gem_object *obj); > + > #endif /* __DRM_GEM_H__ */