mbox series

[v8,0/3] drm: Introduce writeback connectors

Message ID 20180518151743.29937-1-Liviu.Dudau@arm.com
Headers show
Series drm: Introduce writeback connectors | expand

Message

Liviu Dudau May 18, 2018, 3:17 p.m. UTC
Hi,

This is v8 of the writeback connector series. v7 got flagged by the
kbuild bot as not being correctly bisectable, so I went and fix that.

For anyone that wants a refresh on what changed in v6, the series
can be found here [2]. The only change in v7 is that the userspace
capabilities patch does not depend on the cleanup patch that got NACKed.

Best regards,
Liviu


[1] https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/merge_requests/3
[2] https://lists.freedesktop.org/archives/dri-devel/2018-February/167703.html

Brian Starkey (2):
  drm: Add writeback connector type
  drm: writeback: Add out-fences for writeback connectors

Liviu Dudau (1):
  drm: writeback: Add client capability for exposing writeback
    connectors

 Documentation/gpu/drm-kms.rst            |   9 +
 drivers/gpu/drm/Makefile                 |   2 +-
 drivers/gpu/drm/drm_atomic.c             | 227 +++++++++++++-
 drivers/gpu/drm/drm_atomic_helper.c      |  30 ++
 drivers/gpu/drm/drm_connector.c          |   4 +-
 drivers/gpu/drm/drm_ioctl.c              |   7 +
 drivers/gpu/drm/drm_mode_config.c        |   5 +
 drivers/gpu/drm/drm_writeback.c          | 360 +++++++++++++++++++++++
 include/drm/drm_atomic.h                 |  11 +
 include/drm/drm_connector.h              |  13 +
 include/drm/drm_file.h                   |   7 +
 include/drm/drm_mode_config.h            |  23 ++
 include/drm/drm_modeset_helper_vtables.h |  11 +
 include/drm/drm_writeback.h              | 129 ++++++++
 include/uapi/drm/drm.h                   |   9 +
 include/uapi/drm/drm_mode.h              |   1 +
 16 files changed, 837 insertions(+), 11 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_writeback.c
 create mode 100644 include/drm/drm_writeback.h

Comments

Eric Anholt May 21, 2018, 7:02 p.m. UTC | #1
Liviu Dudau <Liviu.Dudau@arm.com> writes:

> From: Brian Starkey <brian.starkey@arm.com>

>

> Add the WRITEBACK_OUT_FENCE_PTR property to writeback connectors, to

> enable userspace to get a fence which will signal once the writeback is

> complete. It is not allowed to request an out-fence without a

> framebuffer attached to the connector.

>

> A timeline is added to drm_writeback_connector for use by the writeback

> out-fences.



> diff --git a/include/drm/drm_writeback.h b/include/drm/drm_writeback.h

> index cf3a28676006a..6a7462c1821ad 100644

> --- a/include/drm/drm_writeback.h

> +++ b/include/drm/drm_writeback.h

> @@ -49,6 +49,32 @@ struct drm_writeback_connector {

>  	 * drm_writeback_signal_completion()

>  	 */

>  	struct list_head job_queue;

> +

> +	/**

> +	 * @fence_context:

> +	 *

> +	 * timeline context used for fence operations.

> +	 */

> +	unsigned int fence_context;

> +	/**

> +	 * @fence_lock:

> +	 *

> +	 * spinlock to protect the fences in the fence_context.

> +	 */

> +	spinlock_t fence_lock;

> +	/**

> +	 * @fence_seqno:

> +	 *

> +	 * Seqno variable used as monotonic counter for the fences

> +	 * created on the connector's timeline.

> +	 */

> +	unsigned long fence_seqno;

> +	/**

> +	 * @timeline_name:

> +	 *

> +	 * The name of the connector's fence timeline.

> +	 */

> +	char timeline_name[32];

>  };

>  

>  struct drm_writeback_job {

> @@ -59,12 +85,14 @@ struct drm_writeback_job {

>  	 * framebuffer reference to a workqueue.

>  	 */

>  	struct work_struct cleanup_work;

> +

>  	/**

>  	 * @list_entry:

>  	 *

>  	 * List item for the connector's @job_queue

>  	 */

>  	struct list_head list_entry;

> +

>  	/**

>  	 * @fb:

>  	 *


Move this hunk into patch 1?

Other than that, the series is:

Reviewed-by: Eric Anholt <eric@anholt.net>


It's pretty clean and makes sense to me.  I only had some questions
about the job_queue, which seems superfluous if we aren't supporting
firing off a new writeback while an old one is outstanding (and maybe we
should throw an error in that case).  Still, I think this is ready to land.
Maarten Lankhorst May 23, 2018, 9:34 a.m. UTC | #2
Op 18-05-18 om 17:17 schreef Liviu Dudau:
> Due to the fact that writeback connectors behave in a special way
> in DRM (they always report being disconnected) we might confuse some
> userspace. Add a client capability for writeback connectors that will
> filter them out for clients that don't understand the capability.
>
> Re-requested-by: Sean Paul <seanpaul@chromium.org>
> Cc: Brian Starkey <brian.starkey@arm.com>
> Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
> ---
>  drivers/gpu/drm/drm_ioctl.c       | 7 +++++++
>  drivers/gpu/drm/drm_mode_config.c | 5 +++++
>  include/drm/drm_file.h            | 7 +++++++
>  include/uapi/drm/drm.h            | 9 +++++++++
>  4 files changed, 28 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index af782911c505d..59951ff3e3630 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -325,6 +325,13 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
>  		file_priv->atomic = req->value;
>  		file_priv->universal_planes = req->value;
>  		break;
> +	case DRM_CLIENT_CAP_WRITEBACK_CONNECTORS:
> +		if (!file_priv->atomic || !drm_core_check_feature(dev, DRIVER_ATOMIC))
> +			return -EINVAL;
Wondering how you can set the atomic cap without DRIVER_ATOMIC. :)

That part could be dropped I think. We should probably WARN when trying to create a writeback connector without the DRIVER_ATOMIC cap set.
> +		if (req->value > 1)
> +			return -EINVAL;
> +		file_priv->writeback_connectors = req->value;
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index e5c653357024d..21e353bd3948e 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -145,6 +145,11 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
>  	count = 0;
>  	connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
>  	drm_for_each_connector_iter(connector, &conn_iter) {
> +		/* only expose writeback connectors if userspace understands them */
> +		if (!file_priv->writeback_connectors &&
> +		    (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK))
> +			continue;
> +
>  		if (drm_lease_held(file_priv, connector->base.id)) {
>  			if (count < card_res->count_connectors &&
>  			    put_user(connector->base.id, connector_id + count)) {
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index 5176c3797680c..2a09b3c8965c6 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -181,6 +181,13 @@ struct drm_file {
>  	/** @atomic: True if client understands atomic properties. */
>  	unsigned atomic:1;
>  
> +	/**
> +	 * @writeback_connectors:
> +	 *
> +	 * True if client understands writeback connectors
> +	 */
> +	unsigned writeback_connectors:1;
> +
>  	/**
>  	 * @is_master:
>  	 *
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index 6fdff5945c8a0..59f27ea928b42 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -680,6 +680,15 @@ struct drm_get_cap {
>   */
>  #define DRM_CLIENT_CAP_ATOMIC	3
>  
> +/**
> + * DRM_CLIENT_CAP_WRITEBACK_CONNECTORS
> + *
> + * If set to 1, the DRM core will expose special connectors to be used for
> + * writing back to memory the scene setup in the commit. Depends on client
> + * also supporting DRM_CLIENT_CAP_ATOMIC
> + */
> +#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS	4
> +
>  /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
>  struct drm_set_client_cap {
>  	__u64 capability;

~Maarten