[FFmpeg-devel] avutil/ppc/cpu: Fix power8 linux detection

Submitted by Lauri Kasanen on Jan. 8, 2019, 9:08 a.m.

Details

Message ID 20190108110804.01e3ad9ef85ea7446ad4c61a@gmx.com
State New
Headers show

Commit Message

Lauri Kasanen Jan. 8, 2019, 9:08 a.m.
The existing code was in no released kernel that I can see. The corrected code
was added in 3.9.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
---
 libavutil/ppc/cpu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Carl Eugen Hoyos Jan. 9, 2019, 8:55 p.m.
2019-01-08 10:08 GMT+01:00, Lauri Kasanen <cand@gmx.com>:
> The existing code was in no released kernel that I can see. The corrected
> code
> was added in 3.9.
>
> Signed-off-by: Lauri Kasanen <cand@gmx.com>
> ---
>  libavutil/ppc/cpu.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
> index 7bb7cd8..b022149 100644
> --- a/libavutil/ppc/cpu.c
> +++ b/libavutil/ppc/cpu.c
> @@ -93,13 +93,13 @@ int ff_get_cpu_flags_ppc(void)
>                  if (buf[i + 1] & PPC_FEATURE_HAS_VSX)
>                      ret |= AV_CPU_FLAG_VSX;
>  #endif
> -#ifdef PPC_FEATURE_ARCH_2_07
> -                if (buf[i + 1] & PPC_FEATURE_HAS_POWER8)
> -                    ret |= AV_CPU_FLAG_POWER8;
> -#endif
>                  if (ret & AV_CPU_FLAG_VSX)
>                      av_assert0(ret & AV_CPU_FLAG_ALTIVEC);

> -                goto out;

This seems like an unrelated change.

Carl Eugen
Lauri Kasanen Jan. 10, 2019, 9:45 a.m.
On Wed, 9 Jan 2019 21:55:30 +0100
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2019-01-08 10:08 GMT+01:00, Lauri Kasanen <cand@gmx.com>:
> > The existing code was in no released kernel that I can see. The corrected
> > code
> > was added in 3.9.
> >
> > Signed-off-by: Lauri Kasanen <cand@gmx.com>
> > ---
> >  libavutil/ppc/cpu.c | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
> > index 7bb7cd8..b022149 100644
> > --- a/libavutil/ppc/cpu.c
> > +++ b/libavutil/ppc/cpu.c
> > @@ -93,13 +93,13 @@ int ff_get_cpu_flags_ppc(void)
> >                  if (buf[i + 1] & PPC_FEATURE_HAS_VSX)
> >                      ret |= AV_CPU_FLAG_VSX;
> >  #endif
> > -#ifdef PPC_FEATURE_ARCH_2_07
> > -                if (buf[i + 1] & PPC_FEATURE_HAS_POWER8)
> > -                    ret |= AV_CPU_FLAG_POWER8;
> > -#endif
> >                  if (ret & AV_CPU_FLAG_VSX)
> >                      av_assert0(ret & AV_CPU_FLAG_ALTIVEC);
> 
> > -                goto out;
> 
> This seems like an unrelated change.

It's necessary. HWCAP appears before HWCAP2 in the array, so if the
code jumps out in HWCAP, it never gets to checking the CAP2 bits like
power8.

- Lauri
Carl Eugen Hoyos Jan. 10, 2019, 5:09 p.m.
2019-01-10 10:45 GMT+01:00, Lauri Kasanen <cand@gmx.com>:
> On Wed, 9 Jan 2019 21:55:30 +0100
> Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
>> 2019-01-08 10:08 GMT+01:00, Lauri Kasanen <cand@gmx.com>:
>> > The existing code was in no released kernel that I can see. The
>> > corrected
>> > code
>> > was added in 3.9.
>> >
>> > Signed-off-by: Lauri Kasanen <cand@gmx.com>
>> > ---
>> >  libavutil/ppc/cpu.c | 10 +++++-----
>> >  1 file changed, 5 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
>> > index 7bb7cd8..b022149 100644
>> > --- a/libavutil/ppc/cpu.c
>> > +++ b/libavutil/ppc/cpu.c
>> > @@ -93,13 +93,13 @@ int ff_get_cpu_flags_ppc(void)
>> >                  if (buf[i + 1] & PPC_FEATURE_HAS_VSX)
>> >                      ret |= AV_CPU_FLAG_VSX;
>> >  #endif
>> > -#ifdef PPC_FEATURE_ARCH_2_07
>> > -                if (buf[i + 1] & PPC_FEATURE_HAS_POWER8)
>> > -                    ret |= AV_CPU_FLAG_POWER8;
>> > -#endif
>> >                  if (ret & AV_CPU_FLAG_VSX)
>> >                      av_assert0(ret & AV_CPU_FLAG_ALTIVEC);
>>
>> > -                goto out;
>>
>> This seems like an unrelated change.
>
> It's necessary. HWCAP appears before HWCAP2 in the array, so if the
> code jumps out in HWCAP, it never gets to checking the CAP2 bits like
> power8.

The next line (that I unfortunately cut) is:
} else if (buf[i] == AT_HWCAP2) {
indicating afaict that it is only reached if buf[i] is not equal
to HWCAP.
What do I miss?

Carl Eugen
Lauri Kasanen Jan. 10, 2019, 5:21 p.m.
On Thu, 10 Jan 2019 18:09:21 +0100
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> >> > -                goto out;
> >>
> >> This seems like an unrelated change.
> >
> > It's necessary. HWCAP appears before HWCAP2 in the array, so if the
> > code jumps out in HWCAP, it never gets to checking the CAP2 bits like
> > power8.
> 
> The next line (that I unfortunately cut) is:
> } else if (buf[i] == AT_HWCAP2) {
> indicating afaict that it is only reached if buf[i] is not equal
> to HWCAP.
> What do I miss?

The surrounding context is a loop over all bytes:
for (i = 0; i < count / sizeof(*buf); i += 2) {

While the out: label is after the loop.

- Lauri
Carl Eugen Hoyos Jan. 10, 2019, 5:21 p.m.
2019-01-10 18:21 GMT+01:00, Lauri Kasanen <cand@gmx.com>:
> On Thu, 10 Jan 2019 18:09:21 +0100
> Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
>> >> > -                goto out;
>> >>
>> >> This seems like an unrelated change.
>> >
>> > It's necessary. HWCAP appears before HWCAP2 in the array, so if the
>> > code jumps out in HWCAP, it never gets to checking the CAP2 bits like
>> > power8.
>>
>> The next line (that I unfortunately cut) is:
>> } else if (buf[i] == AT_HWCAP2) {
>> indicating afaict that it is only reached if buf[i] is not equal
>> to HWCAP.
>> What do I miss?
>
> The surrounding context is a loop over all bytes:
> for (i = 0; i < count / sizeof(*buf); i += 2) {
>
> While the out: label is after the loop.

Thank you!

Carl Eugen
Lauri Kasanen Jan. 17, 2019, 7:40 a.m.
On Tue, 8 Jan 2019 11:08:04 +0200
Lauri Kasanen <cand@gmx.com> wrote:

> The existing code was in no released kernel that I can see. The corrected code
> was added in 3.9.
> 
> Signed-off-by: Lauri Kasanen <cand@gmx.com>
> ---
>  libavutil/ppc/cpu.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Ping.

- Lauri

Patch hide | download patch | download mbox

diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
index 7bb7cd8..b022149 100644
--- a/libavutil/ppc/cpu.c
+++ b/libavutil/ppc/cpu.c
@@ -93,13 +93,13 @@  int ff_get_cpu_flags_ppc(void)
                 if (buf[i + 1] & PPC_FEATURE_HAS_VSX)
                     ret |= AV_CPU_FLAG_VSX;
 #endif
-#ifdef PPC_FEATURE_ARCH_2_07
-                if (buf[i + 1] & PPC_FEATURE_HAS_POWER8)
-                    ret |= AV_CPU_FLAG_POWER8;
-#endif
                 if (ret & AV_CPU_FLAG_VSX)
                     av_assert0(ret & AV_CPU_FLAG_ALTIVEC);
-                goto out;
+            } else if (buf[i] == AT_HWCAP2) {
+#ifdef PPC_FEATURE2_ARCH_2_07
+                if (buf[i + 1] & PPC_FEATURE2_ARCH_2_07)
+                    ret |= AV_CPU_FLAG_POWER8;
+#endif
             }
         }
     }