* [PATCH v2 0/3] Use kvmalloc_array for radeon and amdgpu CS chunks
@ 2021-03-03 2:05 Chen Li
2021-03-03 2:06 ` [PATCH v2 1/3] drm/radeon: Use kvmalloc for " Chen Li
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Chen Li @ 2021-03-03 2:05 UTC (permalink / raw)
To: amd-gfx; +Cc: Alex Deucher, "Christian König"
When testing kernel with trinity, the kernel turned to tainted in that radeon CS require large memory and order is over MAX_ORDER.
kvmalloc/kvmalloc_array should be used here in that it will fallback to vmalloc if necessary.
Chen Li (3):
drm/radeon: Use kvmalloc for CS chunks
drm/amdgpu: Use kvmalloc for CS chunks
drm/amdgpu: correct DRM_ERROR for kvmalloc_array
Changelog:
v1->v2:
* also use kvmalloc in amdgpu
* fix a DRM_ERROR message for kvmalloc_array.
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++---
drivers/gpu/drm/radeon/radeon_cs.c | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
--
2.30.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/3] drm/radeon: Use kvmalloc for CS chunks
2021-03-03 2:05 [PATCH v2 0/3] Use kvmalloc_array for radeon and amdgpu CS chunks Chen Li
@ 2021-03-03 2:06 ` Chen Li
2021-03-03 2:07 ` [PATCH v2 2/3] drm/amdgpu: " Chen Li
2021-03-03 2:08 ` [PATCH v2 3/3] drm/amdgpu: correct DRM_ERROR for kvmalloc_array Chen Li
2 siblings, 0 replies; 6+ messages in thread
From: Chen Li @ 2021-03-03 2:06 UTC (permalink / raw)
To: amd-gfx; +Cc: Alex Deucher, "Christian König"
The number of chunks/chunks_array may be passed in
by userspace and can be large.
Signed-off-by: Chen Li <chenli@uniontech.com>
---
drivers/gpu/drm/radeon/radeon_cs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 35e937d39b51..fb736ef9f9aa 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -288,7 +288,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
p->chunk_relocs = NULL;
p->chunk_flags = NULL;
p->chunk_const_ib = NULL;
- p->chunks_array = kcalloc(cs->num_chunks, sizeof(uint64_t), GFP_KERNEL);
+ p->chunks_array = kvmalloc_array(cs->num_chunks, sizeof(uint64_t), GFP_KERNEL);
if (p->chunks_array == NULL) {
return -ENOMEM;
}
@@ -299,7 +299,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
}
p->cs_flags = 0;
p->nchunks = cs->num_chunks;
- p->chunks = kcalloc(p->nchunks, sizeof(struct radeon_cs_chunk), GFP_KERNEL);
+ p->chunks = kvmalloc_array(p->nchunks, sizeof(struct radeon_cs_chunk), GFP_KERNEL);
if (p->chunks == NULL) {
return -ENOMEM;
}
@@ -452,8 +452,8 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo
kvfree(parser->vm_bos);
for (i = 0; i < parser->nchunks; i++)
kvfree(parser->chunks[i].kdata);
- kfree(parser->chunks);
- kfree(parser->chunks_array);
+ kvfree(parser->chunks);
+ kvfree(parser->chunks_array);
radeon_ib_free(parser->rdev, &parser->ib);
radeon_ib_free(parser->rdev, &parser->const_ib);
}
--
2.30.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] drm/amdgpu: Use kvmalloc for CS chunks
2021-03-03 2:05 [PATCH v2 0/3] Use kvmalloc_array for radeon and amdgpu CS chunks Chen Li
2021-03-03 2:06 ` [PATCH v2 1/3] drm/radeon: Use kvmalloc for " Chen Li
@ 2021-03-03 2:07 ` Chen Li
2021-03-03 2:23 ` Alex Deucher
2021-03-03 2:08 ` [PATCH v2 3/3] drm/amdgpu: correct DRM_ERROR for kvmalloc_array Chen Li
2 siblings, 1 reply; 6+ messages in thread
From: Chen Li @ 2021-03-03 2:07 UTC (permalink / raw)
To: amd-gfx; +Cc: Alex Deucher, "Christian König"
The number of chunks/chunks_array may be passed in
by userspace and can be large.
Signed-off-by: Chen Li <chenli@uniontech.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 3e240b952e79..aefb7e68977d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -117,7 +117,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
if (cs->in.num_chunks == 0)
return 0;
- chunk_array = kmalloc_array(cs->in.num_chunks, sizeof(uint64_t), GFP_KERNEL);
+ chunk_array = kvmalloc_array(cs->in.num_chunks, sizeof(uint64_t), GFP_KERNEL);
if (!chunk_array)
return -ENOMEM;
@@ -144,7 +144,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
}
p->nchunks = cs->in.num_chunks;
- p->chunks = kmalloc_array(p->nchunks, sizeof(struct amdgpu_cs_chunk),
+ p->chunks = kvmalloc_array(p->nchunks, sizeof(struct amdgpu_cs_chunk),
GFP_KERNEL);
if (!p->chunks) {
ret = -ENOMEM;
--
2.30.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] drm/amdgpu: correct DRM_ERROR for kvmalloc_array
2021-03-03 2:05 [PATCH v2 0/3] Use kvmalloc_array for radeon and amdgpu CS chunks Chen Li
2021-03-03 2:06 ` [PATCH v2 1/3] drm/radeon: Use kvmalloc for " Chen Li
2021-03-03 2:07 ` [PATCH v2 2/3] drm/amdgpu: " Chen Li
@ 2021-03-03 2:08 ` Chen Li
2 siblings, 0 replies; 6+ messages in thread
From: Chen Li @ 2021-03-03 2:08 UTC (permalink / raw)
To: amd-gfx; +Cc: Alex Deucher, "Christian König"
This may avoid debug confusion.
Signed-off-by: Chen Li <chenli@uniontech.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index aefb7e68977d..a1df980864a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -559,7 +559,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
sizeof(struct page *),
GFP_KERNEL | __GFP_ZERO);
if (!e->user_pages) {
- DRM_ERROR("calloc failure\n");
+ DRM_ERROR("kvmalloc_array failure\n");
return -ENOMEM;
}
--
2.30.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] drm/amdgpu: Use kvmalloc for CS chunks
2021-03-03 2:07 ` [PATCH v2 2/3] drm/amdgpu: " Chen Li
@ 2021-03-03 2:23 ` Alex Deucher
2021-03-03 3:14 ` [PATCH v2 2/3] drm/amdgpu: Use kvmalloc for CS chunks【Suspected phishing email, please pay attention to password security】 Chen Li
0 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2021-03-03 2:23 UTC (permalink / raw)
To: Chen Li; +Cc: Alex Deucher, Christian König, amd-gfx list
On Tue, Mar 2, 2021 at 9:16 PM Chen Li <chenli@uniontech.com> wrote:
>
>
> The number of chunks/chunks_array may be passed in
> by userspace and can be large.
>
We also need to kvfree these.
Alex
> Signed-off-by: Chen Li <chenli@uniontech.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 3e240b952e79..aefb7e68977d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -117,7 +117,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
> if (cs->in.num_chunks == 0)
> return 0;
>
> - chunk_array = kmalloc_array(cs->in.num_chunks, sizeof(uint64_t), GFP_KERNEL);
> + chunk_array = kvmalloc_array(cs->in.num_chunks, sizeof(uint64_t), GFP_KERNEL);
> if (!chunk_array)
> return -ENOMEM;
>
> @@ -144,7 +144,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
> }
>
> p->nchunks = cs->in.num_chunks;
> - p->chunks = kmalloc_array(p->nchunks, sizeof(struct amdgpu_cs_chunk),
> + p->chunks = kvmalloc_array(p->nchunks, sizeof(struct amdgpu_cs_chunk),
> GFP_KERNEL);
> if (!p->chunks) {
> ret = -ENOMEM;
> --
> 2.30.0
>
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] drm/amdgpu: Use kvmalloc for CS chunks【Suspected phishing email, please pay attention to password security】
2021-03-03 2:23 ` Alex Deucher
@ 2021-03-03 3:14 ` Chen Li
0 siblings, 0 replies; 6+ messages in thread
From: Chen Li @ 2021-03-03 3:14 UTC (permalink / raw)
To: Alex Deucher; +Cc: Christian König, amd-gfx list
On Wed, 03 Mar 2021 10:23:01 +0800,
Alex Deucher wrote:
>
> On Tue, Mar 2, 2021 at 9:16 PM Chen Li <chenli@uniontech.com> wrote:
> >
> >
> > The number of chunks/chunks_array may be passed in
> > by userspace and can be large.
> >
>
> We also need to kvfree these.
Thanks for pointing out this! I will a add it in v3.
>
> Alex
>
> > Signed-off-by: Chen Li <chenli@uniontech.com>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > index 3e240b952e79..aefb7e68977d 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > @@ -117,7 +117,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
> > if (cs->in.num_chunks == 0)
> > return 0;
> >
> > - chunk_array = kmalloc_array(cs->in.num_chunks, sizeof(uint64_t), GFP_KERNEL);
> > + chunk_array = kvmalloc_array(cs->in.num_chunks, sizeof(uint64_t), GFP_KERNEL);
> > if (!chunk_array)
> > return -ENOMEM;
> >
> > @@ -144,7 +144,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
> > }
> >
> > p->nchunks = cs->in.num_chunks;
> > - p->chunks = kmalloc_array(p->nchunks, sizeof(struct amdgpu_cs_chunk),
> > + p->chunks = kvmalloc_array(p->nchunks, sizeof(struct amdgpu_cs_chunk),
> > GFP_KERNEL);
> > if (!p->chunks) {
> > ret = -ENOMEM;
> > --
> > 2.30.0
> >
> >
> >
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-03-03 3:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 2:05 [PATCH v2 0/3] Use kvmalloc_array for radeon and amdgpu CS chunks Chen Li
2021-03-03 2:06 ` [PATCH v2 1/3] drm/radeon: Use kvmalloc for " Chen Li
2021-03-03 2:07 ` [PATCH v2 2/3] drm/amdgpu: " Chen Li
2021-03-03 2:23 ` Alex Deucher
2021-03-03 3:14 ` [PATCH v2 2/3] drm/amdgpu: Use kvmalloc for CS chunks【Suspected phishing email, please pay attention to password security】 Chen Li
2021-03-03 2:08 ` [PATCH v2 3/3] drm/amdgpu: correct DRM_ERROR for kvmalloc_array Chen Li
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.