From e3cbeaf8db3dc0b2cfd3c31dfac5bec8846d33f2 Mon Sep 17 00:00:00 2001 From: Meghana Madhyastha Date: Thu, 14 Sep 2017 13:39:14 +0530 Subject: drm/agpsupport: Replace "foo * bar" with "foo *bar" This replaces all instances of foo * bar with foo *bar in drm_agpsupport.c. This is so that it adheres to standard C syntax for pointers. Signed-off-by: Meghana Madhyastha Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/e092694c26e61fc6147e44851392a43b7a68c4f3.1505376068.git.meghana.madhyastha@gmail.com --- drivers/gpu/drm/drm_agpsupport.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c index c89953449e96..d9e8cdd4b9e9 100644 --- a/drivers/gpu/drm/drm_agpsupport.c +++ b/drivers/gpu/drm/drm_agpsupport.c @@ -95,7 +95,7 @@ int drm_agp_info_ioctl(struct drm_device *dev, void *data, * Verifies the AGP device hasn't been acquired before and calls * \c agp_backend_acquire. */ -int drm_agp_acquire(struct drm_device * dev) +int drm_agp_acquire(struct drm_device *dev) { if (!dev->agp) return -ENODEV; @@ -135,7 +135,7 @@ int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, * * Verifies the AGP device has been acquired and calls \c agp_backend_release. */ -int drm_agp_release(struct drm_device * dev) +int drm_agp_release(struct drm_device *dev) { if (!dev->agp || !dev->agp->acquired) return -EINVAL; @@ -161,7 +161,7 @@ int drm_agp_release_ioctl(struct drm_device *dev, void *data, * Verifies the AGP device has been acquired but not enabled, and calls * \c agp_enable. */ -int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode) +int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode) { if (!dev->agp || !dev->agp->acquired) return -EINVAL; @@ -244,8 +244,8 @@ int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, * * Walks through drm_agp_head::memory until finding a matching handle. */ -static struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device * dev, - unsigned long handle) +static struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device *dev, + unsigned long handle) { struct drm_agp_mem *entry; -- cgit v1.2.3 From 182e61d136bd1f927e33bf4a98d1f7ebedbeba2d Mon Sep 17 00:00:00 2001 From: Meghana Madhyastha Date: Thu, 14 Sep 2017 13:40:49 +0530 Subject: drm/agpsupport: Remove assignment in if condition Move the assignment so that it happens before the if condition. Merged multiple similar conditionals to a single conditional statement. This results in syntax which is easier to read. Found by checkpath.pl Signed-off-by: Meghana Madhyastha Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/d30cb59d92c8a98d0665ef6ae2a56b364dc61098.1505376068.git.meghana.madhyastha@gmail.com --- drivers/gpu/drm/drm_agpsupport.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c index d9e8cdd4b9e9..860d57acb8e3 100644 --- a/drivers/gpu/drm/drm_agpsupport.c +++ b/drivers/gpu/drm/drm_agpsupport.c @@ -101,7 +101,8 @@ int drm_agp_acquire(struct drm_device *dev) return -ENODEV; if (dev->agp->acquired) return -EBUSY; - if (!(dev->agp->bridge = agp_backend_acquire(dev->pdev))) + dev->agp->bridge = agp_backend_acquire(dev->pdev); + if (!dev->agp->bridge) return -ENODEV; dev->agp->acquired = 1; return 0; @@ -203,12 +204,14 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request) if (!dev->agp || !dev->agp->acquired) return -EINVAL; - if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL))) + entry = kzalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) return -ENOMEM; pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; type = (u32) request->type; - if (!(memory = agp_allocate_memory(dev->agp->bridge, pages, type))) { + memory = agp_allocate_memory(dev->agp->bridge, pages, type); + if (!memory) { kfree(entry); return -ENOMEM; } @@ -275,9 +278,8 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request) if (!dev->agp || !dev->agp->acquired) return -EINVAL; - if (!(entry = drm_agp_lookup_entry(dev, request->handle))) - return -EINVAL; - if (!entry->bound) + entry = drm_agp_lookup_entry(dev, request->handle); + if (!entry || !entry->bound) return -EINVAL; ret = drm_unbind_agp(entry->memory); if (ret == 0) @@ -316,12 +318,12 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request) if (!dev->agp || !dev->agp->acquired) return -EINVAL; - if (!(entry = drm_agp_lookup_entry(dev, request->handle))) - return -EINVAL; - if (entry->bound) + entry = drm_agp_lookup_entry(dev, request->handle); + if (!entry || entry->bound) return -EINVAL; page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE; - if ((retcode = drm_bind_agp(entry->memory, page))) + retcode = drm_bind_agp(entry->memory, page); + if (retcode) return retcode; entry->bound = dev->agp->base + (page << PAGE_SHIFT); DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n", @@ -359,7 +361,8 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request) if (!dev->agp || !dev->agp->acquired) return -EINVAL; - if (!(entry = drm_agp_lookup_entry(dev, request->handle))) + entry = drm_agp_lookup_entry(dev, request->handle); + if (!entry) return -EINVAL; if (entry->bound) drm_unbind_agp(entry->memory); @@ -398,11 +401,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev) { struct drm_agp_head *head = NULL; - if (!(head = kzalloc(sizeof(*head), GFP_KERNEL))) + head = kzalloc(sizeof(*head), GFP_KERNEL); + if (!head) return NULL; head->bridge = agp_find_bridge(dev->pdev); if (!head->bridge) { - if (!(head->bridge = agp_backend_acquire(dev->pdev))) { + head->bridge = agp_backend_acquire(dev->pdev); + if (!head->bridge) { kfree(head); return NULL; } -- cgit v1.2.3 From 221399c387cd85ea552f7fbc8c219a6927b430ec Mon Sep 17 00:00:00 2001 From: Meghana Madhyastha Date: Thu, 14 Sep 2017 13:43:12 +0530 Subject: drm/agpsupport: Move EXPORT_SYMBOL so that it immediately follows its function EXPORT_SYMBOL(foo) should immediately follow its function/variable. This coding style is preferred. Found by checkpath.pl. Signed-off-by: Meghana Madhyastha Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/0496f0e821082969ec7950ac35f1e6b6cedb22a6.1505376068.git.meghana.madhyastha@gmail.com --- drivers/gpu/drm/drm_agpsupport.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c index 860d57acb8e3..a0510557787c 100644 --- a/drivers/gpu/drm/drm_agpsupport.c +++ b/drivers/gpu/drm/drm_agpsupport.c @@ -70,7 +70,6 @@ int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info) return 0; } - EXPORT_SYMBOL(drm_agp_info); int drm_agp_info_ioctl(struct drm_device *dev, void *data, @@ -107,7 +106,6 @@ int drm_agp_acquire(struct drm_device *dev) dev->agp->acquired = 1; return 0; } - EXPORT_SYMBOL(drm_agp_acquire); /** @@ -172,7 +170,6 @@ int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode) dev->agp->enabled = 1; return 0; } - EXPORT_SYMBOL(drm_agp_enable); int drm_agp_enable_ioctl(struct drm_device *dev, void *data, -- cgit v1.2.3 From 13cc80ce4404e19619c41fc636ebb2dd91a22c23 Mon Sep 17 00:00:00 2001 From: Meghana Madhyastha Date: Thu, 14 Sep 2017 13:44:20 +0530 Subject: drm/agpsupport: Remove extra blank line Remove extra blank line to adhere to standard coding style. Found by checkpath.pl.. Signed-off-by: Meghana Madhyastha Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/9cfc7e7535908f3fe3b1df706f2999687c90d4e7.1505376068.git.meghana.madhyastha@gmail.com --- drivers/gpu/drm/drm_agpsupport.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c index a0510557787c..737f02885c28 100644 --- a/drivers/gpu/drm/drm_agpsupport.c +++ b/drivers/gpu/drm/drm_agpsupport.c @@ -373,7 +373,6 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request) EXPORT_SYMBOL(drm_agp_free); - int drm_agp_free_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { -- cgit v1.2.3 From 531beb067c6185aceabfdee0965234c6a8fd133b Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 15 Sep 2017 00:05:16 +0100 Subject: dma-buf: remove redundant initialization of sg_table sg_table is being initialized and is never read before it is updated again later on, hence making the initialization redundant. Remove the initialization. Detected by clang scan-build: "warning: Value stored to 'sg_table' during its initialization is never read" Signed-off-by: Colin Ian King Reviewed-by: Chris Wilson Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20170914230516.6056-1-colin.king@canonical.com --- drivers/dma-buf/dma-buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 4a038dcf5361..bc1cb284111c 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -625,7 +625,7 @@ EXPORT_SYMBOL_GPL(dma_buf_detach); struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach, enum dma_data_direction direction) { - struct sg_table *sg_table = ERR_PTR(-EINVAL); + struct sg_table *sg_table; might_sleep(); -- cgit v1.2.3 From 6bf2e0324b9376512b0b9bf5c5c4b383afd419ec Mon Sep 17 00:00:00 2001 From: Sean Paul Date: Wed, 20 Sep 2017 17:13:56 -0700 Subject: drm/rockchip: Fix uninitialized use of ret If there are no children for lvds, ret is used uninitialized. This patch initializes ret and returns an error if the port has no children. Fixes: 34cc0aa25456 ("drm/rockchip: Add support for Rockchip Soc LVDS") Cc: Mark Yao Cc: Heiko Stuebner Cc: Sandy Huang Cc: dri-devel@lists.freedesktop.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-rockchip@lists.infradead.org Reviewed-by: Mark Yao Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/20170921001408.1839-1-seanpaul@chromium.org --- drivers/gpu/drm/rockchip/rockchip_lvds.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c index c5fbe533796c..84911bdc27d1 100644 --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c @@ -346,7 +346,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master, struct drm_connector *connector; struct device_node *remote = NULL; struct device_node *port, *endpoint; - int ret; + int ret = 0, child_count = 0; const char *name; u32 endpoint_id; @@ -358,15 +358,20 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master, return -EINVAL; } for_each_child_of_node(port, endpoint) { + child_count++; of_property_read_u32(endpoint, "reg", &endpoint_id); ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id, &lvds->panel, &lvds->bridge); if (!ret) break; } - if (ret) { + if (!child_count) { + DRM_DEV_ERROR(dev, "lvds port does not have any children\n"); + ret = -EINVAL; + goto err_put_port; + } else if (ret) { DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n"); - ret = -EPROBE_DEFER; + ret = -EPROBE_DEFER; goto err_put_port; } if (lvds->panel) -- cgit v1.2.3 From d0d1aee5f7eda2f2cae0932a217e27493f2c2faa Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Thu, 21 Sep 2017 00:59:57 +0200 Subject: drm: Try to document legacy DPMS uapi a bit better Due to inconsistency of how various legacy drivers implemented DPMS the DPMS uabi has a lot of quirks. Atomic standardizes this, but drivers using the DPMS support can't rely on that since legacy drivers still exist. Laurent asked for this. v2: Improve commit message and explain that DPMS doesn't really exist for the atomic ioctl (it's "ACTIVE" on the CRTC instead). Text polish from Eric's review. Cc: Laurent Pinchart Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Jani Nikula Cc: Sean Paul Cc: David Airlie Cc: Eric Anholt Reviewed-by: Eric Anholt Reviewed-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/20170920225957.16278-1-daniel.vetter@ffwll.ch --- drivers/gpu/drm/drm_connector.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index bb2e60f5feb6..d8ca526ca4ee 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -719,6 +719,29 @@ DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name, * callback. For atomic drivers the remapping to the "ACTIVE" property is * implemented in the DRM core. This is the only standard connector * property that userspace can change. + * + * Note that this property cannot be set through the MODE_ATOMIC ioctl, + * userspace must use "ACTIVE" on the CRTC instead. + * + * WARNING: + * + * For userspace also running on legacy drivers the "DPMS" semantics are a + * lot more complicated. First, userspace cannot rely on the "DPMS" value + * returned by the GETCONNECTOR actually reflecting reality, because many + * drivers fail to update it. For atomic drivers this is taken care of in + * drm_atomic_helper_update_legacy_modeset_state(). + * + * The second issue is that the DPMS state is only well-defined when the + * connector is connected to a CRTC. In atomic the DRM core enforces that + * "ACTIVE" is off in such a case, no such checks exists for "DPMS". + * + * Finally, when enabling an output using the legacy SETCONFIG ioctl then + * "DPMS" is forced to ON. But see above, that might not be reflected in + * the software value on legacy drivers. + * + * Summarizing: Only set "DPMS" when the connector is known to be enabled, + * assume that a successful SETCONFIG call also sets "DPMS" to on, and + * never read back the value of "DPMS" because it can be incorrect. * PATH: * Connector path property to identify how this sink is physically * connected. Used by DP MST. This should be set by calling -- cgit v1.2.3 From 3fbe2e184d2fbc353425efa7b788aba64374119b Mon Sep 17 00:00:00 2001 From: Haneen Mohammed Date: Thu, 21 Sep 2017 15:04:24 -0600 Subject: drm: Remove obsolete "This is gross" comment Remove obsolete comment which was initially added in 2008 to annotate that idr_find() was used before idr_remove() since idr_remove() didn't use to return feedback. The comment now is irrelevant with commit f6cd7daecff5 ("drm: Release driver references to handle before making it available again"). Signed-off-by: Haneen Mohammed Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20170921210424.GA21951@Haneen --- drivers/gpu/drm/drm_gem.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 8bea0326e7a7..4e710ec40599 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -281,15 +281,6 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle) { struct drm_gem_object *obj; - /* This is gross. The idr system doesn't let us try a delete and - * return an error code. It just spews if you fail at deleting. - * So, we have to grab a lock around finding the object and then - * doing the delete on it and dropping the refcount, or the user - * could race us to double-decrement the refcount and cause a - * use-after-free later. Given the frequency of our handle lookups, - * we may want to use ida for number allocation and a hash table - * for the pointers, anyway. - */ spin_lock(&filp->table_lock); /* Check if we currently have a reference on the object */ -- cgit v1.2.3 From f2a44dd02329707514af16fe0904a78604a97c0b Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Thu, 21 Sep 2017 00:29:36 +0200 Subject: drm/rockchip: Cocci spatch "vma_pages" Use vma_pages function on vma object instead of explicit computation. Found by coccinelle spatch "api/vma_pages.cocci" Signed-off-by: Thomas Meyer Signed-off-by: Mark Yao Link: https://patchwork.freedesktop.org/patch/msgid/1505946334393-988165015-7-diffsplit-thomas@m3y3r.de --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 1869c8bb76c8..1d9655576b6e 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -220,7 +220,7 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj, { struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); unsigned int i, count = obj->size >> PAGE_SHIFT; - unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; + unsigned long user_count = vma_pages(vma); unsigned long uaddr = vma->vm_start; unsigned long offset = vma->vm_pgoff; unsigned long end = user_count + offset; -- cgit v1.2.3 From 9a96f55034e41b4e002b767e9218d55f03bdff7d Mon Sep 17 00:00:00 2001 From: Aishwarya Pant Date: Tue, 26 Sep 2017 13:58:49 +0530 Subject: drm: introduce drm_dev_{get/put} functions Reference counting functions in the kernel typically use get/put suffixes. For maintaining coding style consistency, introduce drm_dev_{get/put} functions. All callers of drm_dev_ref() API have been converted in this patch and hence it has been dropped while the drm_dev_unref() API with non-trivial number of users remains for compatibility. The semantic patch scripts/coccinelle/api/drm-get-put.cocci has been updated with the new helper for conversion of drm_dev_unref() to drm_dev_put() Signed-off-by: Aishwarya Pant Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/6babda56134035a98220d5d37a4fd4048df214ce.1506413698.git.aishpant@gmail.com --- drivers/gpu/drm/drm_drv.c | 51 ++++++++++++++++++++------------ drivers/gpu/drm/drm_prime.c | 2 +- include/drm/drm_drv.h | 5 ++-- scripts/coccinelle/api/drm-get-put.cocci | 5 ++++ 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index be38ac7050d4..c0292e5d7281 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -286,13 +286,13 @@ struct drm_minor *drm_minor_acquire(unsigned int minor_id) spin_lock_irqsave(&drm_minor_lock, flags); minor = idr_find(&drm_minors_idr, minor_id); if (minor) - drm_dev_ref(minor->dev); + drm_dev_get(minor->dev); spin_unlock_irqrestore(&drm_minor_lock, flags); if (!minor) { return ERR_PTR(-ENODEV); } else if (drm_dev_is_unplugged(minor->dev)) { - drm_dev_unref(minor->dev); + drm_dev_put(minor->dev); return ERR_PTR(-ENODEV); } @@ -301,7 +301,7 @@ struct drm_minor *drm_minor_acquire(unsigned int minor_id) void drm_minor_release(struct drm_minor *minor) { - drm_dev_unref(minor->dev); + drm_dev_put(minor->dev); } /** @@ -326,11 +326,11 @@ void drm_minor_release(struct drm_minor *minor) * When cleaning up a device instance everything needs to be done in reverse: * First unpublish the device instance with drm_dev_unregister(). Then clean up * any other resources allocated at device initialization and drop the driver's - * reference to &drm_device using drm_dev_unref(). + * reference to &drm_device using drm_dev_put(). * * Note that the lifetime rules for &drm_device instance has still a lot of * historical baggage. Hence use the reference counting provided by - * drm_dev_ref() and drm_dev_unref() only carefully. + * drm_dev_get() and drm_dev_put() only carefully. * * It is recommended that drivers embed &struct drm_device into their own device * structure, which is supported through drm_dev_init(). @@ -345,7 +345,7 @@ void drm_minor_release(struct drm_minor *minor) * Cleans up all DRM device, calling drm_lastclose(). * * Note: Use of this function is deprecated. It will eventually go away - * completely. Please use drm_dev_unregister() and drm_dev_unref() explicitly + * completely. Please use drm_dev_unregister() and drm_dev_put() explicitly * instead to make sure that the device isn't userspace accessible any more * while teardown is in progress, ensuring that userspace can't access an * inconsistent state. @@ -360,7 +360,7 @@ void drm_put_dev(struct drm_device *dev) } drm_dev_unregister(dev); - drm_dev_unref(dev); + drm_dev_put(dev); } EXPORT_SYMBOL(drm_put_dev); @@ -386,7 +386,7 @@ void drm_dev_unplug(struct drm_device *dev) mutex_lock(&drm_global_mutex); drm_device_set_unplugged(dev); if (dev->open_count == 0) - drm_dev_unref(dev); + drm_dev_put(dev); mutex_unlock(&drm_global_mutex); } EXPORT_SYMBOL(drm_dev_unplug); @@ -475,8 +475,8 @@ static void drm_fs_inode_free(struct inode *inode) * initialization sequence to make sure userspace can't access an inconsistent * state. * - * The initial ref-count of the object is 1. Use drm_dev_ref() and - * drm_dev_unref() to take and drop further ref-counts. + * The initial ref-count of the object is 1. Use drm_dev_get() and + * drm_dev_put() to take and drop further ref-counts. * * Note that for purely virtual devices @parent can be NULL. * @@ -626,8 +626,8 @@ EXPORT_SYMBOL(drm_dev_fini); * initialization sequence to make sure userspace can't access an inconsistent * state. * - * The initial ref-count of the object is 1. Use drm_dev_ref() and - * drm_dev_unref() to take and drop further ref-counts. + * The initial ref-count of the object is 1. Use drm_dev_get() and + * drm_dev_put() to take and drop further ref-counts. * * Note that for purely virtual devices @parent can be NULL. * @@ -670,36 +670,49 @@ static void drm_dev_release(struct kref *ref) } /** - * drm_dev_ref - Take reference of a DRM device + * drm_dev_get - Take reference of a DRM device * @dev: device to take reference of or NULL * * This increases the ref-count of @dev by one. You *must* already own a - * reference when calling this. Use drm_dev_unref() to drop this reference + * reference when calling this. Use drm_dev_put() to drop this reference * again. * * This function never fails. However, this function does not provide *any* * guarantee whether the device is alive or running. It only provides a * reference to the object and the memory associated with it. */ -void drm_dev_ref(struct drm_device *dev) +void drm_dev_get(struct drm_device *dev) { if (dev) kref_get(&dev->ref); } -EXPORT_SYMBOL(drm_dev_ref); +EXPORT_SYMBOL(drm_dev_get); /** - * drm_dev_unref - Drop reference of a DRM device + * drm_dev_put - Drop reference of a DRM device * @dev: device to drop reference of or NULL * * This decreases the ref-count of @dev by one. The device is destroyed if the * ref-count drops to zero. */ -void drm_dev_unref(struct drm_device *dev) +void drm_dev_put(struct drm_device *dev) { if (dev) kref_put(&dev->ref, drm_dev_release); } +EXPORT_SYMBOL(drm_dev_put); + +/** + * drm_dev_unref - Drop reference of a DRM device + * @dev: device to drop reference of or NULL + * + * This is a compatibility alias for drm_dev_put() and should not be used by new + * code. + */ +void drm_dev_unref(struct drm_device *dev) +{ + drm_dev_put(dev); +} EXPORT_SYMBOL(drm_dev_unref); static int create_compat_control_link(struct drm_device *dev) @@ -839,7 +852,7 @@ EXPORT_SYMBOL(drm_dev_register); * * Unregister the DRM device from the system. This does the reverse of * drm_dev_register() but does not deallocate the device. The caller must call - * drm_dev_unref() to drop their final reference. + * drm_dev_put() to drop their final reference. * * A special form of unregistering for hotpluggable devices is drm_dev_unplug(), * which can be called while there are still open users of @dev. diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 22408badc617..782b95e72405 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -318,7 +318,7 @@ struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, if (IS_ERR(dma_buf)) return dma_buf; - drm_dev_ref(dev); + drm_dev_get(dev); drm_gem_object_get(exp_info->priv); return dma_buf; diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 71bbaaec836d..ee06ecd6c01f 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -155,7 +155,7 @@ struct drm_driver { * reverse order of the initialization. Similarly to the load * hook, this handler is deprecated and its usage should be * dropped in favor of an open-coded teardown function at the - * driver layer. See drm_dev_unregister() and drm_dev_unref() + * driver layer. See drm_dev_unregister() and drm_dev_put() * for the proper way to remove a &struct drm_device. * * The unload() hook is called right after unregistering @@ -611,7 +611,8 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, int drm_dev_register(struct drm_device *dev, unsigned long flags); void drm_dev_unregister(struct drm_device *dev); -void drm_dev_ref(struct drm_device *dev); +void drm_dev_get(struct drm_device *dev); +void drm_dev_put(struct drm_device *dev); void drm_dev_unref(struct drm_device *dev); void drm_put_dev(struct drm_device *dev); void drm_dev_unplug(struct drm_device *dev); diff --git a/scripts/coccinelle/api/drm-get-put.cocci b/scripts/coccinelle/api/drm-get-put.cocci index 0c7a9265c07e..dc10dee356c2 100644 --- a/scripts/coccinelle/api/drm-get-put.cocci +++ b/scripts/coccinelle/api/drm-get-put.cocci @@ -50,6 +50,9 @@ expression object; | - drm_property_unreference_blob(object) + drm_property_blob_put(object) +| +- drm_dev_unref(object) ++ drm_dev_put(object) ) @r depends on report@ @@ -81,6 +84,8 @@ drm_gem_object_unreference_unlocked(object) drm_property_unreference_blob@p(object) | drm_property_reference_blob@p(object) +| +drm_dev_unref@p(object) ) @script:python depends on report@ -- cgit v1.2.3 From ce7b700d1e0da806a5bcba19a197b050563df78f Mon Sep 17 00:00:00 2001 From: Aishwarya Pant Date: Tue, 26 Sep 2017 14:00:19 +0530 Subject: drm/tilcdc: replace reference/unreference() with get/put For maintaining consistency with kernel coding style replace reference/unreference in ref counting functions with get/put. The following cocci script was used to generate the tilcdc patch: @@ expression ex; @@ ( -drm_framebuffer_unreference(ex); +drm_framebuffer_put(ex); | -drm_dev_unref(ex); +drm_dev_put(ex); | -drm_framebuffer_reference(ex); +drm_framebuffer_get(ex); ) Signed-off-by: Aishwarya Pant Acked-by: Jyri Sarha Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/3f2f592f6ea28adfea3fd8b70421b2fab38f0b94.1506413698.git.aishpant@gmail.com --- drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 6 +++--- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index 406fe4544b83..d2589f310437 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c @@ -75,7 +75,7 @@ static void unref_worker(struct drm_flip_work *work, void *val) struct drm_device *dev = tilcdc_crtc->base.dev; mutex_lock(&dev->mode_config.mutex); - drm_framebuffer_unreference(val); + drm_framebuffer_put(val); mutex_unlock(&dev->mode_config.mutex); } @@ -456,7 +456,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc) set_scanout(crtc, fb); - drm_framebuffer_reference(fb); + drm_framebuffer_get(fb); crtc->hwmode = crtc->state->adjusted_mode; } @@ -633,7 +633,7 @@ int tilcdc_crtc_update_fb(struct drm_crtc *crtc, return -EBUSY; } - drm_framebuffer_reference(fb); + drm_framebuffer_get(fb); crtc->primary->fb = fb; tilcdc_crtc->event = event; diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index 146ac9a5a2fd..72ce063aa0d8 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c @@ -226,7 +226,7 @@ static void tilcdc_fini(struct drm_device *dev) pm_runtime_disable(dev->dev); - drm_dev_unref(dev); + drm_dev_put(dev); } static int tilcdc_init(struct drm_driver *ddrv, struct device *dev) -- cgit v1.2.3 From d9c8022475f9144a66e03df5d4818a3377df8d97 Mon Sep 17 00:00:00 2001 From: Haneen Mohammed Date: Tue, 26 Sep 2017 15:08:35 -0600 Subject: drm/doc: Remove todo item about "This is gross" comment This patch remove the todo item "Use new IDR deletion interface to clean up drm_gem_handle_delete()" after it has been resolved with the commit "drm: Remove obsolete "This is gross" comment". Signed-off-by: Haneen Mohammed Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20170926210835.GA4622@Haneen --- Documentation/gpu/todo.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index de9512afd611..5f4870289135 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -184,12 +184,6 @@ Contact: Sean Paul, Maintainer of the driver you plan to convert Core refactorings ================= -Use new IDR deletion interface to clean up drm_gem_handle_delete() ------------------------------------------------------------------- - -See the "This is gross" comment -- apparently the IDR system now can return an -error code instead of oopsing. - Clean up the DRM header mess ---------------------------- -- cgit v1.2.3 From ffeeeed0aee9f36635c8642ff40de863bbb4224a Mon Sep 17 00:00:00 2001 From: Aishwarya Pant Date: Tue, 26 Sep 2017 22:34:00 +0530 Subject: drm/core: clean up references to drm_dev_unref() This is a continuation of a previous commit ("drm: introduce drm_dev_{get/put} functions") to replace all references to drm_dev_unref() in drm core files with drm_dev_put(). Signed-off-by: Aishwarya Pant Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20170926170400.GA7671@aishwarya --- drivers/gpu/drm/drm_pci.c | 2 +- drivers/gpu/drm/drm_prime.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index 1235c9877d6f..4db9c515b74f 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c @@ -274,7 +274,7 @@ err_agp: drm_pci_agp_destroy(dev); pci_disable_device(pdev); err_free: - drm_dev_unref(dev); + drm_dev_put(dev); return ret; } EXPORT_SYMBOL(drm_get_pci_dev); diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 782b95e72405..8de93a226c24 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -342,7 +342,7 @@ void drm_gem_dmabuf_release(struct dma_buf *dma_buf) /* drop the reference on the export fd holds */ drm_gem_object_put_unlocked(obj); - drm_dev_unref(dev); + drm_dev_put(dev); } EXPORT_SYMBOL(drm_gem_dmabuf_release); -- cgit v1.2.3 From 9949b355dc1c259b4ed3c092b899b7e9cf166236 Mon Sep 17 00:00:00 2001 From: Meghana Madhyastha Date: Wed, 27 Sep 2017 16:21:23 +0530 Subject: drm/Documentation: Refine TODO for backlight helpers in tinydrm Add a summary which resulted from discussions on what should be done to refactor backlight helpers in tinydrm so that they can be used in other drivers as well. Signed-off-by: Meghana Madhyastha Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20170927105116.GA30391@meghana-HP-Pavilion-Notebook --- Documentation/gpu/todo.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index 5f4870289135..92ee2f982572 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -351,7 +351,16 @@ those drivers as simple as possible, so lots of room for refactoring: - backlight helpers, probably best to put them into a new drm_backlight.c. This is because drivers/video is de-facto unmaintained. We could also move drivers/video/backlight to drivers/gpu/backlight and take it all - over within drm-misc, but that's more work. + over within drm-misc, but that's more work. Backlight helpers require a fair + bit of reworking and refactoring. A simple example is the enabling of a backlight. + Tinydrm has helpers for this. It would be good if other drivers can also use the + helper. However, there are various cases we need to consider i.e different + drivers seem to have different ways of enabling/disabling a backlight. + We also need to consider the backlight drivers (like gpio_backlight). The situation + is further complicated by the fact that the backlight is tied to fbdev + via fb_notifier_callback() which has complicated logic. For further details, refer + to the following discussion thread: + https://groups.google.com/forum/#!topic/outreachy-kernel/8rBe30lwtdA - spi helpers, probably best put into spi core/helper code. Thierry said the spi maintainer is fast&reactive, so shouldn't be a big issue. -- cgit v1.2.3 From af2eca53206c59ce9308a4f5f46c4a104a179b6b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 15 Aug 2017 16:47:19 -0700 Subject: drm/vc4: Avoid using vrefresh==0 mode in DSI htotal math. The incoming mode might have a missing vrefresh field if it came from drmModeSetCrtc(), which the kernel is supposed to calculate using drm_mode_vrefresh(). We could either use that or the adjusted_mode's original vrefresh value. However, we can maintain a more exact vrefresh value (not just the integer approximation), by scaling by the ratio of our clocks. v2: Use math suggested by Andrzej Hajda instead. v3: Simplify math now that adjusted_mode->clock isn't padded. v4: Drop some parens. Signed-off-by: Eric Anholt Link: https://patchwork.freedesktop.org/patch/msgid/20170815234722.20700-2-eric@anholt.net Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/vc4/vc4_dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index d1e0dc908048..04796d7d0fdb 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -866,7 +866,8 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, adjusted_mode->clock = pixel_clock_hz / 1000 + 1; /* Given the new pixel clock, adjust HFP to keep vrefresh the same. */ - adjusted_mode->htotal = pixel_clock_hz / (mode->vrefresh * mode->vtotal); + adjusted_mode->htotal = adjusted_mode->clock * mode->htotal / + mode->clock; adjusted_mode->hsync_end += adjusted_mode->htotal - mode->htotal; adjusted_mode->hsync_start += adjusted_mode->htotal - mode->htotal; -- cgit v1.2.3 From 32ad958d85b92ee7068aa1de5917777be080cc3c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 15 Aug 2017 16:47:20 -0700 Subject: drm/vc4: Set up the DSI host at pdev probe time, not component bind. We need the following things to happen in sequence: DSI host creation DSI device creation in the panel driver (needs DSI host) DSI device attach from panel to host. DSI drm_panel_add() DSI encoder creation DSI encoder's DRM panel/bridge attach Unless we allow device creation while the host isn't up yet, we need to break the -EPROBE_DEFER deadlock between the panel driver looking up the host and the host driver looking up the panel. We can do so by moving the DSI host creation outside of the component bind loop, and the panel/bridge lookup/attach into the component bind process. Signed-off-by: Eric Anholt Link: https://patchwork.freedesktop.org/patch/msgid/20170815234722.20700-3-eric@anholt.net Reviewed-by: Archit Taneja --- drivers/gpu/drm/vc4/vc4_dsi.c | 97 +++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 04796d7d0fdb..925c726ac694 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -504,7 +505,6 @@ struct vc4_dsi { struct mipi_dsi_host dsi_host; struct drm_encoder *encoder; struct drm_bridge *bridge; - bool is_panel_bridge; void __iomem *regs; @@ -1289,7 +1289,6 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct vc4_dsi *dsi = host_to_dsi(host); - int ret = 0; dsi->lanes = device->lanes; dsi->channel = device->channel; @@ -1324,34 +1323,12 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host, return 0; } - dsi->bridge = of_drm_find_bridge(device->dev.of_node); - if (!dsi->bridge) { - struct drm_panel *panel = - of_drm_find_panel(device->dev.of_node); - - dsi->bridge = drm_panel_bridge_add(panel, - DRM_MODE_CONNECTOR_DSI); - if (IS_ERR(dsi->bridge)) { - ret = PTR_ERR(dsi->bridge); - dsi->bridge = NULL; - return ret; - } - dsi->is_panel_bridge = true; - } - - return drm_bridge_attach(dsi->encoder, dsi->bridge, NULL); + return 0; } static int vc4_dsi_host_detach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { - struct vc4_dsi *dsi = host_to_dsi(host); - - if (dsi->is_panel_bridge) { - drm_panel_bridge_remove(dsi->bridge); - dsi->bridge = NULL; - } - return 0; } @@ -1493,16 +1470,13 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) struct platform_device *pdev = to_platform_device(dev); struct drm_device *drm = dev_get_drvdata(master); struct vc4_dev *vc4 = to_vc4_dev(drm); - struct vc4_dsi *dsi; + struct vc4_dsi *dsi = dev_get_drvdata(dev); struct vc4_dsi_encoder *vc4_dsi_encoder; + struct drm_panel *panel; const struct of_device_id *match; dma_cap_mask_t dma_mask; int ret; - dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); - if (!dsi) - return -ENOMEM; - match = of_match_device(vc4_dsi_dt_match, dev); if (!match) return -ENODEV; @@ -1517,7 +1491,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) vc4_dsi_encoder->dsi = dsi; dsi->encoder = &vc4_dsi_encoder->base.base; - dsi->pdev = pdev; dsi->regs = vc4_ioremap_regs(pdev, 0); if (IS_ERR(dsi->regs)) return PTR_ERR(dsi->regs); @@ -1598,6 +1571,18 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) return ret; } + ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, + &panel, &dsi->bridge); + if (ret) + return ret; + + if (panel) { + dsi->bridge = devm_drm_panel_bridge_add(dev, panel, + DRM_MODE_CONNECTOR_DSI); + if (IS_ERR(dsi->bridge)) + return PTR_ERR(dsi->bridge); + } + /* The esc clock rate is supposed to always be 100Mhz. */ ret = clk_set_rate(dsi->escape_clock, 100 * 1000000); if (ret) { @@ -1616,12 +1601,11 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) DRM_MODE_ENCODER_DSI, NULL); drm_encoder_helper_add(dsi->encoder, &vc4_dsi_encoder_helper_funcs); - dsi->dsi_host.ops = &vc4_dsi_host_ops; - dsi->dsi_host.dev = dev; - - mipi_dsi_host_register(&dsi->dsi_host); - - dev_set_drvdata(dev, dsi); + ret = drm_bridge_attach(dsi->encoder, dsi->bridge, NULL); + if (ret) { + dev_err(dev, "bridge attach failed: %d\n", ret); + return ret; + } pm_runtime_enable(dev); @@ -1639,8 +1623,6 @@ static void vc4_dsi_unbind(struct device *dev, struct device *master, vc4_dsi_encoder_destroy(dsi->encoder); - mipi_dsi_host_unregister(&dsi->dsi_host); - if (dsi->port == 1) vc4->dsi1 = NULL; } @@ -1652,12 +1634,47 @@ static const struct component_ops vc4_dsi_ops = { static int vc4_dsi_dev_probe(struct platform_device *pdev) { - return component_add(&pdev->dev, &vc4_dsi_ops); + struct device *dev = &pdev->dev; + struct vc4_dsi *dsi; + int ret; + + dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); + if (!dsi) + return -ENOMEM; + dev_set_drvdata(dev, dsi); + + dsi->pdev = pdev; + + /* Note, the initialization sequence for DSI and panels is + * tricky. The component bind above won't get past its + * -EPROBE_DEFER until the panel/bridge probes. The + * panel/bridge will return -EPROBE_DEFER until it has a + * mipi_dsi_host to register its device to. So, we register + * the host during pdev probe time, so vc4 as a whole can then + * -EPROBE_DEFER its component bind process until the panel + * successfully attaches. + */ + dsi->dsi_host.ops = &vc4_dsi_host_ops; + dsi->dsi_host.dev = dev; + mipi_dsi_host_register(&dsi->dsi_host); + + ret = component_add(&pdev->dev, &vc4_dsi_ops); + if (ret) { + mipi_dsi_host_unregister(&dsi->dsi_host); + return ret; + } + + return 0; } static int vc4_dsi_dev_remove(struct platform_device *pdev) { + struct device *dev = &pdev->dev; + struct vc4_dsi *dsi = dev_get_drvdata(dev); + component_del(&pdev->dev, &vc4_dsi_ops); + mipi_dsi_host_unregister(&dsi->dsi_host); + return 0; } -- cgit v1.2.3 From 7f909d9c74f3894ba8bca426ead8ccbe7282d950 Mon Sep 17 00:00:00 2001 From: Haneen Mohammed Date: Wed, 27 Sep 2017 12:23:17 -0600 Subject: drm/rockchip: Rely on the default best_encoder() behavior Since the output has 1:1 relationship between connectors and encoders, and the driver is relying on the atomic helpers, remove the custom best_encoder() and let the core call drm_atomic_helper_best_encoder(). Signed-off-by: Haneen Mohammed Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/20170927182317.GA8249@Haneen --- drivers/gpu/drm/rockchip/cdn-dp-core.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c index a57da051f516..275844d0d0ec 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c @@ -287,14 +287,6 @@ static int cdn_dp_connector_get_modes(struct drm_connector *connector) return ret; } -static struct drm_encoder * -cdn_dp_connector_best_encoder(struct drm_connector *connector) -{ - struct cdn_dp_device *dp = connector_to_dp(connector); - - return &dp->encoder; -} - static int cdn_dp_connector_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { @@ -346,7 +338,6 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector, static struct drm_connector_helper_funcs cdn_dp_connector_helper_funcs = { .get_modes = cdn_dp_connector_get_modes, - .best_encoder = cdn_dp_connector_best_encoder, .mode_valid = cdn_dp_connector_mode_valid, }; -- cgit v1.2.3 From a33d7f8c06b32ae0396dce42eeb2775644bf23b9 Mon Sep 17 00:00:00 2001 From: Haneen Mohammed Date: Wed, 27 Sep 2017 01:38:46 -0600 Subject: drm/armada: Remove unused #include Remove drmP.h as it is not needed anymore since nothing it defines is used in these files. Signed-off-by: Haneen Mohammed Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20170927073846.GA14352@Haneen --- drivers/gpu/drm/armada/armada_510.c | 1 - drivers/gpu/drm/armada/armada_drv.c | 1 - drivers/gpu/drm/armada/armada_fb.c | 1 - drivers/gpu/drm/armada/armada_fbdev.c | 1 - drivers/gpu/drm/armada/armada_gem.c | 1 - 5 files changed, 5 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_510.c b/drivers/gpu/drm/armada/armada_510.c index ad3d2ebf95c9..41a784f5a5e6 100644 --- a/drivers/gpu/drm/armada/armada_510.c +++ b/drivers/gpu/drm/armada/armada_510.c @@ -9,7 +9,6 @@ */ #include #include -#include #include #include "armada_crtc.h" #include "armada_drm.h" diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 2fbd9d3393e8..2d45103d06cb 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include "armada_crtc.h" diff --git a/drivers/gpu/drm/armada/armada_fb.c b/drivers/gpu/drm/armada/armada_fb.c index 92e6b08ea64a..b9e1637cc4cf 100644 --- a/drivers/gpu/drm/armada/armada_fb.c +++ b/drivers/gpu/drm/armada/armada_fb.c @@ -5,7 +5,6 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#include #include #include #include "armada_drm.h" diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c index 29c7d047b152..10e3fd87a83b 100644 --- a/drivers/gpu/drm/armada/armada_fbdev.c +++ b/drivers/gpu/drm/armada/armada_fbdev.c @@ -10,7 +10,6 @@ #include #include -#include #include #include "armada_crtc.h" #include "armada_drm.h" diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c index 79835380d5c6..7837e6adb16f 100644 --- a/drivers/gpu/drm/armada/armada_gem.c +++ b/drivers/gpu/drm/armada/armada_gem.c @@ -8,7 +8,6 @@ #include #include #include -#include #include "armada_drm.h" #include "armada_gem.h" #include -- cgit v1.2.3 From 4ea30958d96b3f997afadeeb9de29e6dea3a80f5 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 22 Sep 2017 17:05:16 +0100 Subject: drm/tve200: make two functions static The functions tve200_display_disable and tve200_display_funcs are local to the source and do not need to be in global scope, so make them static. Cleans up sparse warnings: symbol 'tve200_display_disable' was not declared. Should it be static? symbol 'tve200_display_funcs' was not declared. Should it be static? Signed-off-by: Colin Ian King Signed-off-by: Linus Walleij Link: https://patchwork.freedesktop.org/patch/msgid/20170922160516.16283-1-colin.king@canonical.com --- drivers/gpu/drm/tve200/tve200_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tve200/tve200_display.c b/drivers/gpu/drm/tve200/tve200_display.c index 18457de47bbc..904e38b93530 100644 --- a/drivers/gpu/drm/tve200/tve200_display.c +++ b/drivers/gpu/drm/tve200/tve200_display.c @@ -221,7 +221,7 @@ static void tve200_display_enable(struct drm_simple_display_pipe *pipe, drm_crtc_vblank_on(crtc); } -void tve200_display_disable(struct drm_simple_display_pipe *pipe) +static void tve200_display_disable(struct drm_simple_display_pipe *pipe) { struct drm_crtc *crtc = &pipe->crtc; struct drm_device *drm = crtc->dev; @@ -293,7 +293,7 @@ static int tve200_display_prepare_fb(struct drm_simple_display_pipe *pipe, return drm_fb_cma_prepare_fb(&pipe->plane, plane_state); } -const struct drm_simple_display_pipe_funcs tve200_display_funcs = { +static const struct drm_simple_display_pipe_funcs tve200_display_funcs = { .check = tve200_display_check, .enable = tve200_display_enable, .disable = tve200_display_disable, -- cgit v1.2.3 From 44390ef519006b13c8fab9eb13abac909342a585 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 25 Sep 2017 13:25:20 +0300 Subject: drm/tve200: Check for IS_ERR instead of NULL in probe devm_ioremap_resource() returns error pointer, it never returns NULL on error. Fixes: 179c02fe90a4 ("drm/tve200: Add new driver for TVE200") Signed-off-by: Dan Carpenter Signed-off-by: Linus Walleij Link: https://patchwork.freedesktop.org/patch/msgid/20170925102520.a7spymwqqbsczzz2@mwanda --- drivers/gpu/drm/tve200/tve200_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tve200/tve200_drv.c b/drivers/gpu/drm/tve200/tve200_drv.c index eae38b669f0a..6939f7455a2d 100644 --- a/drivers/gpu/drm/tve200/tve200_drv.c +++ b/drivers/gpu/drm/tve200/tve200_drv.c @@ -225,7 +225,7 @@ static int tve200_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->regs = devm_ioremap_resource(dev, res); - if (!priv->regs) { + if (IS_ERR(priv->regs)) { dev_err(dev, "%s failed mmio\n", __func__); ret = -EINVAL; goto clk_disable; -- cgit v1.2.3 From 320e421ea303b1e53451b2b4cd3ad18cdd043b3b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 25 Sep 2017 13:30:38 +0300 Subject: drm: of: always initialize panel in drm_of_find_panel_or_bridge() The callers expect "panel" to be initialized, but that isn't true if we return -ENODEV. It causes bugs like: drivers/gpu/drm/tve200/tve200_drv.c:83 tve200_modeset_init() error: uninitialized symbol 'panel'. Signed-off-by: Dan Carpenter Signed-off-by: Linus Walleij Link: https://patchwork.freedesktop.org/patch/msgid/20170925103038.lvr5msjvekwczctn@mwanda --- drivers/gpu/drm/drm_of.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 8dafbdfcd2ea..4c191c050e7d 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -233,6 +233,8 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, if (!panel && !bridge) return -EINVAL; + if (panel) + *panel = NULL; remote = of_graph_get_remote_node(np, port, endpoint); if (!remote) -- cgit v1.2.3 From cce1a87788eb607e9616fe0d1c04f5da72141068 Mon Sep 17 00:00:00 2001 From: Noralf Trønnes Date: Sun, 24 Sep 2017 14:26:16 +0200 Subject: drm/tinydrm: Use drm_gem_framebuffer_helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use drm_gem_framebuffer_helper directly instead of the cma library wrappers. Signed-off-by: Noralf Trønnes Reviewed-by: Eric Anholt Link: https://patchwork.freedesktop.org/patch/msgid/1506255985-61113-2-git-send-email-noralf@tronnes.org --- drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 3 ++- drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 5 +++-- drivers/gpu/drm/tinydrm/mipi-dbi.c | 5 +++-- drivers/gpu/drm/tinydrm/repaper.c | 5 +++-- drivers/gpu/drm/tinydrm/st7586.c | 5 +++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c index 551709e6b114..1a8a57cad431 100644 --- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -128,7 +129,7 @@ tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv, { struct tinydrm_device *tdev = drm->dev_private; - return drm_fb_cma_create_with_funcs(drm, file_priv, mode_cmd, + return drm_gem_fb_create_with_funcs(drm, file_priv, mode_cmd, tdev->fb_funcs); } diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c b/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c index 177e9d861001..fc447c9a1a27 100644 --- a/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -144,7 +145,7 @@ EXPORT_SYMBOL(tinydrm_display_pipe_update); * @pipe: Simple display pipe * @plane_state: Plane state * - * This function uses drm_fb_cma_prepare_fb() to check if the plane FB has an + * This function uses drm_gem_fb_prepare_fb() to check if the plane FB has an * dma-buf attached, extracts the exclusive fence and attaches it to plane * state for the atomic helper to wait on. Drivers can use this as their * &drm_simple_display_pipe_funcs->prepare_fb callback. @@ -152,7 +153,7 @@ EXPORT_SYMBOL(tinydrm_display_pipe_update); int tinydrm_display_pipe_prepare_fb(struct drm_simple_display_pipe *pipe, struct drm_plane_state *plane_state) { - return drm_fb_cma_prepare_fb(&pipe->plane, plane_state); + return drm_gem_fb_prepare_fb(&pipe->plane, plane_state); } EXPORT_SYMBOL(tinydrm_display_pipe_prepare_fb); diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index f0dedc244944..d43e992ab432 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -9,6 +9,7 @@ * (at your option) any later version. */ +#include #include #include #include @@ -253,8 +254,8 @@ out_unlock: } static const struct drm_framebuffer_funcs mipi_dbi_fb_funcs = { - .destroy = drm_fb_cma_destroy, - .create_handle = drm_fb_cma_create_handle, + .destroy = drm_gem_fb_destroy, + .create_handle = drm_gem_fb_create_handle, .dirty = mipi_dbi_fb_dirty, }; diff --git a/drivers/gpu/drm/tinydrm/repaper.c b/drivers/gpu/drm/tinydrm/repaper.c index 5fbe14715c83..340198f5afea 100644 --- a/drivers/gpu/drm/tinydrm/repaper.c +++ b/drivers/gpu/drm/tinydrm/repaper.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -636,8 +637,8 @@ out_unlock: } static const struct drm_framebuffer_funcs repaper_fb_funcs = { - .destroy = drm_fb_cma_destroy, - .create_handle = drm_fb_cma_create_handle, + .destroy = drm_gem_fb_destroy, + .create_handle = drm_gem_fb_create_handle, .dirty = repaper_fb_dirty, }; diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c index 07b4d312784c..da9c0d83045f 100644 --- a/drivers/gpu/drm/tinydrm/st7586.c +++ b/drivers/gpu/drm/tinydrm/st7586.c @@ -17,6 +17,7 @@ #include #include