public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: dri-devel@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
	open list <linux-kernel@vger.kernel.org>,
	Sean Paul <sean@poorly.run>
Subject: Re: [PATCH v2] drm: refuse ADDFB2 ioctl for broken bigendian drivers
Date: Fri, 7 Sep 2018 21:47:39 +0200	[thread overview]
Message-ID: <20180907194739.GD7176@phenom.ffwll.local> (raw)
In-Reply-To: <20180907073213.20410-1-kraxel@redhat.com>

On Fri, Sep 07, 2018 at 09:32:13AM +0200, Gerd Hoffmann wrote:
> Drivers must set the quirk_addfb_prefer_host_byte_order quirk to make
> the drm_mode_addfb() compat code work correctly on bigendian machines.
> 
> If they don't they interpret pixel_format values incorrectly for bug
> compatibility, which in turn implies the ADDFB2 ioctl does not work
> correctly then.  So block it to make userspace fallback to ADDFB.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_crtc_internal.h |  6 ++++--
>  drivers/gpu/drm/drm_framebuffer.c   | 24 ++++++++++++++++++++++++
>  drivers/gpu/drm/drm_ioctl.c         |  2 +-
>  3 files changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index b613227633..6719e1c8df 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -174,6 +174,8 @@ void drm_fb_release(struct drm_file *file_priv);
>  
>  int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
>  		   struct drm_file *file_priv);
> +int drm_mode_addfb2(struct drm_device *dev,
> +		    void *data, struct drm_file *file_priv);
>  int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
>  		  struct drm_file *file_priv);
>  
> @@ -181,8 +183,8 @@ int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
>  /* IOCTL */
>  int drm_mode_addfb_ioctl(struct drm_device *dev,
>  			 void *data, struct drm_file *file_priv);
> -int drm_mode_addfb2(struct drm_device *dev,
> -		    void *data, struct drm_file *file_priv);
> +int drm_mode_addfb2_ioctl(struct drm_device *dev,
> +			  void *data, struct drm_file *file_priv);
>  int drm_mode_rmfb_ioctl(struct drm_device *dev,
>  			void *data, struct drm_file *file_priv);
>  int drm_mode_getfb(struct drm_device *dev,
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index f863f8a20f..fb7528444c 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -363,6 +363,30 @@ int drm_mode_addfb2(struct drm_device *dev,
>  	return 0;
>  }
>  
> +int drm_mode_addfb2_ioctl(struct drm_device *dev,
> +			  void *data, struct drm_file *file_priv)
> +{
> +#ifdef __BIG_ENDIAN
> +	if (!dev->mode_config.quirk_addfb_prefer_host_byte_order) {
> +		/*
> +		 * Drivers must set the
> +		 * quirk_addfb_prefer_host_byte_order quirk to make
> +		 * the drm_mode_addfb() compat code work correctly on
> +		 * bigendian machines.
> +		 *
> +		 * If they don't they interpret pixel_format values
> +		 * incorrectly for bug compatibility, which in turn
> +		 * implies the ADDFB2 ioctl does not work correctly
> +		 * then.  So block it to make userspace fallback to
> +		 * ADDFB.
> +		 */
> +		DRM_DEBUG_KMS("addfb2 broken on bigendian");
> +		return -EINVAL;
> +	}
> +#endif
> +	return drm_mode_addfb2(dev, data, file_priv);
> +}
> +
>  struct drm_mode_rmfb_work {
>  	struct work_struct work;
>  	struct list_head fbs;
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index ea10e9a26a..6b4a633b42 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -645,7 +645,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb_ioctl, DRM_UNLOCKED),
> -	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2, DRM_UNLOCKED),
> +	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2_ioctl, DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb_ioctl, DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_PAGE_FLIP, drm_mode_page_flip_ioctl, DRM_MASTER|DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER|DRM_UNLOCKED),
> -- 
> 2.9.3
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2018-09-07 19:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07  7:32 [PATCH v2] drm: refuse ADDFB2 ioctl for broken bigendian drivers Gerd Hoffmann
2018-09-07 19:47 ` Daniel Vetter [this message]
2018-09-10  8:32 ` kbuild test robot

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=20180907194739.GD7176@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sean@poorly.run \
    /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