component: Add documentation
Subsystems (7)
PATCH 1/4 component: Add documentation
While typing these I think doing an s/component_master/aggregate/ would be useful:
- it's shorter :-)
- I think component/aggregate is much more meaningful naming than component/puppetmaster or something like that. At least to my English ear "aggregate" emphasizes much more the "assemble a pile of things into something bigger" aspect, and there's not really much of a control hierarchy between aggregate and constituing components.
But that's way more than a quick doc typing exercise ...
Thanks to Ram for commenting on an initial draft of these docs.
v2: Review from Rafael:
- git add Documenation/driver-api/component.rst
- lots of polish to the wording + spelling fixes.
v3: Review from Russell:
- s/framework/helper
- clarify the documentation for component_match_add functions.
v4: Remove a few superflous "This".
--- Documentation/driver-api/component.rst | 17 ++++ Documentation/driver-api/device_link.rst | 3 + Documentation/driver-api/index.rst | 1 + drivers/base/component.c | 106 ++++++++++++++++++++++- include/linux/component.h | 70 +++++++++++++++ 5 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 Documentation/driver-api/component.rst
Documentation/driver-api/component.rst new file +17 -0
@@ -0,0 +1,17 @@ +====================================== +Component Helper for Aggregate Drivers +====================================== + +.. kernel-doc:: drivers/base/component.c + :doc: overview + + +API +=== + +.. kernel-doc:: include/linux/component.h + :internal: + +.. kernel-doc:: drivers/base/component.c + :export: +
Documentation/driver-api/device_link.rst +3 -0
@@ -1,6 +1,9 @@ .. |struct dev_pm_domain| replace:: :c:type:`struct dev_pm_domain <dev_pm_domain>` .. |struct generic_pm_domain| replace:: :c:type:`struct generic_pm_domain <generic_pm_domain>` + +.. _device_link: + ============ Device links ============
Documentation/driver-api/index.rst +1 -0
@@ -22,6 +22,7 @@ available subsections can be seen below. device_connection dma-buf device_link + component message-based sound frame-buffer
drivers/base/component.c +103 -3
155 lines not on this page · raw message
include/linux/component.h +70 -0
95 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/4 components: multiple components for a device
Component framework is extended to support multiple components for a struct device. These will be matched with different masters based on its sub component value.
We are introducing this, as I915 needs two different components with different subcomponent value, which will be matched to two different component masters(Audio and HDCP) based on the subcomponent values.
v2: Add documenation.
v3: Rebase on top of updated documenation.
v4: Review from Rafael:
- Remove redundant "This" from kerneldoc (also in the previous patch)
- Streamline the logic in find_component() a bit.
--- drivers/base/component.c | 158 +++++++++++++++++++++++++++++--------- include/linux/component.h | 10 ++- 2 files changed, 129 insertions(+), 39 deletions(-)
drivers/base/component.c +121 -37
@@ -47,6 +47,7 @@ struct component;struct component_match_array {void *data;int (*compare)(struct device *,void *); +int (*compare_typed)(struct device *,int ,void *);void (*release)(struct device *,void *);struct component *component;bool duplicate;
@@ -74,6 +75,7 @@ struct component {bool bound;const struct component_ops *ops; +int subcomponent;struct device *dev; };
@@ -158,7 +160,7 @@ static struct master *__master_find(struct device *dev, }static struct component *find_component (struct master *master, -int (*compare)(struct device *,void *),void *compare_data) +struct component_match_array *mc) {struct component *c;
@@ -166,7 +168,11 @@ static struct component *find_component(struct master *master,if (c->master && c->master != master)continue ; -if (compare (c->dev, compare_data)) +if (mc->compare && mc->compare (c->dev, mc->data)) +return c; + +if (mc->compare_typed && + mc->compare_typed (c->dev, c->subcomponent, mc->data))return c; }
@@ -192,7 +198,7 @@ static int find_components(struct master *master)if (match->compare[i].component)continue ; - c =find_component (master, mc->compare, mc->data); + c =find_component (master, mc);if (!c) { ret = -ENXIO ;break ;
@@ -327,29 +333,12 @@ static int component_match_realloc(struct device *dev,return 0 ; } -/** -* component_match_add_release - add a component match with release callback -* @master: device with the aggregate driver -* @matchptr: pointer to the list of component matches -* @release: release function for @compare_data -* @compare: compare function to match against all components -* @compare_data: opaque pointer passed to the @compare function -* -* Adds a new component match to the list stored in @matchptr, which the @master -* aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. -* -* The allocated match list in @matchptr is automatically released using devm -* actions, where upon @release will be called to free any references held by -* @compare_data, e.g. when @compare_data is a &device_node that must be -* released with of_node_put(). -* -* See also component_match_add(). -*/ -void component_match_add_release (struct device *master, +static void __component_match_add (struct device *master,struct component_match **matchptr,void (*release)(struct device *,void *), -int (*compare)(struct device *,void *),void *compare_data) +int (*compare)(struct device *,void *), +int (*compare_typed)(struct device *,int ,void *), +void *compare_data) {struct component_match *match = *matchptr;
@@ -381,13 +370,69 @@ void component_match_add_release(struct device *master, } match->compare[match->num].compare = compare; + match->compare[match->num].compare_typed = compare_typed; match->compare[match->num].release = release; match->compare[match->num].data = compare_data; match->compare[match->num].component =NULL ; match->num++; } + +/** +* component_match_add_release - add a component match with release callback +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @release: release function for @compare_data +* @compare: compare function to match against all components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions, where upon @release will be called to free any references held by +* @compare_data, e.g. when @compare_data is a &device_node that must be +* released with of_node_put(). +* +* See also component_match_add() and component_match_add_typed(). +*/ +void component_match_add_release (struct device *master, +struct component_match **matchptr, +void (*release)(struct device *,void *), +int (*compare)(struct device *,void *),void *compare_data) +{ +__component_match_add (master, matchptr, release, compare,NULL , + compare_data); +}EXPORT_SYMBOL (component_match_add_release); +/** +* component_match_add_typed - add a compent match for a typed component +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @compare_typed: compare function to match against all typed components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add_typed(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions. +* +* See also component_match_add_release() and component_match_add_typed(). +*/ +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data) +{ +__component_match_add (master, matchptr,NULL ,NULL , compare_typed, + compare_data); +} +EXPORT_SYMBOL (component_match_add_typed); +static void free_master (struct master *master) {struct component_match *match = master->match;
@@ -616,19 +661,8 @@ int component_bind_all(struct device *master_dev, void *data) }EXPORT_SYMBOL_GPL (component_bind_all); -/** -* component_add - register a component -* @dev: component device -* @ops: component callbacks -* -* Register a new component for @dev. Functions in @ops will be called when the -* aggregate driver is ready to bind the overall driver by calling -* component_bind_all(). See also &struct component_ops. -* -* The component needs to be unregistered at driver unload/disconnect by calling -* component_del(). -*/ -int component_add (struct device *dev,const struct component_ops *ops) +static int __component_add (struct device *dev,const struct component_ops *ops, +int subcomponent) {struct component *component;int ret;
@@ -639,6 +673,7 @@ int component_add(struct device *dev, const struct component_ops *ops) component->ops = ops; component->dev = dev; + component->subcomponent = subcomponent;dev_dbg (dev,"adding component (ops %ps)\n" , ops);
@@ -657,6 +692,55 @@ int component_add(struct device *dev, const struct component_ops *ops)return ret <0 ? ret :0 ; } + +/** +* component_add_typed - register a component +* @dev: component device +* @ops: component callbacks +* @subcomponent: nonzero identifier for subcomponents +* +* Register a new component for @dev. Functions in @ops will be call when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* @subcomponent must be nonzero and is used to differentiate between multiple +* components registerd on the same device @dev. These components are match +* using component_match_add_typed(). +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add(). +*/ +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent) +{ +if (WARN_ON (subcomponent ==0 )) +return -EINVAL ; + +return __component_add (dev, ops, subcomponent); +} +EXPORT_SYMBOL_GPL (component_add_typed); + +/** +* component_add - register a component +* @dev: component device +* @ops: component callbacks +* +* Register a new component for @dev. Functions in @ops will be called when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add_typed() for a variant that allows multipled different +* components on the same device. +*/ +int component_add (struct device *dev,const struct component_ops *ops) +{ +return __component_add (dev, ops,0 ); +}EXPORT_SYMBOL_GPL (component_add);/**
include/linux/component.h +8 -2
@@ -34,6 +34,8 @@ struct component_ops { };int component_add (struct device *,const struct component_ops *); +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent);void component_del (struct device *,const struct component_ops *);int component_bind_all (struct device *master,void *master_data);
@@ -91,6 +93,9 @@ void component_match_add_release(struct device *master,struct component_match **matchptr, void (*release)(struct device *, void *), int (*compare)(struct device *, void *), void *compare_data); +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data);/** * component_match_add - add a compent match
@@ -101,12 +106,13 @@ void component_match_add_release(struct device *master,* * Adds a new component match to the list stored in @matchptr, which the @master * aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). * * The allocated match list in @matchptr is automatically released using devm * actions. * -* See also component_match_add_release(). +* See also component_match_add_release() and component_match_add_typed(). */ static inline void component_match_add(struct device *master, struct component_match **matchptr,
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/4] components: multiple components for a device
Quoted 18 lines · Daniel Vetter
Component framework is extended to support multiple components for a struct device. These will be matched with different masters based on its sub component value.
We are introducing this, as I915 needs two different components with different subcomponent value, which will be matched to two different component masters(Audio and HDCP) based on the subcomponent values.
v2: Add documenation.
v3: Rebase on top of updated documenation.
v4: Review from Rafael:
- Remove redundant "This" from kerneldoc (also in the previous patch)
- Streamline the logic infind_component()a bit.
Quoted 11 lines
Signed-off-by Daniel Vetter <[email protected]> (v1 code)Signed-off-by Ramalingam C <[email protected]> (v1 commit message)Cc Ramalingam C <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
Quoted 288 lines
--- drivers/base/component.c | 158 +++++++++++++++++++++++++++++--------- include/linux/component.h | 10 ++- 2 files changed, 129 insertions(+), 39 deletions(-)drivers/base/component.c +121
-37@@ -47,6 +47,7 @@ struct component;struct component_match_array {void *data;int (*compare)(struct device *,void *); +int (*compare_typed)(struct device *,int ,void *);void (*release)(struct device *,void *);struct component *component;bool duplicate;@@ -74,6 +75,7 @@ struct component {bool bound;const struct component_ops *ops; +int subcomponent;struct device *dev; };@@ -158,7 +160,7 @@ static struct master *__master_find(struct device *dev, }static struct component *find_component (struct master *master, -int (*compare)(struct device *,void *),void *compare_data) +struct component_match_array *mc) {struct component *c;@@ -166,7 +168,11 @@ static struct component *find_component(struct master *master,if (c->master && c->master != master)continue ; -if (compare (c->dev, compare_data)) +if (mc->compare && mc->compare (c->dev, mc->data)) +return c; + +if (mc->compare_typed && + mc->compare_typed (c->dev, c->subcomponent, mc->data))return c; }@@ -192,7 +198,7 @@ static int find_components(struct master *master)if (match->compare[i].component)continue ; - c =find_component (master, mc->compare, mc->data); + c =find_component (master, mc);if (!c) { ret = -ENXIO ;break ;@@ -327,29 +333,12 @@ static int component_match_realloc(struct device *dev,return 0 ; } -/** -* component_match_add_release - add a component match with release callback -* @master: device with the aggregate driver -* @matchptr: pointer to the list of component matches -* @release: release function for @compare_data -* @compare: compare function to match against all components -* @compare_data: opaque pointer passed to the @compare function -* -* Adds a new component match to the list stored in @matchptr, which the @master -* aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. -* -* The allocated match list in @matchptr is automatically released using devm -* actions, where upon @release will be called to free any references held by -* @compare_data, e.g. when @compare_data is a &device_node that must be -* released with of_node_put(). -* -* See also component_match_add(). -*/ -void component_match_add_release (struct device *master, +static void __component_match_add (struct device *master,struct component_match **matchptr,void (*release)(struct device *,void *), -int (*compare)(struct device *,void *),void *compare_data) +int (*compare)(struct device *,void *), +int (*compare_typed)(struct device *,int ,void *), +void *compare_data) {struct component_match *match = *matchptr;@@ -381,13 +370,69 @@ void component_match_add_release(struct device *master, } match->compare[match->num].compare = compare; + match->compare[match->num].compare_typed = compare_typed; match->compare[match->num].release = release; match->compare[match->num].data = compare_data; match->compare[match->num].component =NULL ; match->num++; } + +/** +* component_match_add_release - add a component match with release callback +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @release: release function for @compare_data +* @compare: compare function to match against all components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions, where upon @release will be called to free any references held by +* @compare_data, e.g. when @compare_data is a &device_node that must be +* released with of_node_put(). +* +* See also component_match_add() and component_match_add_typed(). +*/ +void component_match_add_release (struct device *master, +struct component_match **matchptr, +void (*release)(struct device *,void *), +int (*compare)(struct device *,void *),void *compare_data) +{ +__component_match_add (master, matchptr, release, compare,NULL , + compare_data); +}EXPORT_SYMBOL (component_match_add_release); +/** +* component_match_add_typed - add a compent match for a typed component +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @compare_typed: compare function to match against all typed components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add_typed(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions. +* +* See also component_match_add_release() and component_match_add_typed(). +*/ +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data) +{ +__component_match_add (master, matchptr,NULL ,NULL , compare_typed, + compare_data); +} +EXPORT_SYMBOL (component_match_add_typed); +static void free_master (struct master *master) {struct component_match *match = master->match;@@ -616,19 +661,8 @@ int component_bind_all(struct device *master_dev, void *data) }EXPORT_SYMBOL_GPL (component_bind_all); -/** -* component_add - register a component -* @dev: component device -* @ops: component callbacks -* -* Register a new component for @dev. Functions in @ops will be called when the -* aggregate driver is ready to bind the overall driver by calling -* component_bind_all(). See also &struct component_ops. -* -* The component needs to be unregistered at driver unload/disconnect by calling -* component_del(). -*/ -int component_add (struct device *dev,const struct component_ops *ops) +static int __component_add (struct device *dev,const struct component_ops *ops, +int subcomponent) {struct component *component;int ret;@@ -639,6 +673,7 @@ int component_add(struct device *dev, const struct component_ops *ops) component->ops = ops; component->dev = dev; + component->subcomponent = subcomponent;dev_dbg (dev,"adding component (ops %ps)\n" , ops);@@ -657,6 +692,55 @@ int component_add(struct device *dev, const struct component_ops *ops)return ret <0 ? ret :0 ; } + +/** +* component_add_typed - register a component +* @dev: component device +* @ops: component callbacks +* @subcomponent: nonzero identifier for subcomponents +* +* Register a new component for @dev. Functions in @ops will be call when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* @subcomponent must be nonzero and is used to differentiate between multiple +* components registerd on the same device @dev. These components are match +* using component_match_add_typed(). +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add(). +*/ +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent) +{ +if (WARN_ON (subcomponent ==0 )) +return -EINVAL ; + +return __component_add (dev, ops, subcomponent); +} +EXPORT_SYMBOL_GPL (component_add_typed); + +/** +* component_add - register a component +* @dev: component device +* @ops: component callbacks +* +* Register a new component for @dev. Functions in @ops will be called when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add_typed() for a variant that allows multipled different +* components on the same device. +*/ +int component_add (struct device *dev,const struct component_ops *ops) +{ +return __component_add (dev, ops,0 ); +}EXPORT_SYMBOL_GPL (component_add);/** include/linux/component.h +8
-3@@ -34,6 +34,8 @@ struct component_ops { };int component_add (struct device *,const struct component_ops *); +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent);void component_del (struct device *,const struct component_ops *);int component_bind_all (struct device *master,void *master_data);@@ -91,6 +93,9 @@ void component_match_add_release(struct device *master,struct component_match **matchptr, void (*release)(struct device *, void *), int (*compare)(struct device *, void *), void *compare_data); +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data);/** * component_match_add - add a compent match @@ -101,12 +106,13 @@ void component_match_add_release(struct device *master,* * Adds a new component match to the list stored in @matchptr, which the @master * aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). * * The allocated match list in @matchptr is automatically released using devm * actions. * -* See also component_match_add_release(). +* See also component_match_add_release() and component_match_add_typed(). */ static inline void component_match_add(struct device *master, struct component_match **matchptr, --2.20.1
Re: [PATCH 2/4] components: multiple components for a device
In reply to Daniel VetterQuoted 172 lines · Daniel Vetter
Component framework is extended to support multiple components for a struct device. These will be matched with different masters based on its sub component value.
We are introducing this, as I915 needs two different components with different subcomponent value, which will be matched to two different component masters(Audio and HDCP) based on the subcomponent values.
v2: Add documenation.
v3: Rebase on top of updated documenation.
v4: Review from Rafael:
- Remove redundant "This" from kerneldoc (also in the previous patch)
- Streamline the logic infind_component()a bit.Signed-off-by Daniel Vetter <[email protected]> (v1 code)Signed-off-by Ramalingam C <[email protected]> (v1 commit message)Cc Ramalingam C <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/base/component.c | 158 +++++++++++++++++++++++++++++--------- include/linux/component.h | 10 ++- 2 files changed, 129 insertions(+), 39 deletions(-)drivers/base/component.c +56
-24@@ -47,6 +47,7 @@ struct component;struct component_match_array {void *data;int (*compare)(struct device *,void *); +int (*compare_typed)(struct device *,int ,void *);void (*release)(struct device *,void *);struct component *component;bool duplicate;@@ -74,6 +75,7 @@ struct component {bool bound;const struct component_ops *ops; +int subcomponent;struct device *dev; };@@ -158,7 +160,7 @@ static struct master *__master_find(struct device *dev, }static struct component *find_component (struct master *master, -int (*compare)(struct device *,void *),void *compare_data) +struct component_match_array *mc) {struct component *c;@@ -166,7 +168,11 @@ static struct component *find_component(struct master *master,if (c->master && c->master != master)continue ; -if (compare (c->dev, compare_data)) +if (mc->compare && mc->compare (c->dev, mc->data)) +return c; + +if (mc->compare_typed && + mc->compare_typed (c->dev, c->subcomponent, mc->data))return c; }@@ -192,7 +198,7 @@ static int find_components(struct master *master)if (match->compare[i].component)continue ; - c =find_component (master, mc->compare, mc->data); + c =find_component (master, mc);if (!c) { ret = -ENXIO ;break ;@@ -327,29 +333,12 @@ static int component_match_realloc(struct device *dev,return 0 ; } -/** -* component_match_add_release - add a component match with release callback -* @master: device with the aggregate driver -* @matchptr: pointer to the list of component matches -* @release: release function for @compare_data -* @compare: compare function to match against all components -* @compare_data: opaque pointer passed to the @compare function -* -* Adds a new component match to the list stored in @matchptr, which the @master -* aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. -* -* The allocated match list in @matchptr is automatically released using devm -* actions, where upon @release will be called to free any references held by -* @compare_data, e.g. when @compare_data is a &device_node that must be -* released with of_node_put(). -* -* See also component_match_add(). -*/ -void component_match_add_release (struct device *master, +static void __component_match_add (struct device *master,struct component_match **matchptr,void (*release)(struct device *,void *), -int (*compare)(struct device *,void *),void *compare_data) +int (*compare)(struct device *,void *), +int (*compare_typed)(struct device *,int ,void *), +void *compare_data) {struct component_match *match = *matchptr;@@ -381,13 +370,69 @@ void component_match_add_release(struct device *master, } match->compare[match->num].compare = compare; + match->compare[match->num].compare_typed = compare_typed; match->compare[match->num].release = release; match->compare[match->num].data = compare_data; match->compare[match->num].component =NULL ; match->num++; } + +/** +* component_match_add_release - add a component match with release callback +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @release: release function for @compare_data +* @compare: compare function to match against all components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions, where upon @release will be called to free any references held by +* @compare_data, e.g. when @compare_data is a &device_node that must be +* released with of_node_put(). +* +* See also component_match_add() and component_match_add_typed(). +*/ +void component_match_add_release (struct device *master, +struct component_match **matchptr, +void (*release)(struct device *,void *), +int (*compare)(struct device *,void *),void *compare_data) +{ +__component_match_add (master, matchptr, release, compare,NULL , + compare_data); +}EXPORT_SYMBOL (component_match_add_release); +/** +* component_match_add_typed - add a compent match for a typed component +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @compare_typed: compare function to match against all typed components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add_typed(). +* +* The allocated match list in @matchptr is automatically released using devm
drivers/base/component.c void component_match_add_release(struct device *master, · line 432
Quoted 10 lines
drivers/base/component.c +10
-0+* actions. +* +* See also component_match_add_release() and component_match_add_typed(). +*/ +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data) +{ +__component_match_add (master, matchptr,NULL ,NULL , compare_typed, + compare_data);
You're still passing some compare data in that may need to be released, but you are explicitly denying the ability to provide a release function pointer here. What was the reasoning behind that decision? If someone wanted to use this with compare_data being a device_node, how should that be handled?
Thanks.
Quoted 135 lines
drivers/base/component.c +55
-13+} +EXPORT_SYMBOL (component_match_add_typed); +static void free_master (struct master *master) {struct component_match *match = master->match;@@ -616,19 +661,8 @@ int component_bind_all(struct device *master_dev, void *data) }EXPORT_SYMBOL_GPL (component_bind_all); -/** -* component_add - register a component -* @dev: component device -* @ops: component callbacks -* -* Register a new component for @dev. Functions in @ops will be called when the -* aggregate driver is ready to bind the overall driver by calling -* component_bind_all(). See also &struct component_ops. -* -* The component needs to be unregistered at driver unload/disconnect by calling -* component_del(). -*/ -int component_add (struct device *dev,const struct component_ops *ops) +static int __component_add (struct device *dev,const struct component_ops *ops, +int subcomponent) {struct component *component;int ret;@@ -639,6 +673,7 @@ int component_add(struct device *dev, const struct component_ops *ops) component->ops = ops; component->dev = dev; + component->subcomponent = subcomponent;dev_dbg (dev,"adding component (ops %ps)\n" , ops);@@ -657,6 +692,55 @@ int component_add(struct device *dev, const struct component_ops *ops)return ret <0 ? ret :0 ; } + +/** +* component_add_typed - register a component +* @dev: component device +* @ops: component callbacks +* @subcomponent: nonzero identifier for subcomponents +* +* Register a new component for @dev. Functions in @ops will be call when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* @subcomponent must be nonzero and is used to differentiate between multiple +* components registerd on the same device @dev. These components are match +* using component_match_add_typed(). +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add(). +*/ +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent) +{ +if (WARN_ON (subcomponent ==0 )) +return -EINVAL ; + +return __component_add (dev, ops, subcomponent); +} +EXPORT_SYMBOL_GPL (component_add_typed); + +/** +* component_add - register a component +* @dev: component device +* @ops: component callbacks +* +* Register a new component for @dev. Functions in @ops will be called when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add_typed() for a variant that allows multipled different +* components on the same device. +*/ +int component_add (struct device *dev,const struct component_ops *ops) +{ +return __component_add (dev, ops,0 ); +}EXPORT_SYMBOL_GPL (component_add);/** include/linux/component.h +8
-2@@ -34,6 +34,8 @@ struct component_ops { };int component_add (struct device *,const struct component_ops *); +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent);void component_del (struct device *,const struct component_ops *);int component_bind_all (struct device *master,void *master_data);@@ -91,6 +93,9 @@ void component_match_add_release(struct device *master,struct component_match **matchptr, void (*release)(struct device *, void *), int (*compare)(struct device *, void *), void *compare_data); +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data);/** * component_match_add - add a compent match @@ -101,12 +106,13 @@ void component_match_add_release(struct device *master,* * Adds a new component match to the list stored in @matchptr, which the @master * aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). * * The allocated match list in @matchptr is automatically released using devm * actions. * -* See also component_match_add_release(). +* See also component_match_add_release() and component_match_add_typed(). */ static inline void component_match_add(struct device *master, struct component_match **matchptr,Signature · 1 line
2.20.1
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Re: [PATCH 2/4] components: multiple components for a device
Quoted 181 lines · Russell King - ARM Linux admin
Quoted 180 lines · Daniel Vetter
Component framework is extended to support multiple components for a struct device. These will be matched with different masters based on its sub component value.
We are introducing this, as I915 needs two different components with different subcomponent value, which will be matched to two different component masters(Audio and HDCP) based on the subcomponent values.
v2: Add documenation.
v3: Rebase on top of updated documenation.
v4: Review from Rafael:
- Remove redundant "This" from kerneldoc (also in the previous patch)
- Streamline the logic infind_component()a bit.Signed-off-by Daniel Vetter <[email protected]> (v1 code)Signed-off-by Ramalingam C <[email protected]> (v1 commit message)Cc Ramalingam C <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/base/component.c | 158 +++++++++++++++++++++++++++++--------- include/linux/component.h | 10 ++- 2 files changed, 129 insertions(+), 39 deletions(-)drivers/base/component.c +64
-24@@ -47,6 +47,7 @@ struct component;struct component_match_array {void *data;int (*compare)(struct device *,void *); +int (*compare_typed)(struct device *,int ,void *);void (*release)(struct device *,void *);struct component *component;bool duplicate;@@ -74,6 +75,7 @@ struct component {bool bound;const struct component_ops *ops; +int subcomponent;struct device *dev; };@@ -158,7 +160,7 @@ static struct master *__master_find(struct device *dev, }static struct component *find_component (struct master *master, -int (*compare)(struct device *,void *),void *compare_data) +struct component_match_array *mc) {struct component *c;@@ -166,7 +168,11 @@ static struct component *find_component(struct master *master,if (c->master && c->master != master)continue ; -if (compare (c->dev, compare_data)) +if (mc->compare && mc->compare (c->dev, mc->data)) +return c; + +if (mc->compare_typed && + mc->compare_typed (c->dev, c->subcomponent, mc->data))return c; }@@ -192,7 +198,7 @@ static int find_components(struct master *master)if (match->compare[i].component)continue ; - c =find_component (master, mc->compare, mc->data); + c =find_component (master, mc);if (!c) { ret = -ENXIO ;break ;@@ -327,29 +333,12 @@ static int component_match_realloc(struct device *dev,return 0 ; } -/** -* component_match_add_release - add a component match with release callback -* @master: device with the aggregate driver -* @matchptr: pointer to the list of component matches -* @release: release function for @compare_data -* @compare: compare function to match against all components -* @compare_data: opaque pointer passed to the @compare function -* -* Adds a new component match to the list stored in @matchptr, which the @master -* aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. -* -* The allocated match list in @matchptr is automatically released using devm -* actions, where upon @release will be called to free any references held by -* @compare_data, e.g. when @compare_data is a &device_node that must be -* released with of_node_put(). -* -* See also component_match_add(). -*/ -void component_match_add_release (struct device *master, +static void __component_match_add (struct device *master,struct component_match **matchptr,void (*release)(struct device *,void *), -int (*compare)(struct device *,void *),void *compare_data) +int (*compare)(struct device *,void *), +int (*compare_typed)(struct device *,int ,void *), +void *compare_data) {struct component_match *match = *matchptr;@@ -381,13 +370,69 @@ void component_match_add_release(struct device *master, } match->compare[match->num].compare = compare; + match->compare[match->num].compare_typed = compare_typed; match->compare[match->num].release = release; match->compare[match->num].data = compare_data; match->compare[match->num].component =NULL ; match->num++; } + +/** +* component_match_add_release - add a component match with release callback +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @release: release function for @compare_data +* @compare: compare function to match against all components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions, where upon @release will be called to free any references held by +* @compare_data, e.g. when @compare_data is a &device_node that must be +* released with of_node_put(). +* +* See also component_match_add() and component_match_add_typed(). +*/ +void component_match_add_release (struct device *master, +struct component_match **matchptr, +void (*release)(struct device *,void *), +int (*compare)(struct device *,void *),void *compare_data) +{ +__component_match_add (master, matchptr, release, compare,NULL , + compare_data); +}EXPORT_SYMBOL (component_match_add_release); +/** +* component_match_add_typed - add a compent match for a typed component +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @compare_typed: compare function to match against all typed components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add_typed(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions. +* +* See also component_match_add_release() and component_match_add_typed(). +*/ +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data) +{
Quoted 8 lines
drivers/base/component.c void component_match_add_release(struct device *master, · line 432
Quoted 2 lines
drivers/base/component.c +2
-0+__component_match_add (master, matchptr,NULL ,NULL , compare_typed, + compare_data);You're still passing some compare data in that may need to be released, but you are explicitly denying the ability to provide a release function pointer here. What was the reasoning behind that decision? If someone wanted to use this with
compare_databeing adevice_node, how should that be handled?
Same way we've handled it originally, adding the new variant. I'm not a huge fan of adding api preemptively, without a user. And the data pointer we pass around in i915 for mei_hdcp and snd-hda-intel don't hold references (we don't even use them, we just compare the device against hardcoded expectations). Since the new compare_typed is entirely orthogonal to whether you have a release function or not, that should be simple to do.
-Daniel
Quoted 143 lines
Thanks.
Quoted 135 lines
drivers/base/component.c +55
-13+} +EXPORT_SYMBOL (component_match_add_typed); +static void free_master (struct master *master) {struct component_match *match = master->match;@@ -616,19 +661,8 @@ int component_bind_all(struct device *master_dev, void *data) }EXPORT_SYMBOL_GPL (component_bind_all); -/** -* component_add - register a component -* @dev: component device -* @ops: component callbacks -* -* Register a new component for @dev. Functions in @ops will be called when the -* aggregate driver is ready to bind the overall driver by calling -* component_bind_all(). See also &struct component_ops. -* -* The component needs to be unregistered at driver unload/disconnect by calling -* component_del(). -*/ -int component_add (struct device *dev,const struct component_ops *ops) +static int __component_add (struct device *dev,const struct component_ops *ops, +int subcomponent) {struct component *component;int ret;@@ -639,6 +673,7 @@ int component_add(struct device *dev, const struct component_ops *ops) component->ops = ops; component->dev = dev; + component->subcomponent = subcomponent;dev_dbg (dev,"adding component (ops %ps)\n" , ops);@@ -657,6 +692,55 @@ int component_add(struct device *dev, const struct component_ops *ops)return ret <0 ? ret :0 ; } + +/** +* component_add_typed - register a component +* @dev: component device +* @ops: component callbacks +* @subcomponent: nonzero identifier for subcomponents +* +* Register a new component for @dev. Functions in @ops will be call when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* @subcomponent must be nonzero and is used to differentiate between multiple +* components registerd on the same device @dev. These components are match +* using component_match_add_typed(). +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add(). +*/ +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent) +{ +if (WARN_ON (subcomponent ==0 )) +return -EINVAL ; + +return __component_add (dev, ops, subcomponent); +} +EXPORT_SYMBOL_GPL (component_add_typed); + +/** +* component_add - register a component +* @dev: component device +* @ops: component callbacks +* +* Register a new component for @dev. Functions in @ops will be called when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add_typed() for a variant that allows multipled different +* components on the same device. +*/ +int component_add (struct device *dev,const struct component_ops *ops) +{ +return __component_add (dev, ops,0 ); +}EXPORT_SYMBOL_GPL (component_add);/** include/linux/component.h +8
-2@@ -34,6 +34,8 @@ struct component_ops { };int component_add (struct device *,const struct component_ops *); +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent);void component_del (struct device *,const struct component_ops *);int component_bind_all (struct device *master,void *master_data);@@ -91,6 +93,9 @@ void component_match_add_release(struct device *master,struct component_match **matchptr, void (*release)(struct device *, void *), int (*compare)(struct device *, void *), void *compare_data); +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data);/** * component_match_add - add a compent match @@ -101,12 +106,13 @@ void component_match_add_release(struct device *master,* * Adds a new component match to the list stored in @matchptr, which the @master * aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). * * The allocated match list in @matchptr is automatically released using devm * actions. * -* See also component_match_add_release(). +* See also component_match_add_release() and component_match_add_typed(). */ static inline void component_match_add(struct device *master, struct component_match **matchptr,Signature · 1 line
2.20.1Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/4] components: multiple components for a device
Quoted 192 lines · Daniel Vetter
Quoted 181 lines · Russell King - ARM Linux admin
Quoted 180 lines · Daniel Vetter
Component framework is extended to support multiple components for a struct device. These will be matched with different masters based on its sub component value.
We are introducing this, as I915 needs two different components with different subcomponent value, which will be matched to two different component masters(Audio and HDCP) based on the subcomponent values.
v2: Add documenation.
v3: Rebase on top of updated documenation.
v4: Review from Rafael:
- Remove redundant "This" from kerneldoc (also in the previous patch)
- Streamline the logic infind_component()a bit.Signed-off-by Daniel Vetter <[email protected]> (v1 code)Signed-off-by Ramalingam C <[email protected]> (v1 commit message)Cc Ramalingam C <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/base/component.c | 158 +++++++++++++++++++++++++++++--------- include/linux/component.h | 10 ++- 2 files changed, 129 insertions(+), 39 deletions(-)drivers/base/component.c +64
-24@@ -47,6 +47,7 @@ struct component;struct component_match_array {void *data;int (*compare)(struct device *,void *); +int (*compare_typed)(struct device *,int ,void *);void (*release)(struct device *,void *);struct component *component;bool duplicate;@@ -74,6 +75,7 @@ struct component {bool bound;const struct component_ops *ops; +int subcomponent;struct device *dev; };@@ -158,7 +160,7 @@ static struct master *__master_find(struct device *dev, }static struct component *find_component (struct master *master, -int (*compare)(struct device *,void *),void *compare_data) +struct component_match_array *mc) {struct component *c;@@ -166,7 +168,11 @@ static struct component *find_component(struct master *master,if (c->master && c->master != master)continue ; -if (compare (c->dev, compare_data)) +if (mc->compare && mc->compare (c->dev, mc->data)) +return c; + +if (mc->compare_typed && + mc->compare_typed (c->dev, c->subcomponent, mc->data))return c; }@@ -192,7 +198,7 @@ static int find_components(struct master *master)if (match->compare[i].component)continue ; - c =find_component (master, mc->compare, mc->data); + c =find_component (master, mc);if (!c) { ret = -ENXIO ;break ;@@ -327,29 +333,12 @@ static int component_match_realloc(struct device *dev,return 0 ; } -/** -* component_match_add_release - add a component match with release callback -* @master: device with the aggregate driver -* @matchptr: pointer to the list of component matches -* @release: release function for @compare_data -* @compare: compare function to match against all components -* @compare_data: opaque pointer passed to the @compare function -* -* Adds a new component match to the list stored in @matchptr, which the @master -* aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. -* -* The allocated match list in @matchptr is automatically released using devm -* actions, where upon @release will be called to free any references held by -* @compare_data, e.g. when @compare_data is a &device_node that must be -* released with of_node_put(). -* -* See also component_match_add(). -*/ -void component_match_add_release (struct device *master, +static void __component_match_add (struct device *master,struct component_match **matchptr,void (*release)(struct device *,void *), -int (*compare)(struct device *,void *),void *compare_data) +int (*compare)(struct device *,void *), +int (*compare_typed)(struct device *,int ,void *), +void *compare_data) {struct component_match *match = *matchptr;@@ -381,13 +370,69 @@ void component_match_add_release(struct device *master, } match->compare[match->num].compare = compare; + match->compare[match->num].compare_typed = compare_typed; match->compare[match->num].release = release; match->compare[match->num].data = compare_data; match->compare[match->num].component =NULL ; match->num++; } + +/** +* component_match_add_release - add a component match with release callback +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @release: release function for @compare_data +* @compare: compare function to match against all components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions, where upon @release will be called to free any references held by +* @compare_data, e.g. when @compare_data is a &device_node that must be +* released with of_node_put(). +* +* See also component_match_add() and component_match_add_typed(). +*/ +void component_match_add_release (struct device *master, +struct component_match **matchptr, +void (*release)(struct device *,void *), +int (*compare)(struct device *,void *),void *compare_data) +{ +__component_match_add (master, matchptr, release, compare,NULL , + compare_data); +}EXPORT_SYMBOL (component_match_add_release); +/** +* component_match_add_typed - add a compent match for a typed component +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @compare_typed: compare function to match against all typed components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add_typed(). +* +* The allocated match list in @matchptr is automatically released using devm +* actions. +* +* See also component_match_add_release() and component_match_add_typed(). +*/ +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data) +{Quoted 8 lines
drivers/base/component.c void component_match_add_release(struct device *master, · line 432
Quoted 2 lines
drivers/base/component.c +2
-0+__component_match_add (master, matchptr,NULL ,NULL , compare_typed, + compare_data);You're still passing some compare data in that may need to be released, but you are explicitly denying the ability to provide a release function pointer here. What was the reasoning behind that decision? If someone wanted to use this with
compare_databeing adevice_node, how should that be handled?
Quoted 7 lines
Same way we've handled it originally, adding the new variant. I'm not a huge fan of adding api preemptively, without a user. And the data pointer we pass around in i915 for
mei_hdcpand snd-hda-intel don't hold references (we don't even use them, we just compare the device against hardcoded expectations). Since the newcompare_typedis entirely orthogonal to whether you have a release function or not, that should be simple to do.
Forgot to add: I also don't expect a user for this. The ->release callback is used for dt drivers, because of_node_put(). And well designed device tree will not have multiple components stack in very awkward ways on the exact same underlying device, that would simply be rather unclean DT design. x86 otoh, thanks to window's "one pci device, one driver" expectation is full of that kind of kludged-together SoC-but-not-really behind one pci device. Therefore I expect the overlap for this kind of stuff to be 0.
This includes all the hand-rolled hacks we have in i915 that predate component, e.g. ips on ironlake or the pmu serialization on vlv. So with a 4/4 rate of possible users of component_typed not needed a ->release callback I think not providing that combo for now is the right call. And as mentioned, really easy to adjust in case I've guessed wrong here.
-Daniel
Quoted 145 lines
Quoted 132 lines
Quoted 132 lines
drivers/base/component.c +55
-13+} +EXPORT_SYMBOL (component_match_add_typed); +static void free_master (struct master *master) {struct component_match *match = master->match;@@ -616,19 +661,8 @@ int component_bind_all(struct device *master_dev, void *data) }EXPORT_SYMBOL_GPL (component_bind_all); -/** -* component_add - register a component -* @dev: component device -* @ops: component callbacks -* -* Register a new component for @dev. Functions in @ops will be called when the -* aggregate driver is ready to bind the overall driver by calling -* component_bind_all(). See also &struct component_ops. -* -* The component needs to be unregistered at driver unload/disconnect by calling -* component_del(). -*/ -int component_add (struct device *dev,const struct component_ops *ops) +static int __component_add (struct device *dev,const struct component_ops *ops, +int subcomponent) {struct component *component;int ret;@@ -639,6 +673,7 @@ int component_add(struct device *dev, const struct component_ops *ops) component->ops = ops; component->dev = dev; + component->subcomponent = subcomponent;dev_dbg (dev,"adding component (ops %ps)\n" , ops);@@ -657,6 +692,55 @@ int component_add(struct device *dev, const struct component_ops *ops)return ret <0 ? ret :0 ; } + +/** +* component_add_typed - register a component +* @dev: component device +* @ops: component callbacks +* @subcomponent: nonzero identifier for subcomponents +* +* Register a new component for @dev. Functions in @ops will be call when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* @subcomponent must be nonzero and is used to differentiate between multiple +* components registerd on the same device @dev. These components are match +* using component_match_add_typed(). +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add(). +*/ +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent) +{ +if (WARN_ON (subcomponent ==0 )) +return -EINVAL ; + +return __component_add (dev, ops, subcomponent); +} +EXPORT_SYMBOL_GPL (component_add_typed); + +/** +* component_add - register a component +* @dev: component device +* @ops: component callbacks +* +* Register a new component for @dev. Functions in @ops will be called when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* The component needs to be unregistered at driver unload/disconnect by +* calling component_del(). +* +* See also component_add_typed() for a variant that allows multipled different +* components on the same device. +*/ +int component_add (struct device *dev,const struct component_ops *ops) +{ +return __component_add (dev, ops,0 ); +}EXPORT_SYMBOL_GPL (component_add);/** include/linux/component.h +8
-3@@ -34,6 +34,8 @@ struct component_ops { };int component_add (struct device *,const struct component_ops *); +int component_add_typed (struct device *dev,const struct component_ops *ops, +int subcomponent);void component_del (struct device *,const struct component_ops *);int component_bind_all (struct device *master,void *master_data);@@ -91,6 +93,9 @@ void component_match_add_release(struct device *master,struct component_match **matchptr, void (*release)(struct device *, void *), int (*compare)(struct device *, void *), void *compare_data); +void component_match_add_typed (struct device *master, +struct component_match **matchptr, +int (*compare_typed)(struct device *,int ,void *),void *compare_data);/** * component_match_add - add a compent match @@ -101,12 +106,13 @@ void component_match_add_release(struct device *master,* * Adds a new component match to the list stored in @matchptr, which the @master * aggregate driver needs to function. The list of component matches pointed to -* by @matchptr must be initialized to NULL before adding the first match. +* by @matchptr must be initialized to NULL before adding the first match. This +* only matches against components added with component_add(). * * The allocated match list in @matchptr is automatically released using devm * actions. * -* See also component_match_add_release(). +* See also component_match_add_release() and component_match_add_typed(). */ static inline void component_match_add(struct device *master, struct component_match **matchptr, --Quoted 8 lines
Quoted 3 lines
2.20.1
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 2/4] components: multiple components for a device
In reply to Daniel VetterQuoted 17 lines · Daniel Vetter
Component framework is extended to support multiple components for a struct device. These will be matched with different masters based on its sub component value.
We are introducing this, as I915 needs two different components with different subcomponent value, which will be matched to two different component masters(Audio and HDCP) based on the subcomponent values.
v2: Add documenation.
v3: Rebase on top of updated documenation.
v4: Review from Rafael:
- Remove redundant "This" from kerneldoc (also in the previous patch)
- Streamline the logic infind_component()a bit.
Quoted 11 lines
Signed-off-by Daniel Vetter <[email protected]> (v1 code)Signed-off-by Ramalingam C <[email protected]> (v1 commit message)Cc Ramalingam C <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/doc: document recommended component helper usage
In reply to Daniel VetterNow that component has docs it's worth spending a few words and hyperlinks on recommended best practices in drm.
--- Documentation/driver-api/component.rst | 2 ++ Documentation/gpu/drm-internals.rst | 5 +++++ drivers/gpu/drm/drm_drv.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+)
Documentation/driver-api/component.rst +2 -0
@@ -1,3 +1,5 @@ +.. _component: + ====================================== Component Helper for Aggregate Drivers ======================================
Documentation/gpu/drm-internals.rst +5 -0
@@ -93,6 +93,11 @@ Device Instance and Driver Handling Driver Load ----------- +Component Helper Usage +~~~~~~~~~~~~~~~~~~~~~~ + +.. kernel-doc:: drivers/gpu/drm/drm_drv.c + :doc: component helper usage recommendations IRQ Helper Library ~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/drm_drv.c +14 -0
@@ -456,6 +456,20 @@ static void drm_fs_inode_free(struct inode *inode) } } +/** +* DOC: component helper usage recommendations +* +* DRM drivers that drive hardware where a logical device consists of a pile of +* independent hardware blocks are recommended to use the :ref:`component helper +* library<component>`. The entire device initialization procedure should be run +* from the &component_master_ops.master_bind callback, starting with +* drm_dev_init(), then binding all components with component_bind_all() and +* finishing with drm_dev_register(). For consistency and easier sharing of +* components across drivers the opaque pointer passed to all components through +* component_bind_all() should point at &struct drm_device of the device +* instance, not some driver specific private structure. +*/ +/** * drm_dev_init - Initialise new DRM device * @dev: DRM device
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 i915/snd_hdac: I915 subcomponent for the snd_hdac
In reply to Daniel VetterSince we need multiple components for I915 for different purposes (Audio & Mei_hdcp), we adopt the subcomponents methodology introduced by the previous patch (mentioned below).
Author: Daniel Vetter <[email protected]>
Date: Mon Jan 28 17:08:20 2019 +0530
components: multiple components for a device
--- drivers/gpu/drm/i915/intel_audio.c | 4 +++- include/drm/i915_component.h | 4 ++++ include/sound/hda_component.h | 5 +++-- sound/hda/hdac_component.c | 4 ++-- sound/hda/hdac_i915.c | 6 ++++-- 5 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_audio.c +3 -1
@@ -984,7 +984,9 @@ void i915_audio_component_init(struct drm_i915_private *dev_priv) {int ret; - ret =component_add (dev_priv->drm.dev, &i915_audio_component_bind_ops); + ret =component_add_typed (dev_priv->drm.dev, + &i915_audio_component_bind_ops, +I915_COMPONENT_AUDIO );if (ret <0 ) {DRM_ERROR ("failed to add audio component (%d)\n" , ret);/* continue with reduced functionality */
include/drm/i915_component.h +4 -0
@@ -26,6 +26,10 @@#include "drm_audio_component.h" +enum i915_component_type { +I915_COMPONENT_AUDIO =1 , +}; +/* MAX_PORT is the number of port * It must be sync with I915_MAX_PORTS defined i915_drv.h */
include/sound/hda_component.h +3 -2
@@ -20,7 +20,7 @@ int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid, int dev_id, bool *audio_enabled, char *buffer, int max_bytes);int snd_hdac_acomp_init (struct hdac_bus *bus,const struct drm_audio_component_audio_ops *aops, -int (*match_master)(struct device *,void *), +int (*match_master)(struct device *,int ,void *),size_t extra_size);int snd_hdac_acomp_exit (struct hdac_bus *bus); int snd_hdac_acomp_register_notifier(struct hdac_bus *bus,
@@ -47,7 +47,8 @@ static inline int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t ni }static inline int snd_hdac_acomp_init (struct hdac_bus *bus,const struct drm_audio_component_audio_ops *aops, -int (*match_master)(struct device *,void *), +int (*match_master)(struct device *, +int ,void *),size_t extra_size) {return -ENODEV ;
sound/hda/hdac_component.c +2 -2
@@ -269,7 +269,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_acomp_register_notifier);*/ int snd_hdac_acomp_init (struct hdac_bus *bus,const struct drm_audio_component_audio_ops *aops, -int (*match_master)(struct device *,void *), +int (*match_master)(struct device *,int ,void *),size_t extra_size) {struct component_match *match =NULL ;
@@ -288,7 +288,7 @@ int snd_hdac_acomp_init(struct hdac_bus *bus, bus->audio_component = acomp;devres_add (dev, acomp); -component_match_add (dev, &match, match_master, bus); +component_match_add_typed (dev, &match, match_master, bus); ret =component_master_add_with_match (dev, &hdac_component_master_ops, match);if (ret <0 )
sound/hda/hdac_i915.c +4 -2
@@ -82,9 +82,11 @@ void snd_hdac_i915_set_bclk(struct hdac_bus *bus) }EXPORT_SYMBOL_GPL (snd_hdac_i915_set_bclk); -static int i915_component_master_match (struct device *dev,void *data) +static int i915_component_master_match (struct device *dev,int subcomponent, +void *data) { -return !strcmp (dev->driver->name,"i915" ); +return !strcmp (dev->driver->name,"i915" ) && + subcomponent ==I915_COMPONENT_AUDIO ; }/* check whether intel graphics is present */
Signature · 1 line
2.20.1
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for series starting with [1/4] component: Add documentation
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: series starting with [1/4] component: Add documentation
URL : https://patchwork.freedesktop.org/series/56372/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 4b25d63c44e7 component: Add documentation -:27: WARNING:TYPO_SPELLING: 'superflous' may be misspelled - perhaps 'superfluous'? #27: v4: Remove a few superflous "This".
-:41: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #41:
new file mode 100644
-:46: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #46: FILE: Documentation/driver-api/component.rst:1:
+======================================
-:264: CHECK:LINE_SPACING: Please don't use multiple blank lines #264: FILE: include/linux/component.h:7:
+
-:357: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <[email protected]>'
total: 0 errors, 4 warnings, 1 checks, 283 lines checked7648f41d42d8 components: multiple components for a device
-:44: WARNING:FUNCTION_ARGUMENTS: function definition argument 'struct device *' should also have an identifier name #44: FILE: drivers/base/component.c:50:
+ int (*compare_typed)(struct device *, int, void *);
-:44: WARNING:FUNCTION_ARGUMENTS: function definition argument 'int' should also have an identifier name #44: FILE: drivers/base/component.c:50:
+ int (*compare_typed)(struct device *, int, void *);
-:44: WARNING:FUNCTION_ARGUMENTS: function definition argument 'void *' should also have an identifier name #44: FILE: drivers/base/component.c:50:
+ int (*compare_typed)(struct device *, int, void *);
-:112: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #112: FILE: drivers/base/component.c:337:
+static void __component_match_add(struct device *master,
struct component_match **matchptr,
-:153: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #153: FILE: drivers/base/component.c:401:
+void component_match_add_release(struct device *master,
+ struct component_match **matchptr,
-:180: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #180: FILE: drivers/base/component.c:428:
+void component_match_add_typed(struct device *master,
+ struct component_match **matchptr,
-:209: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #209: FILE: drivers/base/component.c:665:
+static int __component_add(struct device *dev, const struct component_ops *ops,
+ int subcomponent)
-:237: WARNING:TYPO_SPELLING: 'registerd' may be misspelled - perhaps 'registered'? #237: FILE: drivers/base/component.c:707:
+ * components registerd on the same device @dev. These components are match
-:246: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #246: FILE: drivers/base/component.c:716:
+int component_add_typed(struct device *dev, const struct component_ops *ops,
+ int subcomponent)
-:286: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #286: FILE: include/linux/component.h:38:
+int component_add_typed(struct device *dev, const struct component_ops *ops,
+ int subcomponent);
-:295: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #295: FILE: include/linux/component.h:97:
+void component_match_add_typed(struct device *master,
+ struct component_match **matchptr,
total: 0 errors, 4 warnings, 7 checks, 259 lines checkedc583a70a9f8d drm/doc: document recommended component helper usage
-:17: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #17: FILE: Documentation/driver-api/component.rst:1:
+.. _component:
-:62: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <[email protected]>'
total: 0 errors, 2 warnings, 0 checks, 36 lines checked cf66b4cc035d i915/snd_hdac: I915 subcomponent for the snd_hdac -:16: WARNING:BAD_SIGN_OFF: Non-standard signature: Signed-off-by-by:
#16:
total: 0 errors, 1 warnings, 0 checks, 66 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [1/4] component: Add documentation
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: series starting with [1/4] component: Add documentation
URL : https://patchwork.freedesktop.org/series/56372/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5564 -> Patchwork_12174
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/56372/revisions/1/mbox/
Known issues
------------
Here are the changes found in Patchwork_12174 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_suspend@basic-s4-devices:
- fi-blb-e6850: PASS -> INCOMPLETE [fdo#107718]
* igt@kms_busy@basic-flip-a:
- fi-gdg-551: NOTRUN -> FAIL [fdo#103182] +1
* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: NOTRUN -> DMESG-FAIL [fdo#102614]
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- fi-byt-clapper: PASS -> INCOMPLETE [fdo#102657]
#### Possible fixes ####
* igt@kms_frontbuffer_tracking@basic:
- fi-byt-clapper: FAIL [fdo#103167] -> PASS
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#102657]: https://bugs.freedesktop.org/show_bug.cgi?id=102657
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#105998]: https://bugs.freedesktop.org/show_bug.cgi?id=105998
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109294]: https://bugs.freedesktop.org/show_bug.cgi?id=109294
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#109527]: https://bugs.freedesktop.org/show_bug.cgi?id=109527
[fdo#109528]: https://bugs.freedesktop.org/show_bug.cgi?id=109528
[fdo#109530]: https://bugs.freedesktop.org/show_bug.cgi?id=109530
Participating hosts (43 -> 44)
------------------------------
Additional (6): fi-byt-j1900 fi-hsw-peppy fi-gdg-551 fi-pnv-d510 fi-icl-y fi-bsw-kefka
Missing (5): fi-kbl-soraka fi-ilk-m540 fi-skl-gvtdvm fi-byt-squawks fi-bsw-cyan
Build changes
-------------
* Linux: CI_DRM_5564 -> Patchwork_12174
CI_DRM_5564: 41d3825370fbdfe5e8bab13fb87d52fc8a85cdaa @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4813: 09f506726d0e115ee7f4a1604ae71adcf9f12690 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12174: cf66b4cc035d6d2ca88b10e10d697bad5792173f @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
cf66b4cc035d i915/snd_hdac: I915 subcomponent for the snd_hdac c583a70a9f8d drm/doc: document recommended component helper usage 7648f41d42d8 components: multiple components for a device 4b25d63c44e7 component: Add documentation
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12174/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for series starting with [1/4] component: Add documentation
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: series starting with [1/4] component: Add documentation
URL : https://patchwork.freedesktop.org/series/56372/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5564_full -> Patchwork_12174_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_12174_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
- shard-kbl: NOTRUN -> DMESG-WARN [fdo#107956] +1
* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
- shard-glk: NOTRUN -> DMESG-WARN [fdo#107956]
* igt@kms_cursor_crc@cursor-64x21-onscreen:
- shard-glk: PASS -> FAIL [fdo#103232]
- shard-apl: PASS -> FAIL [fdo#103232]
* igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb:
- shard-apl: PASS -> FAIL [fdo#108145]
* igt@kms_plane_multiple@atomic-pipe-c-tiling-y:
- shard-glk: PASS -> FAIL [fdo#103166]
#### Possible fixes ####
* igt@kms_available_modes_crc@available_mode_test_crc:
- shard-glk: FAIL [fdo#106641] -> PASS
* igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
- shard-glk: FAIL [fdo#108145] -> PASS +1
* igt@kms_cursor_crc@cursor-128x128-sliding:
- shard-apl: FAIL [fdo#103232] -> PASS
- shard-glk: FAIL [fdo#103232] -> PASS
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-move:
- shard-glk: FAIL [fdo#103167] -> PASS +1
* igt@kms_plane@pixel-format-pipe-a-planes:
- shard-apl: FAIL [fdo#103166] -> PASS
* igt@kms_plane@pixel-format-pipe-c-planes-source-clamping:
- shard-glk: FAIL [fdo#108948] -> PASS
* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes:
- shard-glk: INCOMPLETE [fdo#103359] / [k.org#198133] -> PASS
* igt@kms_plane@plane-position-covered-pipe-c-planes:
- shard-glk: FAIL [fdo#103166] -> PASS +2
* igt@kms_setmode@basic:
- shard-kbl: FAIL [fdo#99912] -> PASS
#### Warnings ####
* igt@i915_suspend@shrink:
- shard-apl: DMESG-WARN [fdo#107886] / [fdo#109244] -> INCOMPLETE [fdo#103927] / [fdo#106886]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#106641]: https://bugs.freedesktop.org/show_bug.cgi?id=106641
[fdo#106886]: https://bugs.freedesktop.org/show_bug.cgi?id=106886
[fdo#107886]: https://bugs.freedesktop.org/show_bug.cgi?id=107886
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108948]: https://bugs.freedesktop.org/show_bug.cgi?id=108948
[fdo#109244]: https://bugs.freedesktop.org/show_bug.cgi?id=109244
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109373]: https://bugs.freedesktop.org/show_bug.cgi?id=109373
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
[k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133
[k.org#202321]: https://bugzilla.kernel.org/show_bug.cgi?id=202321
Participating hosts (7 -> 4)
------------------------------
Missing (3): shard-snb shard-skl shard-iclb
Build changes
-------------
* Linux: CI_DRM_5564 -> Patchwork_12174
CI_DRM_5564: 41d3825370fbdfe5e8bab13fb87d52fc8a85cdaa @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4813: 09f506726d0e115ee7f4a1604ae71adcf9f12690 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12174: cf66b4cc035d6d2ca88b10e10d697bad5792173f @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12174/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 23 lines · Daniel Vetter
While typing these I think doing an s/component_master/aggregate/ would be useful:
- it's shorter :-)
- I think component/aggregate is much more meaningful naming than component/puppetmaster or something like that. At least to my English ear "aggregate" emphasizes much more the "assemble a pile of things into something bigger" aspect, and there's not really much of a control hierarchy between aggregate and constituing components.But that's way more than a quick doc typing exercise ...
Thanks to Ram for commenting on an initial draft of these docs.
v2: Review from Rafael:
- git addDocumenation/driver-api/component.rst
- lots of polish to the wording + spelling fixes.v3: Review from Russell:
- s/framework/helper
- clarify the documentation forcomponent_match_addfunctions.v4: Remove a few superflous "This".
Quoted 10 lines
Reviewed-by Rafael J. Wysocki <[email protected]>Cc "C, Ramalingam" <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
Thanks for doing this!
Quoted 35 lines · Greg Kroah-Hartman
Quoted 23 lines · Daniel Vetter
While typing these I think doing an s/component_master/aggregate/ would be useful:
- it's shorter :-)
- I think component/aggregate is much more meaningful naming than component/puppetmaster or something like that. At least to my English ear "aggregate" emphasizes much more the "assemble a pile of things into something bigger" aspect, and there's not really much of a control hierarchy between aggregate and constituing components.But that's way more than a quick doc typing exercise ...
Thanks to Ram for commenting on an initial draft of these docs.
v2: Review from Rafael:
- git addDocumenation/driver-api/component.rst
- lots of polish to the wording + spelling fixes.v3: Review from Russell:
- s/framework/helper
- clarify the documentation forcomponent_match_addfunctions.v4: Remove a few superflous "This".
Quoted 10 lines
Reviewed-by Rafael J. Wysocki <[email protected]>Cc "C, Ramalingam" <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
Quoted 3 lines
Thanks for doing this!
Reviewed-by Greg Kroah-Hartman <[email protected]>
Thanks for reviewing (obviously includes Rafael and Russell too)!
For merging I see two options:
- All through drm-intel, but will only land in 5.2 because the feature cut-off has already happened for i915. So a bit awkward.
- Topic branch with the 2 component patches plus the snd-hda/drm-i915 patch, so that you/Takashi/drm can pull it in as needed. The drm component doc patch (3/4 in this series) I can pull in later on.
Greg/Takashi, any preferences?
Thanks, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 43 lines · Daniel Vetter
Quoted 35 lines · Greg Kroah-Hartman
Quoted 23 lines · Daniel Vetter
While typing these I think doing an s/component_master/aggregate/ would be useful:
- it's shorter :-)
- I think component/aggregate is much more meaningful naming than component/puppetmaster or something like that. At least to my English ear "aggregate" emphasizes much more the "assemble a pile of things into something bigger" aspect, and there's not really much of a control hierarchy between aggregate and constituing components.But that's way more than a quick doc typing exercise ...
Thanks to Ram for commenting on an initial draft of these docs.
v2: Review from Rafael:
- git addDocumenation/driver-api/component.rst
- lots of polish to the wording + spelling fixes.v3: Review from Russell:
- s/framework/helper
- clarify the documentation forcomponent_match_addfunctions.v4: Remove a few superflous "This".
Quoted 10 lines
Reviewed-by Rafael J. Wysocki <[email protected]>Cc "C, Ramalingam" <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Russell King <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Quoted 3 lines
Thanks for doing this!
Reviewed-by Greg Kroah-Hartman <[email protected]>Thanks for reviewing (obviously includes Rafael and Russell too)!
Quoted 8 lines
For merging I see two options:
- All through drm-intel, but will only land in 5.2 because the feature cut-off has already happened for i915. So a bit awkward.
- Topic branch with the 2 component patches plus the snd-hda/drm-i915 patch, so that you/Takashi/drm can pull it in as needed. The drm component doc patch (3/4 in this series) I can pull in later on.Greg/Takashi, any preferences?
Just realized that for the mei side of this series I need a topic branch anyway, so topic branch it is. I'll prep that so that CI can beat on it over the w/e, and we can rebase the i915/mei series on top, and then send out the topic pull to everyone early next week. You can then all decide whether you need it or not.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Randy Dunlap
reviewerOn 2/7/19 3:27 PM, Daniel Vetter wrote:
Hi Daniel,
I have a few possible changes for this documentation (see below).
Quoted 22 lines
--- Documentation/driver-api/component.rst | 17 ++++ Documentation/driver-api/device_link.rst | 3 + Documentation/driver-api/index.rst | 1 + drivers/base/component.c | 106 ++++++++++++++++++++++- include/linux/component.h | 70 +++++++++++++++ 5 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 Documentation/driver-api/component.rstdrivers/base/component.c +2
-0@@ -16,6 +16,32 @@#include <linux/slab.h> #include <linux/debugfs.h> +/** +* DOC: overview
drivers/base/component.c line 30
Quoted 10 lines
drivers/base/component.c +10
-0+* +* The component helper allows drivers to collect a pile of sub-devices, +* including their bound drivers, into an aggregate driver. Various subsystems +* already provide functions to get hold of such components, e.g. +* of_clk_get_by_name(). The component helper can be used when such a +* subsystem-specific way to find a device is not available: The component +* helper fills the niche of aggregate drivers for specific hardware, where +* further standardization into a subsystem would not be practical. The common +* example is when a logical device (e.g. a DRM display driver) is spread around +* the SoC on various component (scanout engines, blending blocks, transcoders
on various components
Quoted 81 lines
drivers/base/component.c +52
-3+* for various outputs and so on). +* +* The component helper also doesn't solve runtime dependencies, e.g. for system +* suspend and resume operations. See also :ref:`device links<device_link>`. +* +* Components are registered using component_add() and unregistered with +* component_del(), usually from the driver's probe and disconnect functions. +* +* Aggregate drivers first assemble a component match list of what they need +* using component_match_add(). This is then registered as an aggregate driver +* using component_master_add_with_match(), and unregistered using +* component_master_del(). +*/ +struct component ;struct component_match_array {@@ -301,10 +327,24 @@ static int component_match_realloc(struct device *dev,return 0 ; } -/* -* Add a component to be matched, with a release function. +/** +* component_match_add_release - add a component match with release callback +* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @release: release function for @compare_data +* @compare: compare function to match against all components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to +* by @matchptr must be initialized to NULL before adding the first match. +* +* The allocated match list in @matchptr is automatically released using devm +* actions, where upon @release will be called to free any references held by +* @compare_data, e.g. when @compare_data is a &device_node that must be +* released with of_node_put(). * -* The match array is first created or extended if necessary. +* See also component_match_add(). */ void component_match_add_release(struct device *master, struct component_match **matchptr,@@ -367,6 +407,18 @@ static void free_master(struct master *master)kfree (master); } +/** +* component_master_add_with_match - register an aggregate driver +* @dev: device with the aggregate driver +* @ops: callbacks for the aggregate driver +* @match: component match list for the aggregate driver +* +* Registers a new aggregate driver consisting of the components added to @match +* by calling one of the component_match_add() functions. Once all components in +* @match are available, it will be assembled by calling +* &component_master_ops.bind from @ops. Must be unregistered by calling +* component_master_del(). +*/ int component_master_add_with_match (struct device *dev,const struct component_master_ops *ops,struct component_match *match)@@ -403,6 +455,15 @@ int component_master_add_with_match(struct device *dev, }EXPORT_SYMBOL_GPL (component_master_add_with_match); +/** +* component_master_del - unregister an aggregate driver +* @dev: device with the aggregate driver +* @ops: callbacks for the aggregate driver +* +* Unregisters an aggregate driver registered with +* component_master_add_with_match(). If necessary the aggregate driver is first +* disassembled by calling &component_master_ops.unbind from @ops. +*/ void component_master_del (struct device *dev,const struct component_master_ops *ops) {
drivers/base/component.c static void component_unbind(struct component *component, · line 495
Quoted 5 lines
drivers/base/component.c +2
-0@@ -430,6 +491,15 @@ static void component_unbind(struct component *component,devres_release_group (component->dev, component); } +/** +* component_unbind_all - unbind all component to an aggregate driver
components {of | from} an aggregate driver
drivers/base/component.c static void component_unbind(struct component *component, · line 499
Quoted 4 lines
drivers/base/component.c +4
-0+* @master_dev: device with the aggregate driver +* @data: opaque pointer, passed to all components +* +* Unbinds all components to the aggregate @dev by passing @data to their
{of | from}drivers/base/component.c static int component_bind(struct component *component, struct master *master, · line 577
Quoted 12 lines
drivers/base/component.c +5
-0+* &component_ops.unbind functions. Should be called from +* &component_master_ops.unbind. +*/ void component_unbind_all (struct device *master_dev,void *data) {struct master *master;@@ -503,6 +573,15 @@ static int component_bind(struct component *component, struct master *master,return ret; } +/** +* component_bind_all - bind all component to an aggregate driver
components
Quoted 125 lines
drivers/base/component.c +28
-0+* @master_dev: device with the aggregate driver +* @data: opaque pointer, passed to all components +* +* Binds all components to the aggregate @dev by passing @data to their +* &component_ops.bind functions. Should be called from +* &component_master_ops.bind. +*/ int component_bind_all (struct device *master_dev,void *data) {struct master *master;@@ -537,6 +616,18 @@ int component_bind_all(struct device *master_dev, void *data) }EXPORT_SYMBOL_GPL (component_bind_all); +/** +* component_add - register a component +* @dev: component device +* @ops: component callbacks +* +* Register a new component for @dev. Functions in @ops will be called when the +* aggregate driver is ready to bind the overall driver by calling +* component_bind_all(). See also &struct component_ops. +* +* The component needs to be unregistered at driver unload/disconnect by calling +* component_del(). +*/ int component_add (struct device *dev,const struct component_ops *ops) {struct component *component;@@ -568,6 +659,15 @@ int component_add(struct device *dev, const struct component_ops *ops) }EXPORT_SYMBOL_GPL (component_add); +/** +* component_del - unregister a component +* @dev: component device +* @ops: component callbacks +* +* Unregister a component added with component_add(). If the component is bound +* into an aggregate driver, this will force the entire aggregate driver, including +* all its components, to be unbound. +*/ void component_del (struct device *dev,const struct component_ops *ops) {struct component *c, *component =NULL ;include/linux/component.h +54
-0@@ -4,11 +4,31 @@#include <linux/stddef.h> +struct device ; +/** +* struct component_ops - callbacks for component drivers +* +* Components are registered with component_add() and unregistered with +* component_del(). +*/ struct component_ops { +/** +* @bind: +* +* Called through component_bind_all() when the aggregate driver is +* ready to bind the overall driver. +*/ int (*bind)(struct device *comp,struct device *master,void *master_data); +/** +* @unbind: +* +* Called through component_unbind_all() when the aggregate driver is +* ready to bind the overall driver, or when component_bind_all() fails +* part-ways through and needs to unbind some already bound components. +*/ void (*unbind)(struct device *comp,struct device *master,void *master_data); };@@ -21,8 +41,42 @@ void component_unbind_all(struct device *master, void *master_data);struct master ; +/** +* struct component_master_ops - callback for the aggregate driver +* +* Aggregate drivers are registered with component_master_add_with_match() and +* unregistered with component_master_del(). +*/ struct component_master_ops { +/** +* @bind: +* +* Called when all components or the aggregate driver, as specified in +* the match list passed to component_master_add_with_match(), are +* ready. Usually there are 3 steps to bind an aggregate driver: +* +* 1. Allocate a structure for the aggregate driver. +* +* 2. Bind all components to the aggregate driver by calling +* component_bind_all() with the aggregate driver structure as opaque +* pointer data. +* +* 3. Register the aggregate driver with the subsystem to publish its +* interfaces. +* +* Note that the lifetime of the aggregate driver does not align with +* any of the underlying &struct device instances. Therefore devm cannot +* be used and all resources acquired or allocated in this callback must +* be explicitly released in the @unbind callback. +*/ int (*bind)(struct device *master); +/** +* @unbind: +* +* Called when either the aggregate driver, using +* component_master_del(), or one of its components, using +* component_del(), is unregistered. +*/ void (*unbind)(struct device *master); };
include/linux/component.h void component_match_add_release(struct device *master, · line 96
Quoted 5 lines
include/linux/component.h +2
-0@@ -38,6 +92,22 @@ void component_match_add_release(struct device *master,void (*release)(struct device *,void *), int (*compare)(struct device *, void *), void *compare_data); +/** +* component_match_add - add a compent match
component match entry (or item)
?
Quoted 8 lines
include/linux/component.h +7
-0+* @master: device with the aggregate driver +* @matchptr: pointer to the list of component matches +* @compare: compare function to match against all components +* @compare_data: opaque pointer passed to the @compare function +* +* Adds a new component match to the list stored in @matchptr, which the @master +* aggregate driver needs to function. The list of component matches pointed to
include/linux/component.h void component_match_add_release(struct device *master, · line 113
Quoted 10 lines
include/linux/component.h +7
-0+* by @matchptr must be initialized to NULL before adding the first match. +* +* The allocated match list in @matchptr is automatically released using devm +* actions. +* +* See also component_match_add_release(). +*/ static inline void component_match_add (struct device *master,struct component_match **matchptr,int (*compare)(struct device *,void *),void *compare_data)
cheers.
Signature · 1 line
~Randy