* [PATCH] drm/msm/a6xx: Fix missing ARRAY_SIZE() check
@ 2022-03-05 17:34 Rob Clark
2022-03-07 15:03 ` Akhil P Oommen
0 siblings, 1 reply; 6+ messages in thread
From: Rob Clark @ 2022-03-05 17:34 UTC (permalink / raw)
To: dri-devel
Cc: freedreno, linux-arm-msm, Rob Clark, Dmitry Baryshkov, Rob Clark,
Sean Paul, Abhinav Kumar, David Airlie, Daniel Vetter,
Akhil P Oommen, Jonathan Marek, Jordan Crouse, open list
From: Rob Clark <robdclark@chromium.org>
Fixes: f6d62d091cfd ("drm/msm/a6xx: add support for Adreno 660 GPU")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 02b47977b5c3..83c31b2ad865 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -683,19 +683,23 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
{
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
const u32 *regs = a6xx_protect;
- unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32;
-
- BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
- BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
+ unsigned i, count, count_max;
if (adreno_is_a650(adreno_gpu)) {
regs = a650_protect;
count = ARRAY_SIZE(a650_protect);
count_max = 48;
+ BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
} else if (adreno_is_a660_family(adreno_gpu)) {
regs = a660_protect;
count = ARRAY_SIZE(a660_protect);
count_max = 48;
+ BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
+ } else {
+ regs = a6xx_protect;
+ count = ARRAY_SIZE(a6xx_protect);
+ count_max = 32;
+ BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
}
/*
--
2.35.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/msm/a6xx: Fix missing ARRAY_SIZE() check
2022-03-05 17:34 [PATCH] drm/msm/a6xx: Fix missing ARRAY_SIZE() check Rob Clark
@ 2022-03-07 15:03 ` Akhil P Oommen
0 siblings, 0 replies; 6+ messages in thread
From: Akhil P Oommen @ 2022-03-07 15:03 UTC (permalink / raw)
To: Rob Clark, dri-devel
Cc: freedreno, linux-arm-msm, Rob Clark, Dmitry Baryshkov, Sean Paul,
Abhinav Kumar, David Airlie, Daniel Vetter, Jonathan Marek,
Jordan Crouse, open list
On 3/5/2022 11:04 PM, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
>
> Fixes: f6d62d091cfd ("drm/msm/a6xx: add support for Adreno 660 GPU")
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 02b47977b5c3..83c31b2ad865 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -683,19 +683,23 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
> {
> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
> const u32 *regs = a6xx_protect;
> - unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32;
> -
> - BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
> - BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
> + unsigned i, count, count_max;
>
> if (adreno_is_a650(adreno_gpu)) {
> regs = a650_protect;
> count = ARRAY_SIZE(a650_protect);
> count_max = 48;
> + BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
> } else if (adreno_is_a660_family(adreno_gpu)) {
> regs = a660_protect;
> count = ARRAY_SIZE(a660_protect);
> count_max = 48;
> + BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
> + } else {
> + regs = a6xx_protect;
> + count = ARRAY_SIZE(a6xx_protect);
> + count_max = 32;
> + BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
> }
>
> /*
Reviewed-by: Akhil P Oommen <quic_akhilpo@quicinc.com>
-Akhil.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/msm/a6xx: Fix missing ARRAY_SIZE() check
2022-03-04 21:58 ` Rob Clark
@ 2022-03-05 10:37 ` Dmitry Baryshkov
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2022-03-05 10:37 UTC (permalink / raw)
To: Rob Clark
Cc: dri-devel, freedreno, linux-arm-msm, Rob Clark, Sean Paul,
Abhinav Kumar, David Airlie, Daniel Vetter, Akhil P Oommen,
Jonathan Marek, Jordan Crouse, open list
On Sat, 5 Mar 2022 at 00:57, Rob Clark <robdclark@gmail.com> wrote:
>
> On Fri, Mar 4, 2022 at 1:47 PM Dmitry Baryshkov
> <dmitry.baryshkov@linaro.org> wrote:
> >
> > On Fri, 4 Mar 2022 at 23:23, Rob Clark <robdclark@gmail.com> wrote:
> > >
> > > From: Rob Clark <robdclark@chromium.org>
> > >
> > > Fixes: f6d62d091cfd ("drm/msm/a6xx: add support for Adreno 660 GPU")
> > > Signed-off-by: Rob Clark <robdclark@chromium.org>
> >
> > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > However see the comment below.
> >
> > > ---
> > > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > index 02b47977b5c3..6406d8c3411a 100644
> > > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > @@ -687,6 +687,7 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
> > >
> > > BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
> > > BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
> > > + BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
> >
> > The magic number 32 and 48 are repeated through this code. I'd suggest
> > to define them and use defined names.
> > It can come up as a separate commit.
> >
>
> Or perhaps instead:
IMO this is much better.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ----
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 6406d8c3411a..58c371930fb4 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -683,20 +683,23 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
> {
> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
> const u32 *regs = a6xx_protect;
> - unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32;
> -
> - BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
> - BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
> - BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
> + unsigned i, count, count_max;
>
> if (adreno_is_a650(adreno_gpu)) {
> regs = a650_protect;
> count = ARRAY_SIZE(a650_protect);
> count_max = 48;
> + BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
> } else if (adreno_is_a660_family(adreno_gpu)) {
> regs = a660_protect;
> count = ARRAY_SIZE(a660_protect);
> count_max = 48;
> + BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
> + } else {
> + regs = a6xx_protect;
> + count = ARRAY_SIZE(a6xx_protect);
> + count_max = 32;
> + BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
> }
>
> /*
> ----
>
> that moves each of the two uses of constant together.. adding three
> #defines each used only twice seems a bit silly, IMHO
>
> BR,
> -R
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/msm/a6xx: Fix missing ARRAY_SIZE() check
2022-03-04 21:47 ` Dmitry Baryshkov
@ 2022-03-04 21:58 ` Rob Clark
2022-03-05 10:37 ` Dmitry Baryshkov
0 siblings, 1 reply; 6+ messages in thread
From: Rob Clark @ 2022-03-04 21:58 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: dri-devel, freedreno, linux-arm-msm, Rob Clark, Sean Paul,
Abhinav Kumar, David Airlie, Daniel Vetter, Akhil P Oommen,
Jonathan Marek, Jordan Crouse, open list
On Fri, Mar 4, 2022 at 1:47 PM Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> On Fri, 4 Mar 2022 at 23:23, Rob Clark <robdclark@gmail.com> wrote:
> >
> > From: Rob Clark <robdclark@chromium.org>
> >
> > Fixes: f6d62d091cfd ("drm/msm/a6xx: add support for Adreno 660 GPU")
> > Signed-off-by: Rob Clark <robdclark@chromium.org>
>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> However see the comment below.
>
> > ---
> > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > index 02b47977b5c3..6406d8c3411a 100644
> > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > @@ -687,6 +687,7 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
> >
> > BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
> > BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
> > + BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
>
> The magic number 32 and 48 are repeated through this code. I'd suggest
> to define them and use defined names.
> It can come up as a separate commit.
>
Or perhaps instead:
----
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 6406d8c3411a..58c371930fb4 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -683,20 +683,23 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
{
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
const u32 *regs = a6xx_protect;
- unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32;
-
- BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
- BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
- BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
+ unsigned i, count, count_max;
if (adreno_is_a650(adreno_gpu)) {
regs = a650_protect;
count = ARRAY_SIZE(a650_protect);
count_max = 48;
+ BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
} else if (adreno_is_a660_family(adreno_gpu)) {
regs = a660_protect;
count = ARRAY_SIZE(a660_protect);
count_max = 48;
+ BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
+ } else {
+ regs = a6xx_protect;
+ count = ARRAY_SIZE(a6xx_protect);
+ count_max = 32;
+ BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
}
/*
----
that moves each of the two uses of constant together.. adding three
#defines each used only twice seems a bit silly, IMHO
BR,
-R
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/msm/a6xx: Fix missing ARRAY_SIZE() check
2022-03-04 20:24 Rob Clark
@ 2022-03-04 21:47 ` Dmitry Baryshkov
2022-03-04 21:58 ` Rob Clark
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Baryshkov @ 2022-03-04 21:47 UTC (permalink / raw)
To: Rob Clark
Cc: dri-devel, freedreno, linux-arm-msm, Rob Clark, Sean Paul,
Abhinav Kumar, David Airlie, Daniel Vetter, Akhil P Oommen,
Jonathan Marek, Jordan Crouse, open list
On Fri, 4 Mar 2022 at 23:23, Rob Clark <robdclark@gmail.com> wrote:
>
> From: Rob Clark <robdclark@chromium.org>
>
> Fixes: f6d62d091cfd ("drm/msm/a6xx: add support for Adreno 660 GPU")
> Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
However see the comment below.
> ---
> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 02b47977b5c3..6406d8c3411a 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -687,6 +687,7 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
>
> BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
> BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
> + BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
The magic number 32 and 48 are repeated through this code. I'd suggest
to define them and use defined names.
It can come up as a separate commit.
> if (adreno_is_a650(adreno_gpu)) {
> regs = a650_protect;
> --
> 2.35.1
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] drm/msm/a6xx: Fix missing ARRAY_SIZE() check
@ 2022-03-04 20:24 Rob Clark
2022-03-04 21:47 ` Dmitry Baryshkov
0 siblings, 1 reply; 6+ messages in thread
From: Rob Clark @ 2022-03-04 20:24 UTC (permalink / raw)
To: dri-devel
Cc: freedreno, linux-arm-msm, Rob Clark, Rob Clark, Sean Paul,
Abhinav Kumar, David Airlie, Daniel Vetter, Akhil P Oommen,
Dmitry Baryshkov, Jonathan Marek, Jordan Crouse, open list
From: Rob Clark <robdclark@chromium.org>
Fixes: f6d62d091cfd ("drm/msm/a6xx: add support for Adreno 660 GPU")
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 02b47977b5c3..6406d8c3411a 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -687,6 +687,7 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
+ BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
if (adreno_is_a650(adreno_gpu)) {
regs = a650_protect;
--
2.35.1
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-07 15:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-05 17:34 [PATCH] drm/msm/a6xx: Fix missing ARRAY_SIZE() check Rob Clark
2022-03-07 15:03 ` Akhil P Oommen
-- strict thread matches above, loose matches on Subject: below --
2022-03-04 20:24 Rob Clark
2022-03-04 21:47 ` Dmitry Baryshkov
2022-03-04 21:58 ` Rob Clark
2022-03-05 10:37 ` Dmitry Baryshkov
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®