From: Sui Jingfeng <sui.jingfeng@linux.dev>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Sui Jingfeng <sui.jingfeng@linux.dev>
Subject: [PATCH] drm/prime: drm_prime_sg_to_dma_addr_array(): Return -EINVAL on error
Date: Thu, 31 Oct 2024 22:07:30 +0800 [thread overview]
Message-ID: <20241031140730.2406181-1-sui.jingfeng@linux.dev> (raw)
'-EINVAL' stands for invalid argument, while '-1' will accidently be
interpreted as '-EPERM' by the potential upper caller. Which does not
describe the error case accurately, since such an error can happens when
the caller pass a smaller number than actually needed size to describe
the array passed-in. Such an error is invalid argument.
Take drm/vmwgfx driver as an example, the function call trace is:
|- ttm_bo_vmap()
|-- ttm_tt_populate()
|--- bdev->funcs->ttm_tt_populate()
|----- vmw_ttm_populate()
|------ drm_prime_sg_to_dma_addr_array()
While ttm_bo_vmap() requires its callees return '-EINVAL' on invalid range,
similier for other users or call path. Let's meet the requirement.
Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
---
drivers/gpu/drm/drm_prime.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 0e3f8adf162f..3f1d516a90b6 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -1055,7 +1055,7 @@ int drm_prime_sg_to_dma_addr_array(struct sg_table *sgt, dma_addr_t *addrs,
for_each_sgtable_dma_page(sgt, &dma_iter, 0) {
if (WARN_ON(a - addrs >= max_entries))
- return -1;
+ return -EINVAL;
*a++ = sg_page_iter_dma_address(&dma_iter);
}
return 0;
--
2.34.1
reply other threads:[~2024-10-31 14:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20241031140730.2406181-1-sui.jingfeng@linux.dev \
--to=sui.jingfeng@linux.dev \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®