drm/tegra: Convert to master/component framework
Subsystems (6)
cover drm/tegra: Convert to master/component framework
From: Thierry Reding <[email protected]>
Hi,
This series converts the Tegra DRM driver to the master/component framework. The length of the series and the list of people in Cc is mostly due to the fact that Tegra has some special requirements as opposed to other drivers and therefore requires some changes outside of DRM.
Patches 1 and 2 make some changes to the master/component framework which are necessary to convert Tegra DRM to use it. Note that since I'm looking for early review I haven't converted any of the existing users since I'm not sure if these are acceptable changes.
Patch 3 adds a new interface framework that supplements the master/ component framework and can be used in situations where there is no struct device * that a driver can bind to.
A new function is introduced in patch 4 which can be used to get rid of the DRM bus infrastructure in individual drivers. It should be able to replace the requirement of having a drm_bus for all USB and platform DRM drivers. For backwards-compatibility with legacy PCI drivers some- thing different will probably be needed.
Finally, patch 5 converts the Tegra DRM driver over to using the master/ component framework using the above four patches.
Each patch has a somewhat more elaborate description of why it is needed or what problem it solves. The patchset applies on top of linux-next with Daniel's DRM cleanup series applied.
I welcome any questions or comments you might have.
Thierry
Thierry Reding (5):
drivers/base: Allow multiple masters per device drivers/base: Allow driver-data to be attached to a master drivers/base: Add interface framework
drm: Introduce drm_set_unique()
drm/tegra: Convert to master/component framework
drivers/base/Makefile | 2 +- drivers/base/component.c | 31 ++- drivers/base/interface.c | 186 ++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 37 ++- drivers/gpu/drm/drm_stub.c | 1 + drivers/gpu/drm/tegra/Makefile | 1 - drivers/gpu/drm/tegra/bus.c | 64 ----- drivers/gpu/drm/tegra/dc.c | 58 ++--- drivers/gpu/drm/tegra/drm.c | 171 +++++++++---- drivers/gpu/drm/tegra/drm.h | 27 +- drivers/gpu/drm/tegra/dsi.c | 144 +++++------ drivers/gpu/drm/tegra/gr2d.c | 78 +++--- drivers/gpu/drm/tegra/gr3d.c | 77 +++--- drivers/gpu/drm/tegra/hdmi.c | 69 ++--- drivers/gpu/drm/tegra/sor.c | 71 ++---- drivers/gpu/host1x/Makefile | 1 - drivers/gpu/host1x/bus.c | 553 ----------------------------------------- drivers/gpu/host1x/bus.h | 29 --- drivers/gpu/host1x/dev.c | 21 +- drivers/gpu/host1x/dev.h | 7 +- include/drm/drmP.h | 3 + include/linux/component.h | 20 +- include/linux/host1x.h | 64 +---- include/linux/interface.h | 40 +++ 24 files changed, 625 insertions(+), 1130 deletions(-) create mode 100644 drivers/base/interface.c delete mode 100644 drivers/gpu/drm/tegra/bus.c delete mode 100644 drivers/gpu/host1x/bus.c delete mode 100644 drivers/gpu/host1x/bus.h create mode 100644 include/linux/interface.h
Signature · 1 line
1.9.2
RFC 1/5 drivers/base: Allow multiple masters per device
From: Thierry Reding <[email protected]>
Currently the component/master framework allows only a single master to be registered against a struct device. A master is uniquely identified by the device and the master operations table, but the current API does not pass enough information along to allow a master to be uniquely identified when calling component_unbind_all().
To make it possible to register multiple masters on one device, instead of passing around the device associated with a master, pass around the master directly. That way it can always be uniquely identified.
--- drivers/base/component.c | 18 +++++++----------- include/linux/component.h | 17 ++++++++--------- 2 files changed, 15 insertions(+), 20 deletions(-)
drivers/base/component.c +7 -11
@@ -120,7 +120,7 @@ static int try_to_bring_up_master(struct master *master,* Search the list of components, looking for components that * belong to this master, and attach them to the master. */ -if (master->ops->add_components (master->dev, master)) { +if (master->ops->add_components (master, master->dev)) {/* Failed to find all components */ master_remove_components (master); ret =0 ;
@@ -139,7 +139,7 @@ static int try_to_bring_up_master(struct master *master, }/* Found all components */ - ret = master->ops->bind (master->dev); + ret = master->ops->bind (master, master->dev);if (ret <0 ) {devres_release_group (master->dev,NULL );dev_info (master->dev,"master bind failed: %d\n" , ret);
@@ -172,7 +172,7 @@ static int try_to_bring_up_masters(struct component *component)static void take_down_master (struct master *master) {if (master->bound) { - master->ops->unbind (master->dev); + master->ops->unbind (master, master->dev);devres_release_group (master->dev,NULL ); master->bound = false; }
@@ -233,21 +233,19 @@ static void component_unbind(struct component *component, {WARN_ON (!component->bound); - component->ops->unbind (component->dev, master->dev, data); + component->ops->unbind (component->dev, master, data); component->bound = false;/* Release all resources claimed in the binding of this component */ devres_release_group (component->dev, component); } -void component_unbind_all (struct device *master_dev,void *data) +void component_unbind_all (struct master *master,void *data) { -struct master *master;struct component *c;WARN_ON (!mutex_is_locked (&component_mutex)); - master =__master_find (master_dev,NULL );if (!master)return ;
@@ -282,7 +280,7 @@ static int component_bind(struct component *component, struct master *master,dev_dbg (master->dev,"binding %s (ops %ps)\n" ,dev_name (component->dev), component->ops); - ret = component->ops->bind (component->dev, master->dev, data); + ret = component->ops->bind (component->dev, master, data);if (!ret) { component->bound = true;
@@ -308,15 +306,13 @@ static int component_bind(struct component *component, struct master *master,return ret; } -int component_bind_all (struct device *master_dev,void *data) +int component_bind_all (struct master *master,void *data) { -struct master *master;struct component *c;int ret =0 ;WARN_ON (!mutex_is_locked (&component_mutex)); - master =__master_find (master_dev,NULL );if (!master)return -EINVAL ;
include/linux/component.h +8 -9
@@ -2,24 +2,23 @@#define COMPONENT_H struct device ; +struct master ;struct component_ops { -int (*bind)(struct device *,struct device *,void *); -void (*unbind)(struct device *,struct device *,void *); +int (*bind)(struct device *,struct master *,void *); +void (*unbind)(struct device *,struct master *,void *); };int component_add (struct device *,const struct component_ops *);void component_del (struct device *,const struct component_ops *); -int component_bind_all (struct device *,void *); -void component_unbind_all (struct device *,void *); - -struct master ; +int component_bind_all (struct master *,void *); +void component_unbind_all (struct master *,void *);struct component_master_ops { -int (*add_components)(struct device *,struct master *); -int (*bind)(struct device *); -void (*unbind)(struct device *); +int (*add_components)(struct master *,struct device *); +int (*bind)(struct master *,struct device *); +void (*unbind)(struct master *,struct device *); };int component_master_add (struct device *,const struct component_master_ops *);
Signature · 1 line
1.9.2
RFC 2/5 drivers/base: Allow driver-data to be attached to a master
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Similarly to what can be done for device drivers, allow driver-specific data to be attached to a master. This is necessary for masters whose device is already bound to by a different driver and therefore cannot be used to store the driver-specific data.
--- drivers/base/component.c | 13 +++++++++++++ include/linux/component.h | 3 +++ 2 files changed, 16 insertions(+)
drivers/base/component.c +13 -0
@@ -25,6 +25,8 @@ struct master {const struct component_master_ops *ops;struct device *dev; + +void *drvdata; };struct component {
@@ -53,6 +55,17 @@ static struct master *__master_find(struct device *dev,return NULL ; } +void master_set_drvdata (struct master *master,void *data) +{ +if (master) + master->drvdata = data; +} + +void *master_get_drvdata (struct master *master) +{ +return master ? master->drvdata :NULL ; +} +/* Attach an unattached component to a master. */ static void component_attach_master (struct master *master,struct component *c) {
include/linux/component.h +3 -0
@@ -25,6 +25,9 @@ int component_master_add(struct device *, const struct component_master_ops *);void component_master_del (struct device *,const struct component_master_ops *); +void master_set_drvdata (struct master *,void *); +void *master_get_drvdata (struct master *); +int component_master_add_child (struct master *master,int (*compare)(struct device *,void *),void *compare_data);
Signature · 1 line
1.9.2
RFC 3/5 drivers/base: Add interface framework
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Some drivers, such as graphics drivers in the DRM subsystem, do not have a real device that they can bind to. They are often composed of several devices, each having their own driver. The master/component framework can be used in these situations to collect the devices pertaining to one logical device, wait until all of them have registered and then bind them all at once.
For some situations this is only a partial solution. An implementation of a master still needs to be registered with the system somehow. Many drivers currently resort to creating a dummy device that a driver can bind to and register the master against. This is problematic since it requires (and presumes) knowledge about the system within drivers.
Furthermore there are setups where a suitable device already exists, but is already bound to a driver. For example, on Tegra the following device tree extract (simplified) represents the host1x device along with child devices:
host1x {
display-controller {
...
};
display-controller {
...
};
hdmi {
...
};
dsi {
...
};
csi {
...
};
video-input {
...
};
};Each of the child devices is in turn a client of host1x, in that it can request resources (command stream DMA channels and syncpoints) from it. To implement the DMA channel and syncpoint infrastructure, host1x comes with its own driver. Children are implemented in separate drivers. In Linux this set of devices would be exposed by DRM and V4L2 drivers.
However, neither the DRM nor the V4L2 drivers have a single device that they can bind to. The DRM device is composed of the display controllers and the various output devices, whereas the V4L2 device is composed of one or more video input devices.
This patch introduces the concept of an interface and drivers that can bind to a given interface. An interface can be exposed by any device, and interface drivers can bind to these interfaces. Multiple drivers can bind against a single interface. When a device is removed, interfaces exposed by it will be removed as well, thereby removing the drivers that were bound to those interfaces.
In the example above, the host1x device would expose the "tegra-host1x" interface. DRM and V4L2 drivers can then bind to that interface and instantiate the respective subsystem objects from there.
--- drivers/base/Makefile | 2 +- drivers/base/interface.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/interface.h | 40 ++++++++++ 3 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 drivers/base/interface.c create mode 100644 include/linux/interface.h
drivers/base/Makefile +1 -1
@@ -4,7 +4,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \ driver.o class.o platform.o \ cpu.o firmware.o init.o map.o devres.o \ attribute_container.o transport_class.o \ - topology.o container.o + topology.o container.o interface.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o obj-$(CONFIG_DMA_CMA) += dma-contiguous.o obj-y += power/
drivers/base/interface.c new file +186 -0
186 lines not on this page · raw message
include/linux/interface.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2014 NVIDIA Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef INTERFACE_H +#define INTERFACE_H + +#include <linux/list.h> + +struct device ; +struct interface ; + +struct interface_driver { +const char *name; + +int (*bind)(struct interface *intf); +void (*unbind)(struct interface *intf); + +struct list_head list; +}; + +int interface_register_driver (struct interface_driver *driver); +void interface_unregister_driver (struct interface_driver *driver); + +struct interface { +const char *name; +struct device *dev; + +struct list_head drivers; +struct list_head list; +}; + +int interface_add (struct interface *intf); +void interface_remove (struct interface *intf); + +#endif
Signature · 1 line
1.9.2
RFC 4/5 drm: Introduce drm_set_unique()
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Add a helper function that allows drivers to statically set the unique name of the device. This will allow platform and USB drivers to get rid of their DRM bus implementations and directly use drm_dev_alloc() and drm_dev_register().
--- drivers/gpu/drm/drm_ioctl.c | 37 +++++++++++++++++++++++++++++++------ drivers/gpu/drm/drm_stub.c | 1 + include/drm/drmP.h | 3 +++ 3 files changed, 35 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_ioctl.c +31 -6
@@ -42,6 +42,20 @@#include <asm/mtrr.h> #endif +int drm_set_unique (struct drm_device *dev,const char *fmt, ...) +{ +va_list ap; + +kfree (dev->unique); + +va_start (ap, fmt); + dev->unique =kvasprintf (GFP_KERNEL , fmt, ap); +va_end (ap); + +return dev->unique ?0 : -ENOMEM ; +} +EXPORT_SYMBOL (drm_set_unique); +/** * Get the bus id. *
@@ -131,13 +145,24 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)if (master->unique !=NULL )drm_unset_busid (dev, master); - ret = dev->driver->bus->set_busid (dev, master); -if (ret) - goto err; +if (dev->driver->bus && dev->driver->bus->set_busid) { + ret = dev->driver->bus->set_busid (dev, master); +if (ret) { +drm_unset_busid (dev, master); +return ret; + } + }else { +WARN (dev->unique ==NULL , +"No drm_bus.set_busid() implementation provided by %ps. " +"Set the unique name explicitly using drm_set_unique()." , + dev->driver); + + master->unique =kstrdup (dev->unique,GFP_KERNEL ); +if (master->unique) + master->unique_len =strlen (dev->unique); + } +return 0 ; -err: -drm_unset_busid (dev, master); -return ret; }/**
drivers/gpu/drm/drm_stub.c +1 -0
@@ -646,6 +646,7 @@ static void drm_dev_release(struct kref *ref)drm_minor_free (dev,DRM_MINOR_CONTROL );mutex_destroy (&dev->master_mutex); +kfree (dev->unique);kfree (dev); }
include/drm/drmP.h +3 -0
@@ -1158,6 +1158,8 @@ struct drm_device {struct drm_vma_offset_manager *vma_offset_manager;/*@} */ int switch_power_state; + +char *unique; };#define DRM_SWITCH_POWER_ON 0
@@ -1238,6 +1240,7 @@ extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);/* Misc. IOCTL support (drm_ioctl.h) */ extern int drm_irq_by_busid (struct drm_device *dev,void *data,struct drm_file *file_priv); +extern int drm_set_unique (struct drm_device *dev,const char *fmt, ...);extern int drm_getunique (struct drm_device *dev,void *data,struct drm_file *file_priv); extern int drm_setunique(struct drm_device *dev, void *data,
Signature · 1 line
1.9.2
RFC 5/5 drm/tegra: Convert to master/component framework
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Instead of the current implementation, reuse the recently introduced master/component framework, which is equivalent in most regards. One issue is that there is no device to bind the DRM driver to. In order to still allow the driver to be probed, expose an interface from the host1x device and provide an interface driver to bind to that.
The interface driver then registers (or removes) the master that will be used to instantiate and bind the DRM driver. Since the drm_host1x bus implementation is now gone the dummy device instantiated by it can no longer be used as the parent for the DRM device. However since the parent device doesn't need to be modified, the host1x parent device that exposes the interface can be used instead.
--- drivers/gpu/drm/tegra/Makefile | 1 - drivers/gpu/drm/tegra/bus.c | 64 ----- drivers/gpu/drm/tegra/dc.c | 58 ++--- drivers/gpu/drm/tegra/drm.c | 171 +++++++++---- drivers/gpu/drm/tegra/drm.h | 27 +- drivers/gpu/drm/tegra/dsi.c | 144 +++++------ drivers/gpu/drm/tegra/gr2d.c | 78 +++--- drivers/gpu/drm/tegra/gr3d.c | 77 +++--- drivers/gpu/drm/tegra/hdmi.c | 69 ++--- drivers/gpu/drm/tegra/sor.c | 71 ++---- drivers/gpu/host1x/Makefile | 1 - drivers/gpu/host1x/bus.c | 553 ----------------------------------------- drivers/gpu/host1x/bus.h | 29 --- drivers/gpu/host1x/dev.c | 21 +- drivers/gpu/host1x/dev.h | 7 +- include/linux/host1x.h | 64 +---- 16 files changed, 332 insertions(+), 1103 deletions(-) delete mode 100644 drivers/gpu/drm/tegra/bus.c delete mode 100644 drivers/gpu/host1x/bus.c delete mode 100644 drivers/gpu/host1x/bus.h
drivers/gpu/drm/tegra/Makefile +0 -1
@@ -1,7 +1,6 @@ ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG tegra-drm-y := \ - bus.o \ drm.o \ gem.o \ fb.o \
drivers/gpu/drm/tegra/bus.c deleted +0 -64
64 lines not on this page · raw message
drivers/gpu/drm/tegra/dc.c +22 -36
126 lines not on this page · raw message
drivers/gpu/drm/tegra/drm.c +117 -54
288 lines not on this page · raw message
drivers/gpu/drm/tegra/drm.h +6 -21
@@ -36,6 +36,7 @@ struct tegra_fbdev {struct tegra_drm {struct drm_device *drm; +struct master *master;struct mutex clients_lock;struct list_head clients;
@@ -68,31 +69,25 @@ int tegra_drm_submit(struct tegra_drm_context *context, struct drm_file *file);struct tegra_drm_client { -struct host1x_client base;struct list_head list; +struct device *dev; + +enum host1x_class class; +struct host1x_syncpt **syncpts; +unsigned int num_syncpts;const struct tegra_drm_client_ops *ops; }; -static inline struct tegra_drm_client * -host1x_to_drm_client (struct host1x_client *client) -{ - return container_of(client, struct tegra_drm_client, base); -} -int tegra_drm_register_client (struct tegra_drm *tegra,struct tegra_drm_client *client);int tegra_drm_unregister_client (struct tegra_drm *tegra,struct tegra_drm_client *client); -int tegra_drm_init (struct tegra_drm *tegra,struct drm_device *drm); -int tegra_drm_exit (struct tegra_drm *tegra); -struct tegra_dc_soc_info ;struct tegra_output ;struct tegra_dc { -struct host1x_client client;struct device *dev;spinlock_t lock;
@@ -118,12 +113,6 @@ struct tegra_dc {const struct tegra_dc_soc_info *soc; }; -static inline struct tegra_dc * -host1x_client_to_dc (struct host1x_client *client) -{ - return container_of(client, struct tegra_dc, client); -} -static inline struct tegra_dc *to_tegra_dc (struct drm_crtc *crtc) { return crtc ? container_of(crtc, struct tegra_dc, base) : NULL;
@@ -249,10 +238,6 @@ static inline int tegra_output_check_mode(struct tegra_output *output,return output ? -ENOSYS : -EINVAL ; } -/* from bus.c */ -int drm_host1x_init (struct drm_driver *driver,struct host1x_device *device); -void drm_host1x_exit (struct drm_driver *driver,struct host1x_device *device); -/* from rgb.c */ int tegra_dc_rgb_probe (struct tegra_dc *dc);int tegra_dc_rgb_remove (struct tegra_dc *dc);
drivers/gpu/drm/tegra/dsi.c +60 -84
190 lines not on this page · raw message
drivers/gpu/drm/tegra/gr2d.c +35 -43
130 lines not on this page · raw message
drivers/gpu/drm/tegra/gr3d.c +35 -42
129 lines not on this page · raw message
drivers/gpu/drm/tegra/hdmi.c +22 -47
147 lines not on this page · raw message
drivers/gpu/drm/tegra/sor.c +22 -49
155 lines not on this page · raw message
drivers/gpu/host1x/Makefile +0 -1
@@ -1,5 +1,4 @@ host1x-y = \ - bus.o \ syncpt.o \ dev.o \ intr.o \
drivers/gpu/host1x/bus.c deleted +0 -553
553 lines not on this page · raw message
drivers/gpu/host1x/bus.h deleted +0 -29
@@ -1,29 +0,0 @@ -/* -* Copyright (C) 2012 Avionic Design GmbH -* Copyright (C) 2012-2013, NVIDIA Corporation -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef HOST1X_BUS_H -#define HOST1X_BUS_H - -struct host1x ; - -int host1x_bus_init (void ); -void host1x_bus_exit (void ); - -int host1x_register (struct host1x *host1x); -int host1x_unregister (struct host1x *host1x); - -#endif
drivers/gpu/host1x/dev.c +8 -13
@@ -27,7 +27,6 @@#define CREATE_TRACE_POINTS #include <trace/events/host1x.h> -#include "bus.h" #include "dev.h" #include "intr.h" #include "channel.h"
@@ -124,8 +123,8 @@ static int host1x_probe(struct platform_device *pdev)if (!host)return -ENOMEM ; -mutex_init (&host->devices_lock); -INIT_LIST_HEAD (&host->devices); +mutex_init (&host->masters_lock); +INIT_LIST_HEAD (&host->masters);INIT_LIST_HEAD (&host->list); host->dev = &pdev->dev; host->info = id->data;
@@ -176,7 +175,10 @@ static int host1x_probe(struct platform_device *pdev)host1x_debug_init (host); - err =host1x_register (host); + host->interface.name ="nvidia,tegra-host1x" ; + host->interface.dev = &pdev->dev; + + err =interface_add (&host->interface);if (err <0 ) goto fail_deinit_intr;
@@ -195,7 +197,7 @@ static int host1x_remove(struct platform_device *pdev) {struct host1x *host =platform_get_drvdata (pdev); -host1x_unregister (host); +interface_remove (&host->interface);host1x_intr_deinit (host);host1x_syncpt_deinit (host);clk_disable_unprepare (host->clk);
@@ -216,13 +218,9 @@ static int __init tegra_host1x_init(void) {int err; - err =host1x_bus_init (); -if (err <0 ) -return err; - err =platform_driver_register (&tegra_host1x_driver);if (err <0 ) - goto unregister_bus; +return err; err =platform_driver_register (&tegra_mipi_driver);if (err <0 )
@@ -232,8 +230,6 @@ static int __init tegra_host1x_init(void) unregister_host1x:platform_driver_unregister (&tegra_host1x_driver); -unregister_bus: -host1x_bus_exit ();return err; }module_init (tegra_host1x_init);
@@ -242,7 +238,6 @@ static void __exit tegra_host1x_exit(void) {platform_driver_unregister (&tegra_mipi_driver);platform_driver_unregister (&tegra_host1x_driver); -host1x_bus_exit (); }module_exit (tegra_host1x_exit);
drivers/gpu/host1x/dev.h +4 -3
@@ -17,6 +17,7 @@#ifndef HOST1X_DEV_H #define HOST1X_DEV_H +#include <linux/interface.h> #include <linux/platform_device.h> #include <linux/device.h>
@@ -127,9 +128,9 @@ struct host1x {struct dentry *debugfs; -struct mutex devices_lock; -struct list_head devices; - +struct interface interface; +struct mutex masters_lock; +struct list_head masters;struct list_head list; };
include/linux/host1x.h +1 -63
82 lines not on this page · raw message
Signature · 1 line
1.9.2
Re: [RFC 4/5] drm: Introduce drm_set_unique()
In reply to Thierry RedingQuoted 19 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Add a helper function that allows drivers to statically set the unique name of the device. This will allow platform and USB drivers to get rid of their DRM bus implementations and directly use
drm_dev_alloc()anddrm_dev_register().Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/drm_ioctl.c | 37 +++++++++++++++++++++++++++++++------ drivers/gpu/drm/drm_stub.c | 1 + include/drm/drmP.h | 3 +++ 3 files changed, 35 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_ioctl.c +0
-0
drivers/gpu/drm/drm_ioctl.c line 45
Quoted 4 lines
drivers/gpu/drm/drm_ioctl.c +1
-0@@ -42,6 +42,20 @@#include <asm/mtrr.h> #endif +int drm_set_unique (struct drm_device *dev,const char *fmt, ...)
Can you please add a bit of kerneldoc for this? drm_ioctl.c isn't yet pulled into the drm reference docbook, but better to have it there already. With that fixed this is
Quoted 87 lines
drivers/gpu/drm/drm_ioctl.c +30
-6+{ +va_list ap; + +kfree (dev->unique); + +va_start (ap, fmt); + dev->unique =kvasprintf (GFP_KERNEL , fmt, ap); +va_end (ap); + +return dev->unique ?0 : -ENOMEM ; +} +EXPORT_SYMBOL (drm_set_unique); +/** * Get the bus id. * @@ -131,13 +145,24 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)if (master->unique !=NULL )drm_unset_busid (dev, master); - ret = dev->driver->bus->set_busid (dev, master); -if (ret) - goto err; +if (dev->driver->bus && dev->driver->bus->set_busid) { + ret = dev->driver->bus->set_busid (dev, master); +if (ret) { +drm_unset_busid (dev, master); +return ret; + } + }else { +WARN (dev->unique ==NULL , +"No drm_bus.set_busid() implementation provided by %ps. " +"Set the unique name explicitly using drm_set_unique()." , + dev->driver); + + master->unique =kstrdup (dev->unique,GFP_KERNEL ); +if (master->unique) + master->unique_len =strlen (dev->unique); + } +return 0 ; -err: -drm_unset_busid (dev, master); -return ret; }/** drivers/gpu/drm/drm_stub.c +1
-0@@ -646,6 +646,7 @@ static void drm_dev_release(struct kref *ref)drm_minor_free (dev,DRM_MINOR_CONTROL );mutex_destroy (&dev->master_mutex); +kfree (dev->unique);kfree (dev); }include/drm/drmP.h +3
-0@@ -1158,6 +1158,8 @@ struct drm_device {struct drm_vma_offset_manager *vma_offset_manager;/*@} */ int switch_power_state; + +char *unique; };#define DRM_SWITCH_POWER_ON 0@@ -1238,6 +1240,7 @@ extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);/* Misc. IOCTL support (drm_ioctl.h) */ extern int drm_irq_by_busid (struct drm_device *dev,void *data,struct drm_file *file_priv); +extern int drm_set_unique (struct drm_device *dev,const char *fmt, ...);extern int drm_getunique (struct drm_device *dev,void *data,struct drm_file *file_priv); extern int drm_setunique(struct drm_device *dev, void *data,Signature · 6 lines
1.9.2 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [RFC 4/5] drm: Introduce drm_set_unique()
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Add a helper function that allows drivers to statically set the unique name of the device. This will allow platform and USB drivers to get rid of their DRM bus implementations and directly use
drm_dev_alloc()anddrm_dev_register().Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/drm_ioctl.c | 37 +++++++++++++++++++++++++++++++------ drivers/gpu/drm/drm_stub.c | 1 + include/drm/drmP.h | 3 +++ 3 files changed, 35 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_ioctl.c +0
-0@@ -42,6 +42,20 @@#include <asm/mtrr.h> #endif
Quoted 5 lines
drivers/gpu/drm/drm_ioctl.c line 45
Quoted 1 line
drivers/gpu/drm/drm_ioctl.c +1
-0+int drm_set_unique (struct drm_device *dev,const char *fmt, ...)Can you please add a bit of kerneldoc for this?
drm_ioctl.cisn't yet pulled into the drm reference docbook, but better to have it there already.
On second thought, wouldn't this be better located in drm_stub.c? It isn't really related to the IOCTL code except that one of the IOCTLs now uses the information set by this function. Logically I think it belongs with the likes of drm_dev_alloc() and drm_dev_register().
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC 4/5] drm: Introduce drm_set_unique()
Quoted 30 lines · Thierry Reding
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Add a helper function that allows drivers to statically set the unique name of the device. This will allow platform and USB drivers to get rid of their DRM bus implementations and directly use
drm_dev_alloc()anddrm_dev_register().Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/drm_ioctl.c | 37 +++++++++++++++++++++++++++++++------ drivers/gpu/drm/drm_stub.c | 1 + include/drm/drmP.h | 3 +++ 3 files changed, 35 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_ioctl.c +0
-0@@ -42,6 +42,20 @@#include <asm/mtrr.h> #endif Quoted 5 lines
drivers/gpu/drm/drm_ioctl.c line 45
Quoted 1 line
drivers/gpu/drm/drm_ioctl.c +1
-0+int drm_set_unique (struct drm_device *dev,const char *fmt, ...)Can you please add a bit of kerneldoc for this?
drm_ioctl.cisn't yet pulled into the drm reference docbook, but better to have it there already.
Quoted 4 lines
On second thought, wouldn't this be better located in
drm_stub.c? It isn't really related to the IOCTL code except that one of the IOCTLs now uses the information set by this function. Logically I think it belongs with the likes ofdrm_dev_alloc()anddrm_dev_register().
Yeah makes sense. Tbh the entire split-up of these core drm functions is still a bit messy, so I don't mind if it's a bit inconsistent really. We can do the suffling when someone bothers with the kerneldoc for all of them and pulls it into the drm docbook.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [RFC 4/5] drm: Introduce drm_set_unique()
Hi
Quoted 10 lines · Daniel Vetter
Quoted 4 lines · Thierry Reding
On second thought, wouldn't this be better located in
drm_stub.c? It isn't really related to the IOCTL code except that one of the IOCTLs now uses the information set by this function. Logically I think it belongs with the likes ofdrm_dev_alloc()anddrm_dev_register().Yeah makes sense. Tbh the entire split-up of these core drm functions is still a bit messy, so I don't mind if it's a bit inconsistent really. We can do the suffling when someone bothers with the kerneldoc for all of them and pulls it into the drm docbook.
During drm_dev_*() cleanup, I tried to keep the following structure:
drm_drv.c: global drm-module setup
drm_stub.c: drm_device allocation, registration and lifetime management drm_fops.c: reference-implementation of the drm file_operations
The only thing that's wrongly placed is ioctl handling (which somehow ended up in drm_drv.c instead of drm_fops.c). drm_stub.c is where all the generic and mandatory DRM device handling is placed so yeah, I'd put the set_unique() there.
Thanks
David
PATCH v2 1/1 drm: Introduce drm_set_unique()
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Add a helper function that allows drivers to statically set the unique name of the device. This will allow platform and USB drivers to get rid of their DRM bus implementations and directly use drm_dev_alloc() and drm_dev_register().
---
Changes in v2:
- move drm_set_unique() to drivers/gpu/drm/drm_stub.c
- add kernel-doc
drivers/gpu/drm/drm_ioctl.c | 23 +++++++++++++++++------ drivers/gpu/drm/drm_stub.c | 24 ++++++++++++++++++++++++ include/drm/drmP.h | 3 +++ 3 files changed, 44 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_ioctl.c +17 -6
@@ -131,13 +131,24 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)if (master->unique !=NULL )drm_unset_busid (dev, master); - ret = dev->driver->bus->set_busid (dev, master); -if (ret) - goto err; +if (dev->driver->bus && dev->driver->bus->set_busid) { + ret = dev->driver->bus->set_busid (dev, master); +if (ret) { +drm_unset_busid (dev, master); +return ret; + } + }else { +WARN (dev->unique ==NULL , +"No drm_bus.set_busid() implementation provided by %ps. " +"Set the unique name explicitly using drm_set_unique()." , + dev->driver); + + master->unique =kstrdup (dev->unique,GFP_KERNEL ); +if (master->unique) + master->unique_len =strlen (dev->unique); + } +return 0 ; -err: -drm_unset_busid (dev, master); -return ret; }/**
drivers/gpu/drm/drm_stub.c +24 -0
@@ -532,6 +532,29 @@ static void drm_fs_inode_free(struct inode *inode) }/** +* drm_set_unique - Set the unique name of a DRM device +* @dev: device of which to set the unique name +* @fmt: format string for unique name +* +* Sets the unique name of a DRM device using the specified format string and +* a variable list of arguments. Drivers can use this at driver probe time if +* the unique name of the devices they drive is static. +*/ +int drm_set_unique (struct drm_device *dev,const char *fmt, ...) +{ +va_list ap; + +kfree (dev->unique); + +va_start (ap, fmt); + dev->unique =kvasprintf (GFP_KERNEL , fmt, ap); +va_end (ap); + +return dev->unique ?0 : -ENOMEM ; +} +EXPORT_SYMBOL (drm_set_unique); + +/** * drm_dev_alloc - Allocate new drm device * @driver: DRM driver to allocate device for * @parent: Parent device object
@@ -646,6 +669,7 @@ static void drm_dev_release(struct kref *ref)drm_minor_free (dev,DRM_MINOR_CONTROL );mutex_destroy (&dev->master_mutex); +kfree (dev->unique);kfree (dev); }
include/drm/drmP.h +3 -0
@@ -1158,6 +1158,8 @@ struct drm_device {struct drm_vma_offset_manager *vma_offset_manager;/*@} */ int switch_power_state; + +char *unique; };#define DRM_SWITCH_POWER_ON 0
@@ -1608,6 +1610,7 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)#include <drm/drm_mem_util.h> +int drm_set_unique (struct drm_device *dev,const char *fmt, ...);struct drm_device *drm_dev_alloc (struct drm_driver *driver,struct device *parent);void drm_dev_ref (struct drm_device *dev);
Signature · 1 line
1.9.2
Re: [RFC 4/5] drm: Introduce drm_set_unique()
In reply to Daniel VetterQuoted 36 lines · Daniel Vetter
Quoted 30 lines · Thierry Reding
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Add a helper function that allows drivers to statically set the unique name of the device. This will allow platform and USB drivers to get rid of their DRM bus implementations and directly use
drm_dev_alloc()anddrm_dev_register().Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/drm_ioctl.c | 37 +++++++++++++++++++++++++++++++------ drivers/gpu/drm/drm_stub.c | 1 + include/drm/drmP.h | 3 +++ 3 files changed, 35 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_ioctl.c +0
-0@@ -42,6 +42,20 @@#include <asm/mtrr.h> #endif Quoted 5 lines
drivers/gpu/drm/drm_ioctl.c line 45
Quoted 1 line
drivers/gpu/drm/drm_ioctl.c +1
-0+int drm_set_unique (struct drm_device *dev,const char *fmt, ...)Can you please add a bit of kerneldoc for this?
drm_ioctl.cisn't yet pulled into the drm reference docbook, but better to have it there already.Quoted 4 lines
On second thought, wouldn't this be better located in
drm_stub.c? It isn't really related to the IOCTL code except that one of the IOCTLs now uses the information set by this function. Logically I think it belongs with the likes ofdrm_dev_alloc()anddrm_dev_register().
Quoted 4 lines
Yeah makes sense. Tbh the entire split-up of these core drm functions is still a bit messy, so I don't mind if it's a bit inconsistent really. We can do the suffling when someone bothers with the kerneldoc for all of them and pulls it into the drm docbook.
I ended up doing exactly that when I wrote the drm_set_unique() docbook pieces and I've sent out patches based on top of v2 of this patch just now.
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 34 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Hi,
This series converts the Tegra DRM driver to the master/component framework. The length of the series and the list of people in Cc is mostly due to the fact that Tegra has some special requirements as opposed to other drivers and therefore requires some changes outside of DRM.
Patches 1 and 2 make some changes to the master/component framework which are necessary to convert Tegra DRM to use it. Note that since I'm looking for early review I haven't converted any of the existing users since I'm not sure if these are acceptable changes.
Patch 3 adds a new interface framework that supplements the master/ component framework and can be used in situations where there is no struct device * that a driver can bind to.
A new function is introduced in patch 4 which can be used to get rid of the DRM bus infrastructure in individual drivers. It should be able to replace the requirement of having a
drm_busfor all USB and platform DRM drivers. For backwards-compatibility with legacy PCI drivers some- thing different will probably be needed.Finally, patch 5 converts the Tegra DRM driver over to using the master/ component framework using the above four patches.
Each patch has a somewhat more elaborate description of why it is needed or what problem it solves. The patchset applies on top of linux-next with Daniel's DRM cleanup series applied.
I welcome any questions or comments you might have.
Quoted 8 lines
Thierry
Thierry Reding (5):
drivers/base: Allow multiple masters per devicedrivers/base: Allow driver-data to be attached to a masterdrivers/base: Add interface framework
drm: Introducedrm_set_unique()
drm/tegra: Convert to master/component framework
Ping. Anyone?
Thierry
Quoted 34 lines
drivers/base/Makefile | 2 +- drivers/base/component.c | 31 ++- drivers/base/interface.c | 186 ++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 37 ++- drivers/gpu/drm/drm_stub.c | 1 + drivers/gpu/drm/tegra/Makefile | 1 - drivers/gpu/drm/tegra/bus.c | 64 ----- drivers/gpu/drm/tegra/dc.c | 58 ++--- drivers/gpu/drm/tegra/drm.c | 171 +++++++++---- drivers/gpu/drm/tegra/drm.h | 27 +- drivers/gpu/drm/tegra/dsi.c | 144 +++++------ drivers/gpu/drm/tegra/gr2d.c | 78 +++--- drivers/gpu/drm/tegra/gr3d.c | 77 +++--- drivers/gpu/drm/tegra/hdmi.c | 69 ++--- drivers/gpu/drm/tegra/sor.c | 71 ++---- drivers/gpu/host1x/Makefile | 1 - drivers/gpu/host1x/bus.c | 553 ----------------------------------------- drivers/gpu/host1x/bus.h | 29 --- drivers/gpu/host1x/dev.c | 21 +- drivers/gpu/host1x/dev.h | 7 +- include/drm/drmP.h | 3 + include/linux/component.h | 20 +- include/linux/host1x.h | 64 +---- include/linux/interface.h | 40 +++ 24 files changed, 625 insertions(+), 1130 deletions(-) create mode 100644 drivers/base/interface.c delete mode 100644 drivers/gpu/drm/tegra/bus.c delete mode 100644 drivers/gpu/host1x/bus.c delete mode 100644 drivers/gpu/host1x/bus.h create mode 100644 include/linux/interface.hSignature · 1 line
1.9.2