public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 08/11] drm/fb-helper: Remove drm_fb_helper_connector
Date: Thu, 16 May 2019 15:07:32 +0200	[thread overview]
Message-ID: <20190516130732.GA12435@ravnborg.org> (raw)
In-Reply-To: <20190506180139.6913-9-noralf@tronnes.org>

Hi Noralf.

See few comments in the following.

	Sam

On Mon, May 06, 2019 at 08:01:36PM +0200, Noralf Trønnes wrote:
> All drivers add all their connectors so there's no need to keep around an
> array of available connectors.
> 
> Rename functions which signature is changed since they will be moved to
> drm_client in a later patch.
> 
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
> @@ -1645,8 +1461,9 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
>  	struct drm_client_dev *client = &fb_helper->client;
>  	int ret = 0;
>  	int crtc_count = 0;
> -	int i;
> +	struct drm_connector_list_iter conn_iter;
>  	struct drm_fb_helper_surface_size sizes;
> +	struct drm_connector *connector;
>  	struct drm_mode_set *mode_set;
>  	int best_depth = 0;
>  
> @@ -1663,11 +1480,11 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
>  	if (preferred_bpp != sizes.surface_bpp)
>  		sizes.surface_depth = sizes.surface_bpp = preferred_bpp;
>  
> -	drm_fb_helper_for_each_connector(fb_helper, i) {
> -		struct drm_fb_helper_connector *fb_helper_conn = fb_helper->connector_info[i];
> +	drm_connector_list_iter_begin(fb_helper->dev, &conn_iter);
> +	drm_client_for_each_connector_iter(connector, &conn_iter) {
>  		struct drm_cmdline_mode *cmdline_mode;

I fail to see when to use drm_client_for_each_connector_iter() and when
to use a simple for loop.
In this patch drm_fb_helper_for_each_connector() is here replaced by the
iterator variant and in many other placed a simple for loop.

The old code, in this place, would go through all connectors, but this
code will skip 	DRM_MODE_CONNECTOR_WRITEBACK conectors.
So it does not like identical code.

>  
> -		cmdline_mode = &fb_helper_conn->connector->cmdline_mode;
> +		cmdline_mode = &connector->cmdline_mode;
>  
>  		if (cmdline_mode->bpp_specified) {
>  			switch (cmdline_mode->bpp) {
> @@ -1692,6 +1509,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
>  			break;
>  		}
>  	}
> +	drm_connector_list_iter_end(&conn_iter);
>  
>  	/*
>  	 * If we run into a situation where, for example, the primary plane
> @@ -1876,26 +1694,12 @@ void drm_fb_helper_fill_info(struct fb_info *info,
>  }
>  EXPORT_SYMBOL(drm_fb_helper_fill_info);
>  
> +static void drm_client_connectors_enabled(struct drm_connector **connectors,
> +					  unsigned int connector_count,
> +					  bool *enabled)
>  {
>  	bool any_enabled = false;
>  	struct drm_connector *connector;
>  	int i = 0;
>  
> -	drm_fb_helper_for_each_connector(fb_helper, i) {
> -		connector = fb_helper->connector_info[i]->connector;
> +	for (i = 0; i < connector_count; i++) {
> +		connector = connectors[i];
This is for example a place where the drm_fb_helper_for_each_connector()
is replaced by a simple for loop.
The simple for loop is nice and readable - just a comment replated to
the above comment.

>  		struct drm_display_mode *mode = modes[i];
>  		struct drm_crtc *crtc = crtcs[i];
>  		struct drm_fb_offset *offset = &offsets[i];
>  
>  		if (mode && crtc) {
>  			struct drm_mode_set *modeset = drm_client_find_modeset(client, crtc);
> -			struct drm_connector *connector =
> -				fb_helper->connector_info[i]->connector;
> +			struct drm_connector *connector = connectors[i];
>  
>  			DRM_DEBUG_KMS("desired mode %s set on crtc %d (%d,%d)\n",
>  				      mode->name, crtc->base.id, offset->x, offset->y);
> @@ -2539,6 +2354,10 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,
>  	kfree(modes);
>  	kfree(offsets);
>  	kfree(enabled);
> +free_connectors:
> +	for (i = 0; i < connector_count; i++)
> +		drm_connector_put(connectors[i]);
This may call drm_connector_put(NULL) as not all connectors are init.

> +	kfree(connectors);
>  }
>  
>  /*
> @@ -2551,10 +2370,11 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,
>  static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper)
>  {
>  	struct drm_client_dev *client = &fb_helper->client;
> +	struct drm_connector_list_iter conn_iter;
>  	struct fb_info *info = fb_helper->fbdev;
>  	unsigned int rotation, sw_rotations = 0;
> +	struct drm_connector *connector;
>  	struct drm_mode_set *modeset;
> -	int i;
>  
>  	mutex_lock(&client->modeset_mutex);
>  	drm_client_for_each_modeset(modeset, client) {
> @@ -2571,10 +2391,8 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper)
>  	}
>  	mutex_unlock(&client->modeset_mutex);
>  
> -	mutex_lock(&fb_helper->dev->mode_config.mutex);
Why is it OK to drop this lock?
In general I fail to see how the connector data is protected (locking
rules?) This is likely just me missing the bigger picture here..

> +	drm_connector_list_iter_end(&conn_iter);
>  
>  	switch (sw_rotations) {
>  	case DRM_MODE_ROTATE_0:

> diff --git a/include/drm/drm_client.h b/include/drm/drm_client.h
> index 6cf48419f77f..8d94880bbe25 100644
> --- a/include/drm/drm_client.h
> +++ b/include/drm/drm_client.h
> @@ -7,6 +7,7 @@
>  #include <linux/mutex.h>
>  #include <linux/types.h>
>  
> +#include <drm/drm_connector.h>
>  #include <drm/drm_crtc.h>
>  
>  struct drm_client_dev;
> @@ -169,6 +170,20 @@ int drm_client_modeset_dpms(struct drm_client_dev *client, int mode);
>  	for (({ lockdep_assert_held(&(client)->modeset_mutex); }), \
>  	     modeset = (client)->modesets; modeset->crtc; modeset++)
>  
> +/**
> + * drm_client_for_each_connector_iter - connector_list iterator macro
> + * @connector: &struct drm_connector pointer used as cursor
> + * @iter: &struct drm_connector_list_iter
> + *
> + * This iterates the connectors that are useable for internal clients (excludes
> + * writeback connectors).
> + *
> + * For more info see drm_for_each_connector_iter().
> + */
> +#define drm_client_for_each_connector_iter(connector, iter) \
> +	drm_for_each_connector_iter(connector, iter) \
> +		if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
> +
>  int drm_client_debugfs_init(struct drm_minor *minor);
>  
>  #endif
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index 6b334f4d8a22..e14d52ef9638 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -97,16 +97,10 @@ struct drm_fb_helper_funcs {
>  			struct drm_fb_helper_surface_size *sizes);
>  };
>  
> -struct drm_fb_helper_connector {
> -	struct drm_connector *connector;
> -};
> -
>  /**
>   * struct drm_fb_helper - main structure to emulate fbdev on top of KMS
>   * @fb: Scanout framebuffer object
>   * @dev: DRM device
> - * @connector_count: number of connected connectors
> - * @connector_info_alloc_count: size of connector_info
>   * @funcs: driver callbacks for fb helper
>   * @fbdev: emulated fbdev device info struct
>   * @pseudo_palette: fake palette of 16 colors
> @@ -138,15 +132,6 @@ struct drm_fb_helper {
>  
>  	struct drm_framebuffer *fb;
>  	struct drm_device *dev;
> -	int connector_count;
> -	int connector_info_alloc_count;
> -	/**
> -	 * @connector_info:
> -	 *
> -	 * Array of per-connector information. Do not iterate directly, but use
> -	 * drm_fb_helper_for_each_connector.
> -	 */
> -	struct drm_fb_helper_connector **connector_info;

As we are removing connector_info the comment for the @lock member
should be adjusted not to mention connector_info.


>  	const struct drm_fb_helper_funcs *funcs;
>  	struct fb_info *fbdev;
>  	u32 pseudo_palette[17];
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-05-16 13:07 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 18:01 [PATCH v5 00/11] drm/fb-helper: Move modesetting code to drm_client Noralf Trønnes
2019-05-06 18:01 ` [PATCH v5 01/11] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() Noralf Trønnes
2019-05-06 18:01 ` [PATCH v5 02/11] drm/fb-helper: Avoid race with DRM userspace Noralf Trønnes
2019-05-06 18:01 ` [PATCH v5 03/11] drm/fb-helper: No need to cache rotation and sw_rotations Noralf Trønnes
2019-05-06 18:01 ` [PATCH v5 04/11] drm/fb-helper: Remove drm_fb_helper_crtc->{x, y, desired_mode} Noralf Trønnes
2019-05-06 18:01 ` [PATCH v5 05/11] drm/fb-helper: Remove drm_fb_helper_crtc Noralf Trønnes
2019-05-15  9:04   ` Sam Ravnborg
2019-05-15 14:35     ` Familien Trønnes
2019-05-15 14:51     ` Noralf Trønnes
2019-05-15 15:01       ` Sam Ravnborg
2019-05-06 18:01 ` [PATCH v5 06/11] drm/fb-helper: Prepare to move out commit code Noralf Trønnes
2019-05-15  9:07   ` Sam Ravnborg
2019-05-06 18:01 ` [PATCH v5 07/11] drm/fb-helper: Move " Noralf Trønnes
2019-05-15  9:09   ` Sam Ravnborg
2019-05-15 14:40     ` Noralf Trønnes
2019-05-06 18:01 ` [PATCH v5 08/11] drm/fb-helper: Remove drm_fb_helper_connector Noralf Trønnes
2019-05-16 13:07   ` Sam Ravnborg [this message]
2019-05-16 13:53     ` Noralf Trønnes
2019-05-16 15:36       ` Sam Ravnborg
2019-05-06 18:01 ` [PATCH v5 09/11] drm/fb-helper: Prepare to move out modeset config code Noralf Trønnes
2019-05-15  9:14   ` Sam Ravnborg
2019-05-06 18:01 ` [PATCH v5 10/11] drm/fb-helper: Move " Noralf Trønnes
2019-05-16 15:38   ` Sam Ravnborg
2019-05-06 18:01 ` [PATCH v5 11/11] drm/client: Hack: Add bootsplash example Noralf Trønnes
2019-05-06 18:40 ` ✗ Fi.CI.CHECKPATCH: warning for drm/fb-helper: Move modesetting code to drm_client (rev6) Patchwork
2019-05-06 18:48 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-05-06 19:00 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-06 21:17 ` ✓ Fi.CI.IGT: " Patchwork
2019-05-14 14:29 ` [PATCH v5 00/11] drm/fb-helper: Move modesetting code to drm_client Noralf Trønnes
2019-05-16 15:44   ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190516130732.GA12435@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=noralf@tronnes.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox