dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Erik Faye-Lund <erik.faye-lund@collabora.com>
To: Boris Brezillon <boris.brezillon@collabora.com>,
	 dri-devel@lists.freedesktop.org
Cc: Daniel Stone <daniels@collabora.com>,
	Liviu Dudau <Liviu.Dudau@arm.com>,
	Steven Price <steven.price@arm.com>,
	Robin Murphy <robin.murphy@arm.com>,
	kernel@collabora.com, Chris Diamand	 <chris.diamand@foss.arm.com>,
	Ketil Johnsen <ketil.johnsen@arm.com>
Subject: Re: [PATCH v6 01/14] drm/panthor: Add uAPI
Date: Wed, 16 Oct 2024 15:50:55 +0200	[thread overview]
Message-ID: <1bd37b18455607b709529c8def963c4561e2ff1e.camel@collabora.com> (raw)
In-Reply-To: <64ff75ddede7623c16ed0272eef5e950ae34e7d5.camel@collabora.com>

On Wed, 2024-10-16 at 15:16 +0200, Erik Faye-Lund wrote:
> On Thu, 2024-02-29 at 17:22 +0100, Boris Brezillon wrote:
> > +/**
> > + * enum drm_panthor_sync_op_flags - Synchronization operation
> > flags.
> > + */
> > +enum drm_panthor_sync_op_flags {
> > +	/** @DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_MASK: Synchronization
> > handle type mask. */
> > +	DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_MASK = 0xff,
> > +
> > +	/** @DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_SYNCOBJ:
> > Synchronization object type. */
> > +	DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_SYNCOBJ = 0,
> > +
> > +	/**
> > +	 * @DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_TIMELINE_SYNCOBJ:
> > Timeline synchronization
> > +	 * object type.
> > +	 */
> > +	DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_TIMELINE_SYNCOBJ = 1,
> > +
> > +	/** @DRM_PANTHOR_SYNC_OP_WAIT: Wait operation. */
> > +	DRM_PANTHOR_SYNC_OP_WAIT = 0 << 31,
> > +
> > +	/** @DRM_PANTHOR_SYNC_OP_SIGNAL: Signal operation. */
> > +	DRM_PANTHOR_SYNC_OP_SIGNAL = (int)(1u << 31),
> 
> Why do we cast to int here? 1u << 31 doesn't fit in a 32-bit signed
> integer, so isn't this undefined behavior in C?
> 

Seems this was proposed here:
https://lore.kernel.org/dri-devel/89be8f8f-7c4e-4efd-0b7b-c30bcfbf1d23@arm.com/

...that kinda sounds like bad advice to me.

Also, it's been pointed out to me elsewhere that this isn't
*technically speaking* undefined, it's "implementation defined". But as
far as kernel interfaces goes, that's pretty much the same; we can't
guarantee that the kernel and the user-space is using the same
implementation.

Here's the quote from the C99 spec, section 6.3.1.3 "Signed and
unsigned integers":

"""
Otherwise, the new type is signed and the value cannot be represented
in it; either the result is implementation-defined or an
implementation-defined signal is raised
""""

I think a better approach be to use -1 << 31, which is well-defined.
But the problem then becomes assigning it into
drm_panthor_sync_op::flags in a well-defined way... Could we make the
field signed? That seems a bit bad as well...

  parent reply	other threads:[~2024-10-16 13:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 16:22 [PATCH v6 00/14] drm: Add a driver for CSF-based Mali GPUs Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 01/14] drm/panthor: Add uAPI Boris Brezillon
2024-10-16 13:16   ` Erik Faye-Lund
2024-10-16 13:47     ` Boris Brezillon
2024-10-16 14:07       ` Erik Faye-Lund
2024-10-16 13:50     ` Erik Faye-Lund [this message]
2024-10-16 14:02       ` Robin Murphy
2024-10-16 14:05         ` Erik Faye-Lund
2024-10-16 14:18           ` Boris Brezillon
2024-10-17  8:51             ` Erik Faye-Lund
2024-10-17 10:08               ` Boris Brezillon
2024-10-17 10:15                 ` Erik Faye-Lund
2024-10-17 18:34               ` Mihail Atanassov
2024-02-29 16:22 ` [PATCH v6 02/14] drm/panthor: Add GPU register definitions Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 03/14] drm/panthor: Add the device logical block Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 04/14] drm/panthor: Add the GPU " Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 05/14] drm/panthor: Add GEM " Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 06/14] drm/panthor: Add the devfreq " Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 07/14] drm/panthor: Add the MMU/VM " Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 08/14] drm/panthor: Add the FW " Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 09/14] drm/panthor: Add the heap " Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 10/14] drm/panthor: Add the scheduler " Boris Brezillon
2024-03-28 15:38   ` Nathan Chancellor
2024-03-28 15:51     ` Boris Brezillon
2024-09-03 19:43   ` Simona Vetter
2024-09-04  7:09     ` Boris Brezillon
2024-09-04  9:22       ` Simona Vetter
2024-09-04  8:45     ` Simona Vetter
2024-02-29 16:22 ` [PATCH v6 11/14] drm/panthor: Add the driver frontend block Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 12/14] drm/panthor: Allow driver compilation Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 13/14] dt-bindings: gpu: mali-valhall-csf: Add support for Arm Mali CSF GPUs Boris Brezillon
2024-02-29 16:22 ` [PATCH v6 14/14] drm/panthor: Add an entry to MAINTAINERS Boris Brezillon
2024-03-01  9:21 ` [PATCH v6 00/14] drm: Add a driver for CSF-based Mali GPUs Boris Brezillon

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=1bd37b18455607b709529c8def963c4561e2ff1e.camel@collabora.com \
    --to=erik.faye-lund@collabora.com \
    --cc=Liviu.Dudau@arm.com \
    --cc=boris.brezillon@collabora.com \
    --cc=chris.diamand@foss.arm.com \
    --cc=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=ketil.johnsen@arm.com \
    --cc=robin.murphy@arm.com \
    --cc=steven.price@arm.com \
    /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