Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Nerf the preclose callback for modern drivers

With all drivers converted there's only legacy dri1 drivers using it.
Not going to touch those, instead just hide it like we've done with
other dri1 driver hooks like firstopen.

In all this I didn't find any real reason why we'd needed 2 hooks, and
having symmetry between open and close just appeases my OCD better.
Yeah, someone else could do an s/postclose/close/, but that's for
someone who understands cocci. And maybe after this series is reviewed
and landed, to avoid patch-regen churn.

v2: s/last/post/close in the kernel-doc (Sean).

Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170508082633.4214-4-daniel.vetter@ffwll.ch

+6 -25
+4 -4
drivers/gpu/drm/drm_file.c
··· 351 351 * 352 352 * This function must be used by drivers as their &file_operations.release 353 353 * method. It frees any resources associated with the open file, and calls the 354 - * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is 355 - * the last open file for the DRM device also proceeds to call the 356 - * &drm_driver.lastclose driver callback. 354 + * &drm_driver.postclose driver callback. If this is the last open file for the 355 + * DRM device also proceeds to call the &drm_driver.lastclose driver callback. 357 356 * 358 357 * RETURNS: 359 358 * ··· 372 373 list_del(&file_priv->lhead); 373 374 mutex_unlock(&dev->filelist_mutex); 374 375 375 - if (dev->driver->preclose) 376 + if (drm_core_check_feature(dev, DRIVER_LEGACY) && 377 + dev->driver->preclose) 376 378 dev->driver->preclose(dev, file_priv); 377 379 378 380 /* ========================================================
+2 -21
include/drm/drm_drv.h
··· 104 104 int (*open) (struct drm_device *, struct drm_file *); 105 105 106 106 /** 107 - * @preclose: 108 - * 109 - * One of the driver callbacks when a new &struct drm_file is closed. 110 - * Useful for tearing down driver-private data structures allocated in 111 - * @open like buffer allocators, execution contexts or similar things. 112 - * 113 - * Since the display/modeset side of DRM can only be owned by exactly 114 - * one &struct drm_file (see &drm_file.is_master and &drm_device.master) 115 - * there should never be a need to tear down any modeset related 116 - * resources in this callback. Doing so would be a driver design bug. 117 - * 118 - * FIXME: It is not really clear why there's both @preclose and 119 - * @postclose. Without a really good reason, use @postclose only. 120 - */ 121 - void (*preclose) (struct drm_device *, struct drm_file *file_priv); 122 - 123 - /** 124 107 * @postclose: 125 108 * 126 109 * One of the driver callbacks when a new &struct drm_file is closed. ··· 114 131 * one &struct drm_file (see &drm_file.is_master and &drm_device.master) 115 132 * there should never be a need to tear down any modeset related 116 133 * resources in this callback. Doing so would be a driver design bug. 117 - * 118 - * FIXME: It is not really clear why there's both @preclose and 119 - * @postclose. Without a really good reason, use @postclose only. 120 134 */ 121 135 void (*postclose) (struct drm_device *, struct drm_file *); 122 136 ··· 130 150 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo` 131 151 * infrastructure. 132 152 * 133 - * This is called after @preclose and @postclose have been called. 153 + * This is called after @postclose hook has been called. 134 154 * 135 155 * NOTE: 136 156 * ··· 496 516 /* List of devices hanging off this driver with stealth attach. */ 497 517 struct list_head legacy_dev_list; 498 518 int (*firstopen) (struct drm_device *); 519 + void (*preclose) (struct drm_device *, struct drm_file *file_priv); 499 520 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); 500 521 int (*dma_quiescent) (struct drm_device *); 501 522 int (*context_dtor) (struct drm_device *dev, int context);