diff options
author | Thierry Reding <treding@nvidia.com> | 2017-04-10 06:27:01 -0400 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2017-06-15 07:58:43 -0400 |
commit | 466749f13e33d892cf9263d7efbc0ea713c23ed7 (patch) | |
tree | 49de643a08afaad0f18efda4495ca1ca84c11f2a | |
parent | 2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff) |
gpu: host1x: Flesh out kerneldoc
Improve kerneldoc for the public parts of the host1x infrastructure in
preparation for adding driver-specific part to the GPU documentation.
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r-- | drivers/gpu/host1x/bus.c | 75 | ||||
-rw-r--r-- | drivers/gpu/host1x/syncpt.c | 81 | ||||
-rw-r--r-- | include/linux/host1x.h | 25 |
3 files changed, 170 insertions, 11 deletions
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 561831e1ae2c..a048e3ac523d 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c | |||
@@ -40,6 +40,9 @@ struct host1x_subdev { | |||
40 | 40 | ||
41 | /** | 41 | /** |
42 | * host1x_subdev_add() - add a new subdevice with an associated device node | 42 | * host1x_subdev_add() - add a new subdevice with an associated device node |
43 | * @device: host1x device to add the subdevice to | ||
44 | * @driver: host1x driver | ||
45 | * @np: device node | ||
43 | */ | 46 | */ |
44 | static int host1x_subdev_add(struct host1x_device *device, | 47 | static int host1x_subdev_add(struct host1x_device *device, |
45 | struct device_node *np) | 48 | struct device_node *np) |
@@ -62,6 +65,7 @@ static int host1x_subdev_add(struct host1x_device *device, | |||
62 | 65 | ||
63 | /** | 66 | /** |
64 | * host1x_subdev_del() - remove subdevice | 67 | * host1x_subdev_del() - remove subdevice |
68 | * @subdev: subdevice to remove | ||
65 | */ | 69 | */ |
66 | static void host1x_subdev_del(struct host1x_subdev *subdev) | 70 | static void host1x_subdev_del(struct host1x_subdev *subdev) |
67 | { | 71 | { |
@@ -72,6 +76,8 @@ static void host1x_subdev_del(struct host1x_subdev *subdev) | |||
72 | 76 | ||
73 | /** | 77 | /** |
74 | * host1x_device_parse_dt() - scan device tree and add matching subdevices | 78 | * host1x_device_parse_dt() - scan device tree and add matching subdevices |
79 | * @device: host1x logical device | ||
80 | * @driver: host1x driver | ||
75 | */ | 81 | */ |
76 | static int host1x_device_parse_dt(struct host1x_device *device, | 82 | static int host1x_device_parse_dt(struct host1x_device *device, |
77 | struct host1x_driver *driver) | 83 | struct host1x_driver *driver) |
@@ -166,6 +172,16 @@ static void host1x_subdev_unregister(struct host1x_device *device, | |||
166 | mutex_unlock(&device->subdevs_lock); | 172 | mutex_unlock(&device->subdevs_lock); |
167 | } | 173 | } |
168 | 174 | ||
175 | /** | ||
176 | * host1x_device_init() - initialize a host1x logical device | ||
177 | * @device: host1x logical device | ||
178 | * | ||
179 | * The driver for the host1x logical device can call this during execution of | ||
180 | * its &host1x_driver.probe implementation to initialize each of its clients. | ||
181 | * The client drivers access the subsystem specific driver data using the | ||
182 | * &host1x_client.parent field and driver data associated with it (usually by | ||
183 | * calling dev_get_drvdata()). | ||
184 | */ | ||
169 | int host1x_device_init(struct host1x_device *device) | 185 | int host1x_device_init(struct host1x_device *device) |
170 | { | 186 | { |
171 | struct host1x_client *client; | 187 | struct host1x_client *client; |
@@ -192,6 +208,15 @@ int host1x_device_init(struct host1x_device *device) | |||
192 | } | 208 | } |
193 | EXPORT_SYMBOL(host1x_device_init); | 209 | EXPORT_SYMBOL(host1x_device_init); |
194 | 210 | ||
211 | /** | ||
212 | * host1x_device_exit() - uninitialize host1x logical device | ||
213 | * @device: host1x logical device | ||
214 | * | ||
215 | * When the driver for a host1x logical device is unloaded, it can call this | ||
216 | * function to tear down each of its clients. Typically this is done after a | ||
217 | * subsystem-specific data structure is removed and the functionality can no | ||
218 | * longer be used. | ||
219 | */ | ||
195 | int host1x_device_exit(struct host1x_device *device) | 220 | int host1x_device_exit(struct host1x_device *device) |
196 | { | 221 | { |
197 | struct host1x_client *client; | 222 | struct host1x_client *client; |
@@ -446,6 +471,14 @@ static void host1x_detach_driver(struct host1x *host1x, | |||
446 | mutex_unlock(&host1x->devices_lock); | 471 | mutex_unlock(&host1x->devices_lock); |
447 | } | 472 | } |
448 | 473 | ||
474 | /** | ||
475 | * host1x_register() - register a host1x controller | ||
476 | * @host1x: host1x controller | ||
477 | * | ||
478 | * The host1x controller driver uses this to register a host1x controller with | ||
479 | * the infrastructure. Note that all Tegra SoC generations have only ever come | ||
480 | * with a single host1x instance, so this function is somewhat academic. | ||
481 | */ | ||
449 | int host1x_register(struct host1x *host1x) | 482 | int host1x_register(struct host1x *host1x) |
450 | { | 483 | { |
451 | struct host1x_driver *driver; | 484 | struct host1x_driver *driver; |
@@ -464,6 +497,13 @@ int host1x_register(struct host1x *host1x) | |||
464 | return 0; | 497 | return 0; |
465 | } | 498 | } |
466 | 499 | ||
500 | /** | ||
501 | * host1x_unregister() - unregister a host1x controller | ||
502 | * @host1x: host1x controller | ||
503 | * | ||
504 | * The host1x controller driver uses this to remove a host1x controller from | ||
505 | * the infrastructure. | ||
506 | */ | ||
467 | int host1x_unregister(struct host1x *host1x) | 507 | int host1x_unregister(struct host1x *host1x) |
468 | { | 508 | { |
469 | struct host1x_driver *driver; | 509 | struct host1x_driver *driver; |
@@ -513,6 +553,16 @@ static void host1x_device_shutdown(struct device *dev) | |||
513 | driver->shutdown(device); | 553 | driver->shutdown(device); |
514 | } | 554 | } |
515 | 555 | ||
556 | /** | ||
557 | * host1x_driver_register_full() - register a host1x driver | ||
558 | * @driver: host1x driver | ||
559 | * @owner: owner module | ||
560 | * | ||
561 | * Drivers for host1x logical devices call this function to register a driver | ||
562 | * with the infrastructure. Note that since these drive logical devices, the | ||
563 | * registration of the driver actually triggers tho logical device creation. | ||
564 | * A logical device will be created for each host1x instance. | ||
565 | */ | ||
516 | int host1x_driver_register_full(struct host1x_driver *driver, | 566 | int host1x_driver_register_full(struct host1x_driver *driver, |
517 | struct module *owner) | 567 | struct module *owner) |
518 | { | 568 | { |
@@ -541,6 +591,13 @@ int host1x_driver_register_full(struct host1x_driver *driver, | |||
541 | } | 591 | } |
542 | EXPORT_SYMBOL(host1x_driver_register_full); | 592 | EXPORT_SYMBOL(host1x_driver_register_full); |
543 | 593 | ||
594 | /** | ||
595 | * host1x_driver_unregister() - unregister a host1x driver | ||
596 | * @driver: host1x driver | ||
597 | * | ||
598 | * Unbinds the driver from each of the host1x logical devices that it is | ||
599 | * bound to, effectively removing the subsystem devices that they represent. | ||
600 | */ | ||
544 | void host1x_driver_unregister(struct host1x_driver *driver) | 601 | void host1x_driver_unregister(struct host1x_driver *driver) |
545 | { | 602 | { |
546 | driver_unregister(&driver->driver); | 603 | driver_unregister(&driver->driver); |
@@ -551,6 +608,17 @@ void host1x_driver_unregister(struct host1x_driver *driver) | |||
551 | } | 608 | } |
552 | EXPORT_SYMBOL(host1x_driver_unregister); | 609 | EXPORT_SYMBOL(host1x_driver_unregister); |
553 | 610 | ||
611 | /** | ||
612 | * host1x_client_register() - register a host1x client | ||
613 | * @client: host1x client | ||
614 | * | ||
615 | * Registers a host1x client with each host1x controller instance. Note that | ||
616 | * each client will only match their parent host1x controller and will only be | ||
617 | * associated with that instance. Once all clients have been registered with | ||
618 | * their parent host1x controller, the infrastructure will set up the logical | ||
619 | * device and call host1x_device_init(), which will in turn call each client's | ||
620 | * &host1x_client_ops.init implementation. | ||
621 | */ | ||
554 | int host1x_client_register(struct host1x_client *client) | 622 | int host1x_client_register(struct host1x_client *client) |
555 | { | 623 | { |
556 | struct host1x *host1x; | 624 | struct host1x *host1x; |
@@ -576,6 +644,13 @@ int host1x_client_register(struct host1x_client *client) | |||
576 | } | 644 | } |
577 | EXPORT_SYMBOL(host1x_client_register); | 645 | EXPORT_SYMBOL(host1x_client_register); |
578 | 646 | ||
647 | /** | ||
648 | * host1x_client_unregister() - unregister a host1x client | ||
649 | * @client: host1x client | ||
650 | * | ||
651 | * Removes a host1x client from its host1x controller instance. If a logical | ||
652 | * device has already been initialized, it will be torn down. | ||
653 | */ | ||
579 | int host1x_client_unregister(struct host1x_client *client) | 654 | int host1x_client_unregister(struct host1x_client *client) |
580 | { | 655 | { |
581 | struct host1x_client *c; | 656 | struct host1x_client *c; |
diff --git a/drivers/gpu/host1x/syncpt.c b/drivers/gpu/host1x/syncpt.c index 0ac026cdc30c..048ac9e344ce 100644 --- a/drivers/gpu/host1x/syncpt.c +++ b/drivers/gpu/host1x/syncpt.c | |||
@@ -99,14 +99,24 @@ unlock: | |||
99 | return NULL; | 99 | return NULL; |
100 | } | 100 | } |
101 | 101 | ||
102 | /** | ||
103 | * host1x_syncpt_id() - retrieve syncpoint ID | ||
104 | * @sp: host1x syncpoint | ||
105 | * | ||
106 | * Given a pointer to a struct host1x_syncpt, retrieves its ID. This ID is | ||
107 | * often used as a value to program into registers that control how hardware | ||
108 | * blocks interact with syncpoints. | ||
109 | */ | ||
102 | u32 host1x_syncpt_id(struct host1x_syncpt *sp) | 110 | u32 host1x_syncpt_id(struct host1x_syncpt *sp) |
103 | { | 111 | { |
104 | return sp->id; | 112 | return sp->id; |
105 | } | 113 | } |
106 | EXPORT_SYMBOL(host1x_syncpt_id); | 114 | EXPORT_SYMBOL(host1x_syncpt_id); |
107 | 115 | ||
108 | /* | 116 | /** |
109 | * Updates the value sent to hardware. | 117 | * host1x_syncpt_incr_max() - update the value sent to hardware |
118 | * @sp: host1x syncpoint | ||
119 | * @incrs: number of increments | ||
110 | */ | 120 | */ |
111 | u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs) | 121 | u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs) |
112 | { | 122 | { |
@@ -175,8 +185,9 @@ u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp) | |||
175 | return sp->base_val; | 185 | return sp->base_val; |
176 | } | 186 | } |
177 | 187 | ||
178 | /* | 188 | /** |
179 | * Increment syncpoint value from cpu, updating cache | 189 | * host1x_syncpt_incr() - increment syncpoint value from CPU, updating cache |
190 | * @sp: host1x syncpoint | ||
180 | */ | 191 | */ |
181 | int host1x_syncpt_incr(struct host1x_syncpt *sp) | 192 | int host1x_syncpt_incr(struct host1x_syncpt *sp) |
182 | { | 193 | { |
@@ -195,8 +206,12 @@ static bool syncpt_load_min_is_expired(struct host1x_syncpt *sp, u32 thresh) | |||
195 | return host1x_syncpt_is_expired(sp, thresh); | 206 | return host1x_syncpt_is_expired(sp, thresh); |
196 | } | 207 | } |
197 | 208 | ||
198 | /* | 209 | /** |
199 | * Main entrypoint for syncpoint value waits. | 210 | * host1x_syncpt_wait() - wait for a syncpoint to reach a given value |
211 | * @sp: host1x syncpoint | ||
212 | * @thresh: threshold | ||
213 | * @timeout: maximum time to wait for the syncpoint to reach the given value | ||
214 | * @value: return location for the syncpoint value | ||
200 | */ | 215 | */ |
201 | int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout, | 216 | int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout, |
202 | u32 *value) | 217 | u32 *value) |
@@ -402,6 +417,16 @@ int host1x_syncpt_init(struct host1x *host) | |||
402 | return 0; | 417 | return 0; |
403 | } | 418 | } |
404 | 419 | ||
420 | /** | ||
421 | * host1x_syncpt_request() - request a syncpoint | ||
422 | * @dev: device requesting the syncpoint | ||
423 | * @flags: flags | ||
424 | * | ||
425 | * host1x client drivers can use this function to allocate a syncpoint for | ||
426 | * subsequent use. A syncpoint returned by this function will be reserved for | ||
427 | * use by the client exclusively. When no longer using a syncpoint, a host1x | ||
428 | * client driver needs to release it using host1x_syncpt_free(). | ||
429 | */ | ||
405 | struct host1x_syncpt *host1x_syncpt_request(struct device *dev, | 430 | struct host1x_syncpt *host1x_syncpt_request(struct device *dev, |
406 | unsigned long flags) | 431 | unsigned long flags) |
407 | { | 432 | { |
@@ -411,6 +436,16 @@ struct host1x_syncpt *host1x_syncpt_request(struct device *dev, | |||
411 | } | 436 | } |
412 | EXPORT_SYMBOL(host1x_syncpt_request); | 437 | EXPORT_SYMBOL(host1x_syncpt_request); |
413 | 438 | ||
439 | /** | ||
440 | * host1x_syncpt_free() - free a requested syncpoint | ||
441 | * @sp: host1x syncpoint | ||
442 | * | ||
443 | * Release a syncpoint previously allocated using host1x_syncpt_request(). A | ||
444 | * host1x client driver should call this when the syncpoint is no longer in | ||
445 | * use. Note that client drivers must ensure that the syncpoint doesn't remain | ||
446 | * under the control of hardware after calling this function, otherwise two | ||
447 | * clients may end up trying to access the same syncpoint concurrently. | ||
448 | */ | ||
414 | void host1x_syncpt_free(struct host1x_syncpt *sp) | 449 | void host1x_syncpt_free(struct host1x_syncpt *sp) |
415 | { | 450 | { |
416 | if (!sp) | 451 | if (!sp) |
@@ -438,9 +473,12 @@ void host1x_syncpt_deinit(struct host1x *host) | |||
438 | kfree(sp->name); | 473 | kfree(sp->name); |
439 | } | 474 | } |
440 | 475 | ||
441 | /* | 476 | /** |
442 | * Read max. It indicates how many operations there are in queue, either in | 477 | * host1x_syncpt_read_max() - read maximum syncpoint value |
443 | * channel or in a software thread. | 478 | * @sp: host1x syncpoint |
479 | * | ||
480 | * The maximum syncpoint value indicates how many operations there are in | ||
481 | * queue, either in channel or in a software thread. | ||
444 | */ | 482 | */ |
445 | u32 host1x_syncpt_read_max(struct host1x_syncpt *sp) | 483 | u32 host1x_syncpt_read_max(struct host1x_syncpt *sp) |
446 | { | 484 | { |
@@ -450,8 +488,12 @@ u32 host1x_syncpt_read_max(struct host1x_syncpt *sp) | |||
450 | } | 488 | } |
451 | EXPORT_SYMBOL(host1x_syncpt_read_max); | 489 | EXPORT_SYMBOL(host1x_syncpt_read_max); |
452 | 490 | ||
453 | /* | 491 | /** |
454 | * Read min, which is a shadow of the current sync point value in hardware. | 492 | * host1x_syncpt_read_min() - read minimum syncpoint value |
493 | * @sp: host1x syncpoint | ||
494 | * | ||
495 | * The minimum syncpoint value is a shadow of the current sync point value in | ||
496 | * hardware. | ||
455 | */ | 497 | */ |
456 | u32 host1x_syncpt_read_min(struct host1x_syncpt *sp) | 498 | u32 host1x_syncpt_read_min(struct host1x_syncpt *sp) |
457 | { | 499 | { |
@@ -461,6 +503,10 @@ u32 host1x_syncpt_read_min(struct host1x_syncpt *sp) | |||
461 | } | 503 | } |
462 | EXPORT_SYMBOL(host1x_syncpt_read_min); | 504 | EXPORT_SYMBOL(host1x_syncpt_read_min); |
463 | 505 | ||
506 | /** | ||
507 | * host1x_syncpt_read() - read the current syncpoint value | ||
508 | * @sp: host1x syncpoint | ||
509 | */ | ||
464 | u32 host1x_syncpt_read(struct host1x_syncpt *sp) | 510 | u32 host1x_syncpt_read(struct host1x_syncpt *sp) |
465 | { | 511 | { |
466 | return host1x_syncpt_load(sp); | 512 | return host1x_syncpt_load(sp); |
@@ -482,6 +528,11 @@ unsigned int host1x_syncpt_nb_mlocks(struct host1x *host) | |||
482 | return host->info->nb_mlocks; | 528 | return host->info->nb_mlocks; |
483 | } | 529 | } |
484 | 530 | ||
531 | /** | ||
532 | * host1x_syncpt_get() - obtain a syncpoint by ID | ||
533 | * @host: host1x controller | ||
534 | * @id: syncpoint ID | ||
535 | */ | ||
485 | struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, unsigned int id) | 536 | struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, unsigned int id) |
486 | { | 537 | { |
487 | if (id >= host->info->nb_pts) | 538 | if (id >= host->info->nb_pts) |
@@ -491,12 +542,20 @@ struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, unsigned int id) | |||
491 | } | 542 | } |
492 | EXPORT_SYMBOL(host1x_syncpt_get); | 543 | EXPORT_SYMBOL(host1x_syncpt_get); |
493 | 544 | ||
545 | /** | ||
546 | * host1x_syncpt_get_base() - obtain the wait base associated with a syncpoint | ||
547 | * @sp: host1x syncpoint | ||
548 | */ | ||
494 | struct host1x_syncpt_base *host1x_syncpt_get_base(struct host1x_syncpt *sp) | 549 | struct host1x_syncpt_base *host1x_syncpt_get_base(struct host1x_syncpt *sp) |
495 | { | 550 | { |
496 | return sp ? sp->base : NULL; | 551 | return sp ? sp->base : NULL; |
497 | } | 552 | } |
498 | EXPORT_SYMBOL(host1x_syncpt_get_base); | 553 | EXPORT_SYMBOL(host1x_syncpt_get_base); |
499 | 554 | ||
555 | /** | ||
556 | * host1x_syncpt_base_id() - retrieve the ID of a syncpoint wait base | ||
557 | * @base: host1x syncpoint wait base | ||
558 | */ | ||
500 | u32 host1x_syncpt_base_id(struct host1x_syncpt_base *base) | 559 | u32 host1x_syncpt_base_id(struct host1x_syncpt_base *base) |
501 | { | 560 | { |
502 | return base->id; | 561 | return base->id; |
diff --git a/include/linux/host1x.h b/include/linux/host1x.h index 3d04aa1dc83e..840a8ad627b2 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h | |||
@@ -32,11 +32,27 @@ enum host1x_class { | |||
32 | 32 | ||
33 | struct host1x_client; | 33 | struct host1x_client; |
34 | 34 | ||
35 | /** | ||
36 | * struct host1x_client_ops - host1x client operations | ||
37 | * @init: host1x client initialization code | ||
38 | * @exit: host1x client tear down code | ||
39 | */ | ||
35 | struct host1x_client_ops { | 40 | struct host1x_client_ops { |
36 | int (*init)(struct host1x_client *client); | 41 | int (*init)(struct host1x_client *client); |
37 | int (*exit)(struct host1x_client *client); | 42 | int (*exit)(struct host1x_client *client); |
38 | }; | 43 | }; |
39 | 44 | ||
45 | /** | ||
46 | * struct host1x_client - host1x client structure | ||
47 | * @list: list node for the host1x client | ||
48 | * @parent: pointer to struct device representing the host1x controller | ||
49 | * @dev: pointer to struct device backing this host1x client | ||
50 | * @ops: host1x client operations | ||
51 | * @class: host1x class represented by this client | ||
52 | * @channel: host1x channel associated with this client | ||
53 | * @syncpts: array of syncpoints requested for this client | ||
54 | * @num_syncpts: number of syncpoints requested for this client | ||
55 | */ | ||
40 | struct host1x_client { | 56 | struct host1x_client { |
41 | struct list_head list; | 57 | struct list_head list; |
42 | struct device *parent; | 58 | struct device *parent; |
@@ -251,6 +267,15 @@ void host1x_job_unpin(struct host1x_job *job); | |||
251 | 267 | ||
252 | struct host1x_device; | 268 | struct host1x_device; |
253 | 269 | ||
270 | /** | ||
271 | * struct host1x_driver - host1x logical device driver | ||
272 | * @driver: core driver | ||
273 | * @subdevs: table of OF device IDs matching subdevices for this driver | ||
274 | * @list: list node for the driver | ||
275 | * @probe: called when the host1x logical device is probed | ||
276 | * @remove: called when the host1x logical device is removed | ||
277 | * @shutdown: called when the host1x logical device is shut down | ||
278 | */ | ||
254 | struct host1x_driver { | 279 | struct host1x_driver { |
255 | struct device_driver driver; | 280 | struct device_driver driver; |
256 | 281 | ||