All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 4/5] drm/tegra: gem: Correct iommu_map_sg() error checking
Date: Wed, 20 Dec 2017 18:46:13 +0300	[thread overview]
Message-ID: <1daf8bfe7c4ef37a4d5d6d5f87eae36425a3df14.1513783739.git.digetx@gmail.com> (raw)
In-Reply-To: <cover.1513783738.git.digetx@gmail.com>
In-Reply-To: <cover.1513783738.git.digetx@gmail.com>

iommu_map_sg() doesn't return a error value, but a size of the requested
IOMMU mapping or zero in case of error.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/gpu/drm/tegra/gem.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index ab1e53d434e8..49b9bf28f872 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -114,7 +114,7 @@ static const struct host1x_bo_ops tegra_bo_ops = {
 static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
 {
 	int prot = IOMMU_READ | IOMMU_WRITE;
-	ssize_t err;
+	int err;
 
 	if (bo->mm)
 		return -EBUSY;
@@ -128,22 +128,21 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
 	err = drm_mm_insert_node_generic(&tegra->mm,
 					 bo->mm, bo->gem.size, PAGE_SIZE, 0, 0);
 	if (err < 0) {
-		dev_err(tegra->drm->dev, "out of I/O virtual memory: %zd\n",
+		dev_err(tegra->drm->dev, "out of I/O virtual memory: %d\n",
 			err);
 		goto unlock;
 	}
 
 	bo->paddr = bo->mm->start;
 
-	err = iommu_map_sg(tegra->domain, bo->paddr, bo->sgt->sgl,
-			   bo->sgt->nents, prot);
-	if (err < 0) {
-		dev_err(tegra->drm->dev, "failed to map buffer: %zd\n", err);
+	bo->size = iommu_map_sg(tegra->domain, bo->paddr, bo->sgt->sgl,
+				bo->sgt->nents, prot);
+	if (!bo->size) {
+		dev_err(tegra->drm->dev, "failed to map buffer\n");
+		err = -ENOMEM;
 		goto remove;
 	}
 
-	bo->size = err;
-
 	mutex_unlock(&tegra->mm_lock);
 
 	return 0;
-- 
2.15.1

  parent reply	other threads:[~2017-12-20 15:46 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 15:46 [PATCH v3 0/5] Some corrections and improvement for Tegra DRM Dmitry Osipenko
2017-12-20 15:46 ` Dmitry Osipenko
2017-12-20 15:46 ` [PATCH v3 1/5] drm/tegra: dc: Link DC1 to DC0 on Tegra20 Dmitry Osipenko
2017-12-20 20:17   ` Thierry Reding
2017-12-20 20:17     ` Thierry Reding
     [not found] ` <cover.1513783738.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-20 15:46   ` [PATCH v3 2/5] drm/tegra: Restore opaque and drop alpha formats on Tegra20/30 Dmitry Osipenko
2017-12-20 15:46     ` Dmitry Osipenko
     [not found]     ` <0476e28d70b47ec599fb65d1cfa457276629de27.1513783738.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-20 18:01       ` Thierry Reding
2017-12-20 18:01         ` Thierry Reding
2017-12-20 20:01         ` Dmitry Osipenko
2017-12-20 20:01           ` Dmitry Osipenko
     [not found]           ` <3924358d-ae3b-78a4-1227-164435add8d1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-20 20:16             ` Thierry Reding
2017-12-20 20:16               ` Thierry Reding
2017-12-20 21:05               ` Dmitry Osipenko
2017-12-20 21:05                 ` Dmitry Osipenko
2017-12-20 22:02                 ` Thierry Reding
2017-12-20 22:02                   ` Thierry Reding
2017-12-20 22:23                   ` Dmitry Osipenko
2017-12-20 22:23                     ` Dmitry Osipenko
     [not found]                     ` <2c52becd-f20e-599b-c421-bf4b18dda6bf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-20 22:38                       ` Dmitry Osipenko
2017-12-20 22:38                         ` Dmitry Osipenko
     [not found]                         ` <a6644fc8-9c22-4b6b-1fec-82a7636bda65-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-21 14:10                           ` Thierry Reding
2017-12-21 14:10                             ` Thierry Reding
2017-12-21 14:38                             ` Dmitry Osipenko
2017-12-21 14:38                               ` Dmitry Osipenko
2017-12-20 15:46   ` [PATCH v3 3/5] drm/tegra: Trade overlay plane for cursor on older Tegra's Dmitry Osipenko
2017-12-20 15:46     ` Dmitry Osipenko
     [not found]     ` <fd0034ee935cc17915f4189ee65865c974f34d98.1513783739.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-20 20:19       ` Thierry Reding
2017-12-20 20:19         ` Thierry Reding
2017-12-20 20:28         ` Dmitry Osipenko
2017-12-20 20:28           ` Dmitry Osipenko
2017-12-20 15:46 ` Dmitry Osipenko [this message]
     [not found]   ` <1daf8bfe7c4ef37a4d5d6d5f87eae36425a3df14.1513783739.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-20 20:17     ` [PATCH v3 4/5] drm/tegra: gem: Correct iommu_map_sg() error checking Thierry Reding
2017-12-20 20:17       ` Thierry Reding
2017-12-20 15:46 ` [PATCH v3 5/5] drm/tegra: Correct timeout in tegra_syncpt_wait Dmitry Osipenko
2017-12-20 20:17   ` Thierry Reding
2017-12-20 20:17     ` Thierry Reding

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=1daf8bfe7c4ef37a4d5d6d5f87eae36425a3df14.1513783739.git.digetx@gmail.com \
    --to=digetx@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.