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] drm: refuse ADDFB2 ioctl for broken bigendian drivers
Date: Thu, 6 Sep 2018 09:32:36 +0200 [thread overview]
Message-ID: <20180906073236.GL4929@phenom.ffwll.local> (raw)
In-Reply-To: <20180906072850.11150-1-kraxel@redhat.com>
On Thu, Sep 06, 2018 at 09:28:50AM +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>
> ---
> drivers/gpu/drm/drm_ioctl.c | 25 ++++++++++++++++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index ea10e9a26a..08e48bda23 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -469,6 +469,29 @@ static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
> return 0;
> }
>
> +static int drm_mode_addfb2_check(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 would be good here I think, just to help userspace people
figure out why they got an -EINVAL.
> + return -EINVAL;
> + }
> +#endif
> + return drm_mode_addfb2(dev, data, file_priv);
I think it'd be better if we have all the addfb code in drm_framebuffer.c.
So leave the function name, and extract the common code into
__drm_mode_addfb2 helper.
With these two nits addressed:
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> +}
> +
> /*
> * Get version information
> *
> @@ -645,7 +668,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_check, 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
prev parent reply other threads:[~2018-09-06 7:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-06 7:28 Gerd Hoffmann
2018-09-06 7:32 ` Daniel Vetter [this message]
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=20180906073236.GL4929@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
Powered by JetHome