Skip to contentSkip to conversation

drm: use ATOMIC64_INIT() for atomic64_t

PATCH In review Jonathan Gray 2 participants 4 messages Jan 11, 2024 – Nov 5, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: use ATOMIC64_INIT() for atomic64_t

use ATOMIC64_INIT() not ATOMIC_INIT() for atomic64_t

Fixes 3f09a0cd4ea3 ("drm: Add common fdinfo helper")
---
 drivers/gpu/drm/drm_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_file.c +1 -1
index 446458aca8e9..d3b10dd91584 100644
@@ -149,7 +149,7 @@ bool drm_dev_needs_global_mutex(struct drm_device *dev)
  */
 struct drm_file *drm_file_alloc(struct drm_minor *minor)
 {
-	static atomic64_t ident = ATOMIC_INIT(0);
+	static atomic64_t ident = ATOMIC64_INIT(0);
 	struct drm_device *dev = minor->dev;
 	struct drm_file *file;
 	int ret;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jonathan Gray

use ATOMIC64_INIT() not ATOMIC_INIT() for atomic64_t

Fixes 3f09a0cd4ea3 ("drm: Add common fdinfo helper")
Quoted 9 lines
---
 drivers/gpu/drm/drm_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_file.c +0 -0
index 446458aca8e9..d3b10dd91584 100644

drivers/gpu/drm/drm_file.c bool drm_dev_needs_global_mutex(struct drm_device *dev) · line 152

Quoted 5 lines
drivers/gpu/drm/drm_file.c +1 -1
@@ -149,7 +149,7 @@ bool drm_dev_needs_global_mutex(struct drm_device *dev)
  */
 struct drm_file *drm_file_alloc(struct drm_minor *minor)
 {
-	static atomic64_t ident = ATOMIC_INIT(0);
+	static atomic64_t ident = ATOMIC64_INIT(0);

I think we should probably redefine both ATOMIC_INIT and ATOMIC64_INIT to cast the result to the correct type to avoid this problem once and for all.

If we had

#define ATOMIC_INIT(i) (atomic_t){ (i) }

and

#define ATOMIC64_INIT(i) (atomic64_t){ (i) }

we'd get a build failure using them incorrectly.

BR,
Jani.

Quoted 3 lines
drivers/gpu/drm/drm_file.c +0 -0
 	struct drm_device *dev = minor->dev;
 	struct drm_file *file;
 	int ret;
Signature · 1 line
Jani Nikula, Intel
#2 lore raw
Quoted 7 lines · Jani Nikula
Quoted 4 lines · Jonathan Gray

use ATOMIC64_INIT() not ATOMIC_INIT() for atomic64_t

Fixes 3f09a0cd4ea3 ("drm: Add common fdinfo helper")

This patch didn't get merged. Should I resend it?

Quoted 41 lines
Quoted 10 lines
---
 drivers/gpu/drm/drm_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_file.c +0 -0
index 446458aca8e9..d3b10dd91584 100644

drivers/gpu/drm/drm_file.c bool drm_dev_needs_global_mutex(struct drm_device *dev) · line 152

Quoted 5 lines
drivers/gpu/drm/drm_file.c +1 -1
@@ -149,7 +149,7 @@ bool drm_dev_needs_global_mutex(struct drm_device *dev)
  */
 struct drm_file *drm_file_alloc(struct drm_minor *minor)
 {
-	static atomic64_t ident = ATOMIC_INIT(0);
+	static atomic64_t ident = ATOMIC64_INIT(0);

I think we should probably redefine both ATOMIC_INIT and ATOMIC64_INIT to cast the result to the correct type to avoid this problem once and for all.

If we had

#define ATOMIC_INIT(i) (atomic_t){ (i) }

and

#define ATOMIC64_INIT(i) (atomic64_t){ (i) }

we'd get a build failure using them incorrectly.

BR,
Jani.

Quoted 3 lines
drivers/gpu/drm/drm_file.c +0 -0
 	struct drm_device *dev = minor->dev;
 	struct drm_file *file;
 	int ret;
Signature · 1 line
Jani Nikula, Intel
#3 lore raw
Quoted 10 lines · Jonathan Gray
Quoted 7 lines · Jani Nikula
Quoted 4 lines · Jonathan Gray

use ATOMIC64_INIT() not ATOMIC_INIT() for atomic64_t

Fixes 3f09a0cd4ea3 ("drm: Add common fdinfo helper")

This patch didn't get merged. Should I resend it?

Apologies, it fell between the cracks. Pushed to drm-misc-next now, thanks for the patch.

BR,
Jani.

Signature · 1 line
Jani Nikula, Intel