From 18ace11f87e69454379a3a1247a657b70ca142fc Mon Sep 17 00:00:00 2001 From: Ville Syrjälä Date: Thu, 13 Sep 2018 16:16:21 +0300 Subject: drm: Introduce per-device driver_features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We wish to control certain driver_features flags on a per-device basis while still sharing a single drm_driver instance across all the devices. To that end introduce device.driver_features. By default it will be set to ~0 to not impose any limits beyond driver.driver_features. Drivers can then clear specific flags in the per-device bitmask to limit the capabilities of the device. An alternative approach would be to copy the driver_features from the driver into the device in drm_dev_init(), however that would require verifying that no driver is currently changing driver.driver_features after drm_dev_init(). Hence the ~0 apporach was easier. Ideally we'd also make drm_driver const but there is plenty of code left that wants to mutate it (eg. various vfunc assignments). We'll need to fix all that up before we can make it const. And while at it fix up the type of the feature flag passed to drm_core_check_feature(). v2: Streamline the && vs. & (Chris) s/int/u32/ in drm_core_check_feature() args Cc: Chris Wilson Signed-off-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20180913131622.17690-1-ville.syrjala@linux.intel.com Reviewed-by: Chris Wilson Reviewed-by: Daniel Vetter Reviewed-by: Michel Dänzer --- drivers/gpu/drm/drm_drv.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/gpu/drm/drm_drv.c') diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index ea4941da9b27..36e8e9cbec52 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -506,6 +506,9 @@ int drm_dev_init(struct drm_device *dev, dev->dev = parent; dev->driver = driver; + /* no per-device feature limits by default */ + dev->driver_features = ~0u; + INIT_LIST_HEAD(&dev->filelist); INIT_LIST_HEAD(&dev->filelist_internal); INIT_LIST_HEAD(&dev->clientlist); -- cgit v1.2.3