From: Thomas Zimmermann Subject: Re: [PATCH v3 2/3] drm/vram: Add infrastructure for move_notify() Date: Fri, 6 Sep 2019 12:24:00 +0200 Message-ID: <5b033377-44a1-ebd1-7fad-322bede05eef@suse.de> References: <20190906085214.11677-1-tzimmermann@suse.de> <20190906085214.11677-3-tzimmermann@suse.de> <20190906092822.GD3958@phenom.ffwll.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1167098679==" Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 15EA86E1CD for ; Fri, 6 Sep 2019 10:24:08 +0000 (UTC) In-Reply-To: <20190906092822.GD3958@phenom.ffwll.local> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Daniel Vetter Cc: feng.tang@intel.com, dave@stgolabs.net, rong.a.chen@intel.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, maxime.ripard@bootlin.com, kraxel@redhat.com, ying.huang@intel.com, sean@poorly.run List-Id: dri-devel@lists.freedesktop.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============1167098679== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FzMdCdnPqo6bBH8umToSRxntfH5KcpwDJ" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --FzMdCdnPqo6bBH8umToSRxntfH5KcpwDJ Content-Type: multipart/mixed; boundary="XjhILtgrQ2kXfQrdREfGbjlTKhUsk0KNS"; protected-headers="v1" From: Thomas Zimmermann To: Daniel Vetter Cc: noralf@tronnes.org, airlied@linux.ie, rong.a.chen@intel.com, feng.tang@intel.com, ying.huang@intel.com, sean@poorly.run, maxime.ripard@bootlin.com, maarten.lankhorst@linux.intel.com, dave@stgolabs.net, kraxel@redhat.com, dri-devel@lists.freedesktop.org Message-ID: <5b033377-44a1-ebd1-7fad-322bede05eef@suse.de> Subject: Re: [PATCH v3 2/3] drm/vram: Add infrastructure for move_notify() References: <20190906085214.11677-1-tzimmermann@suse.de> <20190906085214.11677-3-tzimmermann@suse.de> <20190906092822.GD3958@phenom.ffwll.local> In-Reply-To: <20190906092822.GD3958@phenom.ffwll.local> --XjhILtgrQ2kXfQrdREfGbjlTKhUsk0KNS Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Am 06.09.19 um 11:28 schrieb Daniel Vetter: > On Fri, Sep 06, 2019 at 10:52:13AM +0200, Thomas Zimmermann wrote: >> This patch prepares VRAM helpers for lazy unmapping of buffer objects.= >> >> Signed-off-by: Thomas Zimmermann >> --- >> drivers/gpu/drm/drm_vram_mm_helper.c | 12 ++++++++++++ >> include/drm/drm_vram_mm_helper.h | 4 ++++ >> 2 files changed, 16 insertions(+) >> >> diff --git a/drivers/gpu/drm/drm_vram_mm_helper.c b/drivers/gpu/drm/dr= m_vram_mm_helper.c >> index c911781d6728..31984690d5f3 100644 >> --- a/drivers/gpu/drm/drm_vram_mm_helper.c >> +++ b/drivers/gpu/drm/drm_vram_mm_helper.c >> @@ -98,6 +98,17 @@ static int bo_driver_verify_access(struct ttm_buffe= r_object *bo, >> return vmm->funcs->verify_access(bo, filp); >> } >> =20 >> +static void bo_driver_move_notify(struct ttm_buffer_object *bo, >> + bool evict, >> + struct ttm_mem_reg *new_mem) >> +{ >> + struct drm_vram_mm *vmm =3D drm_vram_mm_of_bdev(bo->bdev); >> + >> + if (!vmm->funcs || !vmm->funcs->move_notify) >> + return; >> + vmm->funcs->move_notify(bo, evict, new_mem); >> +} >> + >> static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev, >> struct ttm_mem_reg *mem) >> { >> @@ -140,6 +151,7 @@ static struct ttm_bo_driver bo_driver =3D { >> .eviction_valuable =3D ttm_bo_eviction_valuable, >> .evict_flags =3D bo_driver_evict_flags, >> .verify_access =3D bo_driver_verify_access, >> + .move_notify =3D bo_driver_move_notify, >> .io_mem_reserve =3D bo_driver_io_mem_reserve, >> .io_mem_free =3D bo_driver_io_mem_free, >> }; >> diff --git a/include/drm/drm_vram_mm_helper.h b/include/drm/drm_vram_m= m_helper.h >> index 2aacfb1ccfae..7fb8700f45fe 100644 >> --- a/include/drm/drm_vram_mm_helper.h >> +++ b/include/drm/drm_vram_mm_helper.h >> @@ -15,6 +15,8 @@ struct drm_device; >> &ttm_bo_driver.evict_flags >> * @verify_access: Provides an implementation for \ >> struct &ttm_bo_driver.verify_access >> + * @move_notify: Provides an implementation for >> + * struct &ttm_bo_driver.move_notify >> * >> * These callback function integrate VRAM MM with TTM buffer objects.= New >> * functions can be added if necessary. >> @@ -23,6 +25,8 @@ struct drm_vram_mm_funcs { >> void (*evict_flags)(struct ttm_buffer_object *bo, >> struct ttm_placement *placement); >> int (*verify_access)(struct ttm_buffer_object *bo, struct file *filp= ); >> + void (*move_notify)(struct ttm_buffer_object *bo, bool evict, >> + struct ttm_mem_reg *new_mem); >=20 > Is this indirection really worth it? We have a grand total of 1 driver > which isn't using gem (vmwgfx), and I don't think that one will ever > switch over to vram helpers. >=20 > I'd fold that all in. Helpers don't need to be flexible enough to suppo= rt > every possible use-case (that's just the job of the core), they can be > opinionated to get cleaner code for most cases. >=20 The original idea was to make this as flexible as possible; probably more flexible than necessary. I wouldn't mind merging everything into one file, but please not in this patch set, can we keep it for now and I send you a cleanup next? Best regards Thomas > For this case here if you fold this in you can unexport 3 EXPORT_SYMBOL= s > (4 with this patch here), which I think is a neat simplification of the= > complexity exposed to driver writers. Just put the necessary declaratio= ns > into a drm_vram_helper_internal.h so that drivers don't get at it by > accident (like the other drm*internal.h helpers we have). > -Daniel >=20 >> }; >> =20 >> /** >> --=20 >> 2.23.0 >> >=20 --=20 Thomas Zimmermann Graphics Driver Developer SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany GF: Felix Imend=C3=B6rffer, Mary Higgins, Sri Rasiah HRB 21284 (AG N=C3=BCrnberg) --XjhILtgrQ2kXfQrdREfGbjlTKhUsk0KNS-- --FzMdCdnPqo6bBH8umToSRxntfH5KcpwDJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEchf7rIzpz2NEoWjlaA3BHVMLeiMFAl1yM8AACgkQaA3BHVML eiPGhQf+PPvzqDIrgVdsjLfX+jaxYahye/OQY44ejG1VOxpLtG9lS/klRSO6Hgg3 XeTBnKDj+SRXxiXZzxDXMHEWlugeNWh9j4U/XGh/gMWzWBtHCPc+FBhquh5xTCM0 I4dBWHxLg46ev3Hvjyqv4+nxyk84114uudtSSjiurhsY+9+4kIfeRRqVlvwsmfaS yeUenOQdsqvHS7h0l9s1YcPqUWVvzKLDPnlEUpM4YGg+SUZ7RICI82tnP4H213nY jff8e1ODWRAoJxjCKaaJtAOrt1TuGwutCt8DkuVn0J9aT1B5zCfDS5V9yk/rmPYc 1Jec6CgufR1DlC8DYegIZ9cW1FhmUQ== =eqNx -----END PGP SIGNATURE----- --FzMdCdnPqo6bBH8umToSRxntfH5KcpwDJ-- --===============1167098679== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVs --===============1167098679==--