Commit 55eba86e authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

drm/msm: Test for imported buffers with drm_gem_is_imported()



Instead of testing import_attach for imported GEM buffers, invoke
drm_gem_is_imported() to do the test. The helper tests the dma_buf
itself while import_attach is just an artifact of the import. Prepares
to make import_attach optional.

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Dmitry Baryshkov <lumag@kernel.org>
Cc: Sean Paul <sean@poorly.run>
Cc: Marijn Suijten <marijn.suijten@somainline.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Acked-by: default avatarDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250317131923.238374-7-tzimmermann@suse.de
parent e91eb3ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -671,7 +671,7 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
		ret = msm_ioctl_gem_info_set_iova(dev, file, obj, args->value);
		break;
	case MSM_INFO_GET_FLAGS:
		if (obj->import_attach) {
		if (drm_gem_is_imported(obj)) {
			ret = -EINVAL;
			break;
		}
+2 −2
Original line number Diff line number Diff line
@@ -735,7 +735,7 @@ static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)

	msm_gem_assert_locked(obj);

	if (obj->import_attach)
	if (drm_gem_is_imported(obj))
		return ERR_PTR(-ENODEV);

	pages = msm_gem_get_pages_locked(obj, madv);
@@ -1074,7 +1074,7 @@ static void msm_gem_free_object(struct drm_gem_object *obj)

	put_iova_spaces(obj, true);

	if (obj->import_attach) {
	if (drm_gem_is_imported(obj)) {
		GEM_WARN_ON(msm_obj->vaddr);

		/* Don't drop the pages for imported dmabuf, as they are not
+1 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ msm_gem_assert_locked(struct drm_gem_object *obj)
/* imported/exported objects are not purgeable: */
static inline bool is_unpurgeable(struct msm_gem_object *msm_obj)
{
	return msm_obj->base.import_attach || msm_obj->pin_count;
	return drm_gem_is_imported(&msm_obj->base) || msm_obj->pin_count;
}

static inline bool is_purgeable(struct msm_gem_object *msm_obj)
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ int msm_gem_prime_pin(struct drm_gem_object *obj)
	struct page **pages;
	int ret = 0;

	if (obj->import_attach)
	if (drm_gem_is_imported(obj))
		return 0;

	pages = msm_gem_pin_pages_locked(obj);
@@ -62,7 +62,7 @@ int msm_gem_prime_pin(struct drm_gem_object *obj)

void msm_gem_prime_unpin(struct drm_gem_object *obj)
{
	if (obj->import_attach)
	if (drm_gem_is_imported(obj))
		return;

	msm_gem_unpin_pages_locked(obj);