Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90844f00 authored by Eric Engestrom's avatar Eric Engestrom Committed by Daniel Vetter
Browse files

drm: make drm_get_format_name thread-safe



Signed-off-by: default avatarEric Engestrom <eric@engestrom.ch>
[danvet: Clarify that the returned pointer must be freed with
kfree().]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent fc93ff60
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -2071,6 +2071,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
	u32 tmp, viewport_w, viewport_h;
	u32 tmp, viewport_w, viewport_h;
	int r;
	int r;
	bool bypass_lut = false;
	bool bypass_lut = false;
	const char *format_name;


	/* no fb bound */
	/* no fb bound */
	if (!atomic && !crtc->primary->fb) {
	if (!atomic && !crtc->primary->fb) {
@@ -2182,8 +2183,9 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
		bypass_lut = true;
		bypass_lut = true;
		break;
		break;
	default:
	default:
		DRM_ERROR("Unsupported screen format %s\n",
		format_name = drm_get_format_name(target_fb->pixel_format);
			drm_get_format_name(target_fb->pixel_format));
		DRM_ERROR("Unsupported screen format %s\n", format_name);
		kfree(format_name);
		return -EINVAL;
		return -EINVAL;
	}
	}


+4 −2
Original line number Original line Diff line number Diff line
@@ -2046,6 +2046,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
	u32 tmp, viewport_w, viewport_h;
	u32 tmp, viewport_w, viewport_h;
	int r;
	int r;
	bool bypass_lut = false;
	bool bypass_lut = false;
	const char *format_name;


	/* no fb bound */
	/* no fb bound */
	if (!atomic && !crtc->primary->fb) {
	if (!atomic && !crtc->primary->fb) {
@@ -2157,8 +2158,9 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
		bypass_lut = true;
		bypass_lut = true;
		break;
		break;
	default:
	default:
		DRM_ERROR("Unsupported screen format %s\n",
		format_name = drm_get_format_name(target_fb->pixel_format);
			drm_get_format_name(target_fb->pixel_format));
		DRM_ERROR("Unsupported screen format %s\n", format_name);
		kfree(format_name);
		return -EINVAL;
		return -EINVAL;
	}
	}


+4 −2
Original line number Original line Diff line number Diff line
@@ -1952,6 +1952,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
	u32 viewport_w, viewport_h;
	u32 viewport_w, viewport_h;
	int r;
	int r;
	bool bypass_lut = false;
	bool bypass_lut = false;
	const char *format_name;


	/* no fb bound */
	/* no fb bound */
	if (!atomic && !crtc->primary->fb) {
	if (!atomic && !crtc->primary->fb) {
@@ -2056,8 +2057,9 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
		bypass_lut = true;
		bypass_lut = true;
		break;
		break;
	default:
	default:
		DRM_ERROR("Unsupported screen format %s\n",
		format_name = drm_get_format_name(target_fb->pixel_format);
			  drm_get_format_name(target_fb->pixel_format));
		DRM_ERROR("Unsupported screen format %s\n", format_name);
		kfree(format_name);
		return -EINVAL;
		return -EINVAL;
	}
	}


+3 −2
Original line number Original line Diff line number Diff line
@@ -837,8 +837,9 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
	/* Check whether this plane supports the fb pixel format. */
	/* Check whether this plane supports the fb pixel format. */
	ret = drm_plane_check_pixel_format(plane, state->fb->pixel_format);
	ret = drm_plane_check_pixel_format(plane, state->fb->pixel_format);
	if (ret) {
	if (ret) {
		DRM_DEBUG_ATOMIC("Invalid pixel format %s\n",
		const char *format_name = drm_get_format_name(state->fb->pixel_format);
				 drm_get_format_name(state->fb->pixel_format));
		DRM_DEBUG_ATOMIC("Invalid pixel format %s\n", format_name);
		kfree(format_name);
		return ret;
		return ret;
	}
	}


+13 −8
Original line number Original line Diff line number Diff line
@@ -2592,8 +2592,9 @@ static int __setplane_internal(struct drm_plane *plane,
	/* Check whether this plane supports the fb pixel format. */
	/* Check whether this plane supports the fb pixel format. */
	ret = drm_plane_check_pixel_format(plane, fb->pixel_format);
	ret = drm_plane_check_pixel_format(plane, fb->pixel_format);
	if (ret) {
	if (ret) {
		DRM_DEBUG_KMS("Invalid pixel format %s\n",
		const char *format_name = drm_get_format_name(fb->pixel_format);
			      drm_get_format_name(fb->pixel_format));
		DRM_DEBUG_KMS("Invalid pixel format %s\n", format_name);
		kfree(format_name);
		goto out;
		goto out;
	}
	}


@@ -2902,8 +2903,9 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
			ret = drm_plane_check_pixel_format(crtc->primary,
			ret = drm_plane_check_pixel_format(crtc->primary,
							   fb->pixel_format);
							   fb->pixel_format);
			if (ret) {
			if (ret) {
				DRM_DEBUG_KMS("Invalid pixel format %s\n",
				const char *format_name = drm_get_format_name(fb->pixel_format);
					drm_get_format_name(fb->pixel_format));
				DRM_DEBUG_KMS("Invalid pixel format %s\n", format_name);
				kfree(format_name);
				goto out;
				goto out;
			}
			}
		}
		}
@@ -3279,6 +3281,7 @@ int drm_mode_addfb(struct drm_device *dev,
static int format_check(const struct drm_mode_fb_cmd2 *r)
static int format_check(const struct drm_mode_fb_cmd2 *r)
{
{
	uint32_t format = r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN;
	uint32_t format = r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN;
	const char *format_name;


	switch (format) {
	switch (format) {
	case DRM_FORMAT_C8:
	case DRM_FORMAT_C8:
@@ -3343,8 +3346,9 @@ static int format_check(const struct drm_mode_fb_cmd2 *r)
	case DRM_FORMAT_YVU444:
	case DRM_FORMAT_YVU444:
		return 0;
		return 0;
	default:
	default:
		DRM_DEBUG_KMS("invalid pixel format %s\n",
		format_name = drm_get_format_name(r->pixel_format);
			      drm_get_format_name(r->pixel_format));
		DRM_DEBUG_KMS("invalid pixel format %s\n", format_name);
		kfree(format_name);
		return -EINVAL;
		return -EINVAL;
	}
	}
}
}
@@ -3355,8 +3359,9 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)


	ret = format_check(r);
	ret = format_check(r);
	if (ret) {
	if (ret) {
		DRM_DEBUG_KMS("bad framebuffer format %s\n",
		const char *format_name = drm_get_format_name(r->pixel_format);
			      drm_get_format_name(r->pixel_format));
		DRM_DEBUG_KMS("bad framebuffer format %s\n", format_name);
		kfree(format_name);
		return ret;
		return ret;
	}
	}


Loading