diff mbox series

drm/msm/a6xx: fix for kernels without CONFIG_NVMEM

Message ID 20210216200909.19039-1-jonathan@marek.ca (mailing list archive)
State New, archived
Headers show
Series drm/msm/a6xx: fix for kernels without CONFIG_NVMEM | expand

Commit Message

Jonathan Marek Feb. 16, 2021, 8:09 p.m. UTC
Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a ENOENT error,
to fix the case where the kernel was compiled without CONFIG_NVMEM.

Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Rob Clark Feb. 17, 2021, 3:06 a.m. UTC | #1
On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca> wrote:
>
> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a ENOENT error,
> to fix the case where the kernel was compiled without CONFIG_NVMEM.
>
> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> ---
>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index ba8e9d3cf0fe..7fe5d97606aa 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
>
>         cell = nvmem_cell_get(dev, "speed_bin");
>         /*
> -        * -ENOENT means that the platform doesn't support speedbin which is
> -        * fine
> +        * -ENOENT means no speed bin in device tree,
> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM

very minor nit, it would be nice to at least preserve the gist of the
"which is fine" (ie. some variation of "this is an optional thing and
things won't catch fire without it" ;-))

(which is, I believe, is true, hopefully Akhil could confirm.. if not
we should have a harder dependency on CONFIG_NVMEM..)

BR,
-R

>          */
> -       if (PTR_ERR(cell) == -ENOENT)
> +       if (PTR_ERR(cell) == -ENOENT || PTR_ERR(cell) == -EOPNOTSUPP)
>                 return 0;
>         else if (IS_ERR(cell)) {
>                 DRM_DEV_ERROR(dev,
> --
> 2.26.1
>
Akhil P Oommen Feb. 17, 2021, 1:44 p.m. UTC | #2
On 2/17/2021 8:36 AM, Rob Clark wrote:
> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca> wrote:
>>
>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a ENOENT error,
>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
>>
>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
>> ---
>>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> index ba8e9d3cf0fe..7fe5d97606aa 100644
>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
>>
>>          cell = nvmem_cell_get(dev, "speed_bin");
>>          /*
>> -        * -ENOENT means that the platform doesn't support speedbin which is
>> -        * fine
>> +        * -ENOENT means no speed bin in device tree,
>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> 
> very minor nit, it would be nice to at least preserve the gist of the
> "which is fine" (ie. some variation of "this is an optional thing and
> things won't catch fire without it" ;-))
> 
> (which is, I believe, is true, hopefully Akhil could confirm.. if not
> we should have a harder dependency on CONFIG_NVMEM..)
IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw' 
property, we will see some error during boot up if we don't call 
dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev, 
"speed_bin")" is a way to test this.

If there is no other harm, we can put a hard dependency on CONFIG_NVMEM.

-Akhil.
> 
> BR,
> -R
> 
>>           */
>> -       if (PTR_ERR(cell) == -ENOENT)
>> +       if (PTR_ERR(cell) == -ENOENT || PTR_ERR(cell) == -EOPNOTSUPP)
>>                  return 0;
>>          else if (IS_ERR(cell)) {
>>                  DRM_DEV_ERROR(dev,
>> --
>> 2.26.1
>>
Jordan Crouse Feb. 17, 2021, 7:08 p.m. UTC | #3
On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> On 2/17/2021 8:36 AM, Rob Clark wrote:
> >On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca> wrote:
> >>
> >>Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a ENOENT error,
> >>to fix the case where the kernel was compiled without CONFIG_NVMEM.
> >>
> >>Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> >>Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> >>---
> >>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> >>  1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >>diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>index ba8e9d3cf0fe..7fe5d97606aa 100644
> >>--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>@@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
> >>
> >>         cell = nvmem_cell_get(dev, "speed_bin");
> >>         /*
> >>-        * -ENOENT means that the platform doesn't support speedbin which is
> >>-        * fine
> >>+        * -ENOENT means no speed bin in device tree,
> >>+        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> >
> >very minor nit, it would be nice to at least preserve the gist of the
> >"which is fine" (ie. some variation of "this is an optional thing and
> >things won't catch fire without it" ;-))
> >
> >(which is, I believe, is true, hopefully Akhil could confirm.. if not
> >we should have a harder dependency on CONFIG_NVMEM..)
> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw' property,
> we will see some error during boot up if we don't call
> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev, "speed_bin")"
> is a way to test this.
> 
> If there is no other harm, we can put a hard dependency on CONFIG_NVMEM.

I'm not sure if we want to go this far given the squishiness about module
dependencies. As far as I know we are the only driver that uses this seriously
on QCOM SoCs and this is only needed for certain targets. I don't know if we
want to force every target to build NVMEM and QFPROM on our behalf. But maybe
I'm just saying that because Kconfig dependencies tend to break my brain (and
then Arnd has to send a patch to fix it).

Jordan

> -Akhil.
> >
> >BR,
> >-R
> >
> >>          */
> >>-       if (PTR_ERR(cell) == -ENOENT)
> >>+       if (PTR_ERR(cell) == -ENOENT || PTR_ERR(cell) == -EOPNOTSUPP)
> >>                 return 0;
> >>         else if (IS_ERR(cell)) {
> >>                 DRM_DEV_ERROR(dev,
> >>--
> >>2.26.1
> >>
>
Rob Clark Feb. 17, 2021, 8:18 p.m. UTC | #4
On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse <jcrouse@codeaurora.org> wrote:
>
> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> > On 2/17/2021 8:36 AM, Rob Clark wrote:
> > >On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca> wrote:
> > >>
> > >>Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a ENOENT error,
> > >>to fix the case where the kernel was compiled without CONFIG_NVMEM.
> > >>
> > >>Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> > >>Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> > >>---
> > >>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> > >>  1 file changed, 3 insertions(+), 3 deletions(-)
> > >>
> > >>diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > >>index ba8e9d3cf0fe..7fe5d97606aa 100644
> > >>--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > >>+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > >>@@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
> > >>
> > >>         cell = nvmem_cell_get(dev, "speed_bin");
> > >>         /*
> > >>-        * -ENOENT means that the platform doesn't support speedbin which is
> > >>-        * fine
> > >>+        * -ENOENT means no speed bin in device tree,
> > >>+        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> > >
> > >very minor nit, it would be nice to at least preserve the gist of the
> > >"which is fine" (ie. some variation of "this is an optional thing and
> > >things won't catch fire without it" ;-))
> > >
> > >(which is, I believe, is true, hopefully Akhil could confirm.. if not
> > >we should have a harder dependency on CONFIG_NVMEM..)
> > IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw' property,
> > we will see some error during boot up if we don't call
> > dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev, "speed_bin")"
> > is a way to test this.
> >
> > If there is no other harm, we can put a hard dependency on CONFIG_NVMEM.
>
> I'm not sure if we want to go this far given the squishiness about module
> dependencies. As far as I know we are the only driver that uses this seriously
> on QCOM SoCs and this is only needed for certain targets. I don't know if we
> want to force every target to build NVMEM and QFPROM on our behalf. But maybe
> I'm just saying that because Kconfig dependencies tend to break my brain (and
> then Arnd has to send a patch to fix it).
>

Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
other dependencies, so I suppose it wouldn't be the end of the world
to select that.. but I guess we don't want to require QFPROM

I guess at the end of the day, what is the failure mode if you have a
speed-bin device, but your kernel config misses QFPROM (and possibly
NVMEM)?  If the result is just not having the highest clk rate(s)
available, that isn't the end of the world.  But if it makes things
not-work, that is sub-optimal.  Generally, especially on ARM, kconfig
seems to be way harder than it should be to build a kernel that works,
if we could somehow not add to that problem (for both people with a6xx
and older gens) that would be nice ;-)

BR,
-R
Jonathan Marek Feb. 17, 2021, 8:35 p.m. UTC | #5
On 2/17/21 3:18 PM, Rob Clark wrote:
> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse <jcrouse@codeaurora.org> wrote:
>>
>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca> wrote:
>>>>>
>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a ENOENT error,
>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
>>>>>
>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
>>>>> ---
>>>>>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
>>>>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
>>>>>
>>>>>          cell = nvmem_cell_get(dev, "speed_bin");
>>>>>          /*
>>>>> -        * -ENOENT means that the platform doesn't support speedbin which is
>>>>> -        * fine
>>>>> +        * -ENOENT means no speed bin in device tree,
>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
>>>>
>>>> very minor nit, it would be nice to at least preserve the gist of the
>>>> "which is fine" (ie. some variation of "this is an optional thing and
>>>> things won't catch fire without it" ;-))
>>>>
>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
>>>> we should have a harder dependency on CONFIG_NVMEM..)
>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw' property,
>>> we will see some error during boot up if we don't call
>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev, "speed_bin")"
>>> is a way to test this.
>>>
>>> If there is no other harm, we can put a hard dependency on CONFIG_NVMEM.
>>
>> I'm not sure if we want to go this far given the squishiness about module
>> dependencies. As far as I know we are the only driver that uses this seriously
>> on QCOM SoCs and this is only needed for certain targets. I don't know if we
>> want to force every target to build NVMEM and QFPROM on our behalf. But maybe
>> I'm just saying that because Kconfig dependencies tend to break my brain (and
>> then Arnd has to send a patch to fix it).
>>
> 
> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
> other dependencies, so I suppose it wouldn't be the end of the world
> to select that.. but I guess we don't want to require QFPROM
> 
> I guess at the end of the day, what is the failure mode if you have a
> speed-bin device, but your kernel config misses QFPROM (and possibly
> NVMEM)?  If the result is just not having the highest clk rate(s)
> available, that isn't the end of the world.  But if it makes things
> not-work, that is sub-optimal.  Generally, especially on ARM, kconfig
> seems to be way harder than it should be to build a kernel that works,
> if we could somehow not add to that problem (for both people with a6xx
> and older gens) that would be nice ;-)
> 

There is a "imply" kconfig option which solves exactly this problem. 
(you would "imply NVMEM" instead of "select NVMEM". then it would be 
possible to disable NVMEM but it would get enabled by default)

> BR,
> -R
>
Akhil P Oommen Feb. 18, 2021, 12:28 p.m. UTC | #6
On 2/18/2021 2:05 AM, Jonathan Marek wrote:
> On 2/17/21 3:18 PM, Rob Clark wrote:
>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse 
>> <jcrouse@codeaurora.org> wrote:
>>>
>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca> 
>>>>> wrote:
>>>>>>
>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a 
>>>>>> ENOENT error,
>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
>>>>>>
>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
>>>>>> ---
>>>>>>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
>>>>>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct 
>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
>>>>>>
>>>>>>          cell = nvmem_cell_get(dev, "speed_bin");
>>>>>>          /*
>>>>>> -        * -ENOENT means that the platform doesn't support 
>>>>>> speedbin which is
>>>>>> -        * fine
>>>>>> +        * -ENOENT means no speed bin in device tree,
>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
>>>>>
>>>>> very minor nit, it would be nice to at least preserve the gist of the
>>>>> "which is fine" (ie. some variation of "this is an optional thing and
>>>>> things won't catch fire without it" ;-))
>>>>>
>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
>>>>> we should have a harder dependency on CONFIG_NVMEM..)
>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw' 
>>>> property,
>>>> we will see some error during boot up if we don't call
>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev, 
>>>> "speed_bin")"
>>>> is a way to test this.
>>>>
>>>> If there is no other harm, we can put a hard dependency on 
>>>> CONFIG_NVMEM.
>>>
>>> I'm not sure if we want to go this far given the squishiness about 
>>> module
>>> dependencies. As far as I know we are the only driver that uses this 
>>> seriously
>>> on QCOM SoCs and this is only needed for certain targets. I don't 
>>> know if we
>>> want to force every target to build NVMEM and QFPROM on our behalf. 
>>> But maybe
>>> I'm just saying that because Kconfig dependencies tend to break my 
>>> brain (and
>>> then Arnd has to send a patch to fix it).
>>>
>>
>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
>> other dependencies, so I suppose it wouldn't be the end of the world
>> to select that.. but I guess we don't want to require QFPROM
>>
>> I guess at the end of the day, what is the failure mode if you have a
>> speed-bin device, but your kernel config misses QFPROM (and possibly
>> NVMEM)?  If the result is just not having the highest clk rate(s)

Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't 
be very obvious what went wrong when this happens!

-Akhil.

>> available, that isn't the end of the world.  But if it makes things
>> not-work, that is sub-optimal.  Generally, especially on ARM, kconfig
>> seems to be way harder than it should be to build a kernel that works,
>> if we could somehow not add to that problem (for both people with a6xx
>> and older gens) that would be nice ;-)
>>
> 
> There is a "imply" kconfig option which solves exactly this problem. 
> (you would "imply NVMEM" instead of "select NVMEM". then it would be 
> possible to disable NVMEM but it would get enabled by default)
> 
>> BR,
>> -R
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Rob Clark Feb. 18, 2021, 4:11 p.m. UTC | #7
On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>
> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
> > On 2/17/21 3:18 PM, Rob Clark wrote:
> >> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
> >> <jcrouse@codeaurora.org> wrote:
> >>>
> >>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> >>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
> >>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
> >>>>> wrote:
> >>>>>>
> >>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
> >>>>>> ENOENT error,
> >>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
> >>>>>>
> >>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> >>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> >>>>>> ---
> >>>>>>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> >>>>>>   1 file changed, 3 insertions(+), 3 deletions(-)
> >>>>>>
> >>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
> >>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
> >>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
> >>>>>>
> >>>>>>          cell = nvmem_cell_get(dev, "speed_bin");
> >>>>>>          /*
> >>>>>> -        * -ENOENT means that the platform doesn't support
> >>>>>> speedbin which is
> >>>>>> -        * fine
> >>>>>> +        * -ENOENT means no speed bin in device tree,
> >>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> >>>>>
> >>>>> very minor nit, it would be nice to at least preserve the gist of the
> >>>>> "which is fine" (ie. some variation of "this is an optional thing and
> >>>>> things won't catch fire without it" ;-))
> >>>>>
> >>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
> >>>>> we should have a harder dependency on CONFIG_NVMEM..)
> >>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
> >>>> property,
> >>>> we will see some error during boot up if we don't call
> >>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
> >>>> "speed_bin")"
> >>>> is a way to test this.
> >>>>
> >>>> If there is no other harm, we can put a hard dependency on
> >>>> CONFIG_NVMEM.
> >>>
> >>> I'm not sure if we want to go this far given the squishiness about
> >>> module
> >>> dependencies. As far as I know we are the only driver that uses this
> >>> seriously
> >>> on QCOM SoCs and this is only needed for certain targets. I don't
> >>> know if we
> >>> want to force every target to build NVMEM and QFPROM on our behalf.
> >>> But maybe
> >>> I'm just saying that because Kconfig dependencies tend to break my
> >>> brain (and
> >>> then Arnd has to send a patch to fix it).
> >>>
> >>
> >> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
> >> other dependencies, so I suppose it wouldn't be the end of the world
> >> to select that.. but I guess we don't want to require QFPROM
> >>
> >> I guess at the end of the day, what is the failure mode if you have a
> >> speed-bin device, but your kernel config misses QFPROM (and possibly
> >> NVMEM)?  If the result is just not having the highest clk rate(s)
>
> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
> be very obvious what went wrong when this happens!

Ugg, ok..

I suppose we could select NVMEM, but not QFPROM, and then the case
where QFPROM is not enabled on platforms that have the speed-bin field
in DT will fail gracefully and all other platforms would continue on
happily?

BR,
-R

>
> >> available, that isn't the end of the world.  But if it makes things
> >> not-work, that is sub-optimal.  Generally, especially on ARM, kconfig
> >> seems to be way harder than it should be to build a kernel that works,
> >> if we could somehow not add to that problem (for both people with a6xx
> >> and older gens) that would be nice ;-)
> >>
> >
> > There is a "imply" kconfig option which solves exactly this problem.
> > (you would "imply NVMEM" instead of "select NVMEM". then it would be
> > possible to disable NVMEM but it would get enabled by default)
> >
> >> BR,
> >> -R
> >>
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
Akhil P Oommen Feb. 19, 2021, 10:44 a.m. UTC | #8
On 2/18/2021 9:41 PM, Rob Clark wrote:
> On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>>
>> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
>>> On 2/17/21 3:18 PM, Rob Clark wrote:
>>>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
>>>> <jcrouse@codeaurora.org> wrote:
>>>>>
>>>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
>>>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
>>>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
>>>>>>>> ENOENT error,
>>>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
>>>>>>>>
>>>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
>>>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
>>>>>>>> ---
>>>>>>>>    drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
>>>>>>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
>>>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
>>>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
>>>>>>>>
>>>>>>>>           cell = nvmem_cell_get(dev, "speed_bin");
>>>>>>>>           /*
>>>>>>>> -        * -ENOENT means that the platform doesn't support
>>>>>>>> speedbin which is
>>>>>>>> -        * fine
>>>>>>>> +        * -ENOENT means no speed bin in device tree,
>>>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
>>>>>>>
>>>>>>> very minor nit, it would be nice to at least preserve the gist of the
>>>>>>> "which is fine" (ie. some variation of "this is an optional thing and
>>>>>>> things won't catch fire without it" ;-))
>>>>>>>
>>>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
>>>>>>> we should have a harder dependency on CONFIG_NVMEM..)
>>>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
>>>>>> property,
>>>>>> we will see some error during boot up if we don't call
>>>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
>>>>>> "speed_bin")"
>>>>>> is a way to test this.
>>>>>>
>>>>>> If there is no other harm, we can put a hard dependency on
>>>>>> CONFIG_NVMEM.
>>>>>
>>>>> I'm not sure if we want to go this far given the squishiness about
>>>>> module
>>>>> dependencies. As far as I know we are the only driver that uses this
>>>>> seriously
>>>>> on QCOM SoCs and this is only needed for certain targets. I don't
>>>>> know if we
>>>>> want to force every target to build NVMEM and QFPROM on our behalf.
>>>>> But maybe
>>>>> I'm just saying that because Kconfig dependencies tend to break my
>>>>> brain (and
>>>>> then Arnd has to send a patch to fix it).
>>>>>
>>>>
>>>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
>>>> other dependencies, so I suppose it wouldn't be the end of the world
>>>> to select that.. but I guess we don't want to require QFPROM
>>>>
>>>> I guess at the end of the day, what is the failure mode if you have a
>>>> speed-bin device, but your kernel config misses QFPROM (and possibly
>>>> NVMEM)?  If the result is just not having the highest clk rate(s)
>>
>> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
>> be very obvious what went wrong when this happens!
> 
> Ugg, ok..
> 
> I suppose we could select NVMEM, but not QFPROM, and then the case
> where QFPROM is not enabled on platforms that have the speed-bin field
> in DT will fail gracefully and all other platforms would continue on
> happily?
> 
> BR,
> -R

Sounds good to me.

-Akhil.

> 
>>
>>>> available, that isn't the end of the world.  But if it makes things
>>>> not-work, that is sub-optimal.  Generally, especially on ARM, kconfig
>>>> seems to be way harder than it should be to build a kernel that works,
>>>> if we could somehow not add to that problem (for both people with a6xx
>>>> and older gens) that would be nice ;-)
>>>>
>>>
>>> There is a "imply" kconfig option which solves exactly this problem.
>>> (you would "imply NVMEM" instead of "select NVMEM". then it would be
>>> possible to disable NVMEM but it would get enabled by default)
>>>
>>>> BR,
>>>> -R
>>>>
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
Rob Clark Feb. 19, 2021, 4 p.m. UTC | #9
On Fri, Feb 19, 2021 at 2:44 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>
> On 2/18/2021 9:41 PM, Rob Clark wrote:
> > On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> >>
> >> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
> >>> On 2/17/21 3:18 PM, Rob Clark wrote:
> >>>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
> >>>> <jcrouse@codeaurora.org> wrote:
> >>>>>
> >>>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> >>>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
> >>>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
> >>>>>>> wrote:
> >>>>>>>>
> >>>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
> >>>>>>>> ENOENT error,
> >>>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
> >>>>>>>>
> >>>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> >>>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> >>>>>>>> ---
> >>>>>>>>    drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> >>>>>>>>    1 file changed, 3 insertions(+), 3 deletions(-)
> >>>>>>>>
> >>>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
> >>>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
> >>>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
> >>>>>>>>
> >>>>>>>>           cell = nvmem_cell_get(dev, "speed_bin");
> >>>>>>>>           /*
> >>>>>>>> -        * -ENOENT means that the platform doesn't support
> >>>>>>>> speedbin which is
> >>>>>>>> -        * fine
> >>>>>>>> +        * -ENOENT means no speed bin in device tree,
> >>>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> >>>>>>>
> >>>>>>> very minor nit, it would be nice to at least preserve the gist of the
> >>>>>>> "which is fine" (ie. some variation of "this is an optional thing and
> >>>>>>> things won't catch fire without it" ;-))
> >>>>>>>
> >>>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
> >>>>>>> we should have a harder dependency on CONFIG_NVMEM..)
> >>>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
> >>>>>> property,
> >>>>>> we will see some error during boot up if we don't call
> >>>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
> >>>>>> "speed_bin")"
> >>>>>> is a way to test this.
> >>>>>>
> >>>>>> If there is no other harm, we can put a hard dependency on
> >>>>>> CONFIG_NVMEM.
> >>>>>
> >>>>> I'm not sure if we want to go this far given the squishiness about
> >>>>> module
> >>>>> dependencies. As far as I know we are the only driver that uses this
> >>>>> seriously
> >>>>> on QCOM SoCs and this is only needed for certain targets. I don't
> >>>>> know if we
> >>>>> want to force every target to build NVMEM and QFPROM on our behalf.
> >>>>> But maybe
> >>>>> I'm just saying that because Kconfig dependencies tend to break my
> >>>>> brain (and
> >>>>> then Arnd has to send a patch to fix it).
> >>>>>
> >>>>
> >>>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
> >>>> other dependencies, so I suppose it wouldn't be the end of the world
> >>>> to select that.. but I guess we don't want to require QFPROM
> >>>>
> >>>> I guess at the end of the day, what is the failure mode if you have a
> >>>> speed-bin device, but your kernel config misses QFPROM (and possibly
> >>>> NVMEM)?  If the result is just not having the highest clk rate(s)
> >>
> >> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
> >> be very obvious what went wrong when this happens!
> >
> > Ugg, ok..
> >
> > I suppose we could select NVMEM, but not QFPROM, and then the case
> > where QFPROM is not enabled on platforms that have the speed-bin field
> > in DT will fail gracefully and all other platforms would continue on
> > happily?
> >
> > BR,
> > -R
>
> Sounds good to me.
>

You probably should do a quick test with NVMEM enabled but QFPROM
disabled to confirm my theory, but I *think* that should work

BR,
-R
Akhil P Oommen Feb. 22, 2021, 3:45 p.m. UTC | #10
On 2/19/2021 9:30 PM, Rob Clark wrote:
> On Fri, Feb 19, 2021 at 2:44 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>>
>> On 2/18/2021 9:41 PM, Rob Clark wrote:
>>> On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>>>>
>>>> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
>>>>> On 2/17/21 3:18 PM, Rob Clark wrote:
>>>>>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
>>>>>> <jcrouse@codeaurora.org> wrote:
>>>>>>>
>>>>>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
>>>>>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
>>>>>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
>>>>>>>>>> ENOENT error,
>>>>>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
>>>>>>>>>>
>>>>>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
>>>>>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
>>>>>>>>>> ---
>>>>>>>>>>     drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
>>>>>>>>>>     1 file changed, 3 insertions(+), 3 deletions(-)
>>>>>>>>>>
>>>>>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
>>>>>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
>>>>>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
>>>>>>>>>>
>>>>>>>>>>            cell = nvmem_cell_get(dev, "speed_bin");
>>>>>>>>>>            /*
>>>>>>>>>> -        * -ENOENT means that the platform doesn't support
>>>>>>>>>> speedbin which is
>>>>>>>>>> -        * fine
>>>>>>>>>> +        * -ENOENT means no speed bin in device tree,
>>>>>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
>>>>>>>>>
>>>>>>>>> very minor nit, it would be nice to at least preserve the gist of the
>>>>>>>>> "which is fine" (ie. some variation of "this is an optional thing and
>>>>>>>>> things won't catch fire without it" ;-))
>>>>>>>>>
>>>>>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
>>>>>>>>> we should have a harder dependency on CONFIG_NVMEM..)
>>>>>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
>>>>>>>> property,
>>>>>>>> we will see some error during boot up if we don't call
>>>>>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
>>>>>>>> "speed_bin")"
>>>>>>>> is a way to test this.
>>>>>>>>
>>>>>>>> If there is no other harm, we can put a hard dependency on
>>>>>>>> CONFIG_NVMEM.
>>>>>>>
>>>>>>> I'm not sure if we want to go this far given the squishiness about
>>>>>>> module
>>>>>>> dependencies. As far as I know we are the only driver that uses this
>>>>>>> seriously
>>>>>>> on QCOM SoCs and this is only needed for certain targets. I don't
>>>>>>> know if we
>>>>>>> want to force every target to build NVMEM and QFPROM on our behalf.
>>>>>>> But maybe
>>>>>>> I'm just saying that because Kconfig dependencies tend to break my
>>>>>>> brain (and
>>>>>>> then Arnd has to send a patch to fix it).
>>>>>>>
>>>>>>
>>>>>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
>>>>>> other dependencies, so I suppose it wouldn't be the end of the world
>>>>>> to select that.. but I guess we don't want to require QFPROM
>>>>>>
>>>>>> I guess at the end of the day, what is the failure mode if you have a
>>>>>> speed-bin device, but your kernel config misses QFPROM (and possibly
>>>>>> NVMEM)?  If the result is just not having the highest clk rate(s)
>>>>
>>>> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
>>>> be very obvious what went wrong when this happens!
>>>
>>> Ugg, ok..
>>>
>>> I suppose we could select NVMEM, but not QFPROM, and then the case
>>> where QFPROM is not enabled on platforms that have the speed-bin field
>>> in DT will fail gracefully and all other platforms would continue on
>>> happily?
>>>
>>> BR,
>>> -R
>>
>> Sounds good to me.
>>
> 
> You probably should do a quick test with NVMEM enabled but QFPROM
> disabled to confirm my theory, but I *think* that should work
> 
> BR,
> -R
> 

I tried it on an sc7180 device. The suggested combo (CONFIG_NVMEM + no 
CONFIG_QCOM_QFPROM) makes the gpu probe fail with error "failed to read 
speed-bin. Some OPPs may not be supported by hardware". This is good 
enough clue for the developer that he should fix the broken speedbin 
detection.

-Akhil.
Rob Clark Feb. 22, 2021, 4:06 p.m. UTC | #11
On Mon, Feb 22, 2021 at 7:45 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>
> On 2/19/2021 9:30 PM, Rob Clark wrote:
> > On Fri, Feb 19, 2021 at 2:44 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> >>
> >> On 2/18/2021 9:41 PM, Rob Clark wrote:
> >>> On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> >>>>
> >>>> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
> >>>>> On 2/17/21 3:18 PM, Rob Clark wrote:
> >>>>>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
> >>>>>> <jcrouse@codeaurora.org> wrote:
> >>>>>>>
> >>>>>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> >>>>>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
> >>>>>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
> >>>>>>>>> wrote:
> >>>>>>>>>>
> >>>>>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
> >>>>>>>>>> ENOENT error,
> >>>>>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
> >>>>>>>>>>
> >>>>>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> >>>>>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> >>>>>>>>>> ---
> >>>>>>>>>>     drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> >>>>>>>>>>     1 file changed, 3 insertions(+), 3 deletions(-)
> >>>>>>>>>>
> >>>>>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
> >>>>>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >>>>>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
> >>>>>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
> >>>>>>>>>>
> >>>>>>>>>>            cell = nvmem_cell_get(dev, "speed_bin");
> >>>>>>>>>>            /*
> >>>>>>>>>> -        * -ENOENT means that the platform doesn't support
> >>>>>>>>>> speedbin which is
> >>>>>>>>>> -        * fine
> >>>>>>>>>> +        * -ENOENT means no speed bin in device tree,
> >>>>>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> >>>>>>>>>
> >>>>>>>>> very minor nit, it would be nice to at least preserve the gist of the
> >>>>>>>>> "which is fine" (ie. some variation of "this is an optional thing and
> >>>>>>>>> things won't catch fire without it" ;-))
> >>>>>>>>>
> >>>>>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
> >>>>>>>>> we should have a harder dependency on CONFIG_NVMEM..)
> >>>>>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
> >>>>>>>> property,
> >>>>>>>> we will see some error during boot up if we don't call
> >>>>>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
> >>>>>>>> "speed_bin")"
> >>>>>>>> is a way to test this.
> >>>>>>>>
> >>>>>>>> If there is no other harm, we can put a hard dependency on
> >>>>>>>> CONFIG_NVMEM.
> >>>>>>>
> >>>>>>> I'm not sure if we want to go this far given the squishiness about
> >>>>>>> module
> >>>>>>> dependencies. As far as I know we are the only driver that uses this
> >>>>>>> seriously
> >>>>>>> on QCOM SoCs and this is only needed for certain targets. I don't
> >>>>>>> know if we
> >>>>>>> want to force every target to build NVMEM and QFPROM on our behalf.
> >>>>>>> But maybe
> >>>>>>> I'm just saying that because Kconfig dependencies tend to break my
> >>>>>>> brain (and
> >>>>>>> then Arnd has to send a patch to fix it).
> >>>>>>>
> >>>>>>
> >>>>>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
> >>>>>> other dependencies, so I suppose it wouldn't be the end of the world
> >>>>>> to select that.. but I guess we don't want to require QFPROM
> >>>>>>
> >>>>>> I guess at the end of the day, what is the failure mode if you have a
> >>>>>> speed-bin device, but your kernel config misses QFPROM (and possibly
> >>>>>> NVMEM)?  If the result is just not having the highest clk rate(s)
> >>>>
> >>>> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
> >>>> be very obvious what went wrong when this happens!
> >>>
> >>> Ugg, ok..
> >>>
> >>> I suppose we could select NVMEM, but not QFPROM, and then the case
> >>> where QFPROM is not enabled on platforms that have the speed-bin field
> >>> in DT will fail gracefully and all other platforms would continue on
> >>> happily?
> >>>
> >>> BR,
> >>> -R
> >>
> >> Sounds good to me.
> >>
> >
> > You probably should do a quick test with NVMEM enabled but QFPROM
> > disabled to confirm my theory, but I *think* that should work
> >
> > BR,
> > -R
> >
>
> I tried it on an sc7180 device. The suggested combo (CONFIG_NVMEM + no
> CONFIG_QCOM_QFPROM) makes the gpu probe fail with error "failed to read
> speed-bin. Some OPPs may not be supported by hardware". This is good
> enough clue for the developer that he should fix the broken speedbin
> detection.
>

Ok, great.. then sounds like selecting NVMEM is a good approach

BR,
-R
Rob Clark April 1, 2021, 8:12 p.m. UTC | #12
On Mon, Feb 22, 2021 at 8:06 AM Rob Clark <robdclark@gmail.com> wrote:
>
> On Mon, Feb 22, 2021 at 7:45 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> >
> > On 2/19/2021 9:30 PM, Rob Clark wrote:
> > > On Fri, Feb 19, 2021 at 2:44 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> > >>
> > >> On 2/18/2021 9:41 PM, Rob Clark wrote:
> > >>> On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> > >>>>
> > >>>> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
> > >>>>> On 2/17/21 3:18 PM, Rob Clark wrote:
> > >>>>>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
> > >>>>>> <jcrouse@codeaurora.org> wrote:
> > >>>>>>>
> > >>>>>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> > >>>>>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
> > >>>>>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
> > >>>>>>>>> wrote:
> > >>>>>>>>>>
> > >>>>>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
> > >>>>>>>>>> ENOENT error,
> > >>>>>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
> > >>>>>>>>>>
> > >>>>>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> > >>>>>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> > >>>>>>>>>> ---
> > >>>>>>>>>>     drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> > >>>>>>>>>>     1 file changed, 3 insertions(+), 3 deletions(-)
> > >>>>>>>>>>
> > >>>>>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > >>>>>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > >>>>>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
> > >>>>>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > >>>>>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > >>>>>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
> > >>>>>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
> > >>>>>>>>>>
> > >>>>>>>>>>            cell = nvmem_cell_get(dev, "speed_bin");
> > >>>>>>>>>>            /*
> > >>>>>>>>>> -        * -ENOENT means that the platform doesn't support
> > >>>>>>>>>> speedbin which is
> > >>>>>>>>>> -        * fine
> > >>>>>>>>>> +        * -ENOENT means no speed bin in device tree,
> > >>>>>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> > >>>>>>>>>
> > >>>>>>>>> very minor nit, it would be nice to at least preserve the gist of the
> > >>>>>>>>> "which is fine" (ie. some variation of "this is an optional thing and
> > >>>>>>>>> things won't catch fire without it" ;-))
> > >>>>>>>>>
> > >>>>>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
> > >>>>>>>>> we should have a harder dependency on CONFIG_NVMEM..)
> > >>>>>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
> > >>>>>>>> property,
> > >>>>>>>> we will see some error during boot up if we don't call
> > >>>>>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
> > >>>>>>>> "speed_bin")"
> > >>>>>>>> is a way to test this.
> > >>>>>>>>
> > >>>>>>>> If there is no other harm, we can put a hard dependency on
> > >>>>>>>> CONFIG_NVMEM.
> > >>>>>>>
> > >>>>>>> I'm not sure if we want to go this far given the squishiness about
> > >>>>>>> module
> > >>>>>>> dependencies. As far as I know we are the only driver that uses this
> > >>>>>>> seriously
> > >>>>>>> on QCOM SoCs and this is only needed for certain targets. I don't
> > >>>>>>> know if we
> > >>>>>>> want to force every target to build NVMEM and QFPROM on our behalf.
> > >>>>>>> But maybe
> > >>>>>>> I'm just saying that because Kconfig dependencies tend to break my
> > >>>>>>> brain (and
> > >>>>>>> then Arnd has to send a patch to fix it).
> > >>>>>>>
> > >>>>>>
> > >>>>>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
> > >>>>>> other dependencies, so I suppose it wouldn't be the end of the world
> > >>>>>> to select that.. but I guess we don't want to require QFPROM
> > >>>>>>
> > >>>>>> I guess at the end of the day, what is the failure mode if you have a
> > >>>>>> speed-bin device, but your kernel config misses QFPROM (and possibly
> > >>>>>> NVMEM)?  If the result is just not having the highest clk rate(s)
> > >>>>
> > >>>> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
> > >>>> be very obvious what went wrong when this happens!
> > >>>
> > >>> Ugg, ok..
> > >>>
> > >>> I suppose we could select NVMEM, but not QFPROM, and then the case
> > >>> where QFPROM is not enabled on platforms that have the speed-bin field
> > >>> in DT will fail gracefully and all other platforms would continue on
> > >>> happily?
> > >>>
> > >>> BR,
> > >>> -R
> > >>
> > >> Sounds good to me.
> > >>
> > >
> > > You probably should do a quick test with NVMEM enabled but QFPROM
> > > disabled to confirm my theory, but I *think* that should work
> > >
> > > BR,
> > > -R
> > >
> >
> > I tried it on an sc7180 device. The suggested combo (CONFIG_NVMEM + no
> > CONFIG_QCOM_QFPROM) makes the gpu probe fail with error "failed to read
> > speed-bin. Some OPPs may not be supported by hardware". This is good
> > enough clue for the developer that he should fix the broken speedbin
> > detection.
> >
>
> Ok, great.. then sounds like selecting NVMEM is a good approach
>

btw, did anyone ever send a patch to select NVMEM?  I'm not seeing one
but I could be overlooking something

BR,
-R
Dmitry Baryshkov April 1, 2021, 9:03 p.m. UTC | #13
On Thu, 1 Apr 2021 at 23:09, Rob Clark <robdclark@gmail.com> wrote:
>
> On Mon, Feb 22, 2021 at 8:06 AM Rob Clark <robdclark@gmail.com> wrote:
> >
> > On Mon, Feb 22, 2021 at 7:45 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> > >
> > > On 2/19/2021 9:30 PM, Rob Clark wrote:
> > > > On Fri, Feb 19, 2021 at 2:44 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> > > >>
> > > >> On 2/18/2021 9:41 PM, Rob Clark wrote:
> > > >>> On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> > > >>>>
> > > >>>> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
> > > >>>>> On 2/17/21 3:18 PM, Rob Clark wrote:
> > > >>>>>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
> > > >>>>>> <jcrouse@codeaurora.org> wrote:
> > > >>>>>>>
> > > >>>>>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> > > >>>>>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
> > > >>>>>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
> > > >>>>>>>>> wrote:
> > > >>>>>>>>>>
> > > >>>>>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
> > > >>>>>>>>>> ENOENT error,
> > > >>>>>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
> > > >>>>>>>>>>
> > > >>>>>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> > > >>>>>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> > > >>>>>>>>>> ---
> > > >>>>>>>>>>     drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> > > >>>>>>>>>>     1 file changed, 3 insertions(+), 3 deletions(-)
> > > >>>>>>>>>>
> > > >>>>>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > >>>>>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > >>>>>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
> > > >>>>>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > >>>>>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > >>>>>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
> > > >>>>>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
> > > >>>>>>>>>>
> > > >>>>>>>>>>            cell = nvmem_cell_get(dev, "speed_bin");
> > > >>>>>>>>>>            /*
> > > >>>>>>>>>> -        * -ENOENT means that the platform doesn't support
> > > >>>>>>>>>> speedbin which is
> > > >>>>>>>>>> -        * fine
> > > >>>>>>>>>> +        * -ENOENT means no speed bin in device tree,
> > > >>>>>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> > > >>>>>>>>>
> > > >>>>>>>>> very minor nit, it would be nice to at least preserve the gist of the
> > > >>>>>>>>> "which is fine" (ie. some variation of "this is an optional thing and
> > > >>>>>>>>> things won't catch fire without it" ;-))
> > > >>>>>>>>>
> > > >>>>>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
> > > >>>>>>>>> we should have a harder dependency on CONFIG_NVMEM..)
> > > >>>>>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
> > > >>>>>>>> property,
> > > >>>>>>>> we will see some error during boot up if we don't call
> > > >>>>>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
> > > >>>>>>>> "speed_bin")"
> > > >>>>>>>> is a way to test this.
> > > >>>>>>>>
> > > >>>>>>>> If there is no other harm, we can put a hard dependency on
> > > >>>>>>>> CONFIG_NVMEM.
> > > >>>>>>>
> > > >>>>>>> I'm not sure if we want to go this far given the squishiness about
> > > >>>>>>> module
> > > >>>>>>> dependencies. As far as I know we are the only driver that uses this
> > > >>>>>>> seriously
> > > >>>>>>> on QCOM SoCs and this is only needed for certain targets. I don't
> > > >>>>>>> know if we
> > > >>>>>>> want to force every target to build NVMEM and QFPROM on our behalf.
> > > >>>>>>> But maybe
> > > >>>>>>> I'm just saying that because Kconfig dependencies tend to break my
> > > >>>>>>> brain (and
> > > >>>>>>> then Arnd has to send a patch to fix it).
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
> > > >>>>>> other dependencies, so I suppose it wouldn't be the end of the world
> > > >>>>>> to select that.. but I guess we don't want to require QFPROM
> > > >>>>>>
> > > >>>>>> I guess at the end of the day, what is the failure mode if you have a
> > > >>>>>> speed-bin device, but your kernel config misses QFPROM (and possibly
> > > >>>>>> NVMEM)?  If the result is just not having the highest clk rate(s)
> > > >>>>
> > > >>>> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
> > > >>>> be very obvious what went wrong when this happens!
> > > >>>
> > > >>> Ugg, ok..
> > > >>>
> > > >>> I suppose we could select NVMEM, but not QFPROM, and then the case
> > > >>> where QFPROM is not enabled on platforms that have the speed-bin field
> > > >>> in DT will fail gracefully and all other platforms would continue on
> > > >>> happily?
> > > >>>
> > > >>> BR,
> > > >>> -R
> > > >>
> > > >> Sounds good to me.
> > > >>
> > > >
> > > > You probably should do a quick test with NVMEM enabled but QFPROM
> > > > disabled to confirm my theory, but I *think* that should work
> > > >
> > > > BR,
> > > > -R
> > > >
> > >
> > > I tried it on an sc7180 device. The suggested combo (CONFIG_NVMEM + no
> > > CONFIG_QCOM_QFPROM) makes the gpu probe fail with error "failed to read
> > > speed-bin. Some OPPs may not be supported by hardware". This is good
> > > enough clue for the developer that he should fix the broken speedbin
> > > detection.
> > >
> >
> > Ok, great.. then sounds like selecting NVMEM is a good approach
> >
>
> btw, did anyone ever send a patch to select NVMEM?  I'm not seeing one
> but I could be overlooking something

Judging by the amount of issues surrounding speed-bin, I might have a
bold suggestion to revert these patches for now and get them once all
the issues are sorted, so that we'd have a single working commit
instead of scattered patch series breaking git bisect, having bad
side-effects on non-sc7180 platforms, etc.
Rob Clark April 1, 2021, 9:49 p.m. UTC | #14
On Thu, Apr 1, 2021 at 2:03 PM Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> On Thu, 1 Apr 2021 at 23:09, Rob Clark <robdclark@gmail.com> wrote:
> >
> > On Mon, Feb 22, 2021 at 8:06 AM Rob Clark <robdclark@gmail.com> wrote:
> > >
> > > On Mon, Feb 22, 2021 at 7:45 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> > > >
> > > > On 2/19/2021 9:30 PM, Rob Clark wrote:
> > > > > On Fri, Feb 19, 2021 at 2:44 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> > > > >>
> > > > >> On 2/18/2021 9:41 PM, Rob Clark wrote:
> > > > >>> On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
> > > > >>>>
> > > > >>>> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
> > > > >>>>> On 2/17/21 3:18 PM, Rob Clark wrote:
> > > > >>>>>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
> > > > >>>>>> <jcrouse@codeaurora.org> wrote:
> > > > >>>>>>>
> > > > >>>>>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> > > > >>>>>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
> > > > >>>>>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
> > > > >>>>>>>>> wrote:
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
> > > > >>>>>>>>>> ENOENT error,
> > > > >>>>>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
> > > > >>>>>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> > > > >>>>>>>>>> ---
> > > > >>>>>>>>>>     drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> > > > >>>>>>>>>>     1 file changed, 3 insertions(+), 3 deletions(-)
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > > >>>>>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > > >>>>>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
> > > > >>>>>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > > >>>>>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > > >>>>>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
> > > > >>>>>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>            cell = nvmem_cell_get(dev, "speed_bin");
> > > > >>>>>>>>>>            /*
> > > > >>>>>>>>>> -        * -ENOENT means that the platform doesn't support
> > > > >>>>>>>>>> speedbin which is
> > > > >>>>>>>>>> -        * fine
> > > > >>>>>>>>>> +        * -ENOENT means no speed bin in device tree,
> > > > >>>>>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
> > > > >>>>>>>>>
> > > > >>>>>>>>> very minor nit, it would be nice to at least preserve the gist of the
> > > > >>>>>>>>> "which is fine" (ie. some variation of "this is an optional thing and
> > > > >>>>>>>>> things won't catch fire without it" ;-))
> > > > >>>>>>>>>
> > > > >>>>>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
> > > > >>>>>>>>> we should have a harder dependency on CONFIG_NVMEM..)
> > > > >>>>>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
> > > > >>>>>>>> property,
> > > > >>>>>>>> we will see some error during boot up if we don't call
> > > > >>>>>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
> > > > >>>>>>>> "speed_bin")"
> > > > >>>>>>>> is a way to test this.
> > > > >>>>>>>>
> > > > >>>>>>>> If there is no other harm, we can put a hard dependency on
> > > > >>>>>>>> CONFIG_NVMEM.
> > > > >>>>>>>
> > > > >>>>>>> I'm not sure if we want to go this far given the squishiness about
> > > > >>>>>>> module
> > > > >>>>>>> dependencies. As far as I know we are the only driver that uses this
> > > > >>>>>>> seriously
> > > > >>>>>>> on QCOM SoCs and this is only needed for certain targets. I don't
> > > > >>>>>>> know if we
> > > > >>>>>>> want to force every target to build NVMEM and QFPROM on our behalf.
> > > > >>>>>>> But maybe
> > > > >>>>>>> I'm just saying that because Kconfig dependencies tend to break my
> > > > >>>>>>> brain (and
> > > > >>>>>>> then Arnd has to send a patch to fix it).
> > > > >>>>>>>
> > > > >>>>>>
> > > > >>>>>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
> > > > >>>>>> other dependencies, so I suppose it wouldn't be the end of the world
> > > > >>>>>> to select that.. but I guess we don't want to require QFPROM
> > > > >>>>>>
> > > > >>>>>> I guess at the end of the day, what is the failure mode if you have a
> > > > >>>>>> speed-bin device, but your kernel config misses QFPROM (and possibly
> > > > >>>>>> NVMEM)?  If the result is just not having the highest clk rate(s)
> > > > >>>>
> > > > >>>> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
> > > > >>>> be very obvious what went wrong when this happens!
> > > > >>>
> > > > >>> Ugg, ok..
> > > > >>>
> > > > >>> I suppose we could select NVMEM, but not QFPROM, and then the case
> > > > >>> where QFPROM is not enabled on platforms that have the speed-bin field
> > > > >>> in DT will fail gracefully and all other platforms would continue on
> > > > >>> happily?
> > > > >>>
> > > > >>> BR,
> > > > >>> -R
> > > > >>
> > > > >> Sounds good to me.
> > > > >>
> > > > >
> > > > > You probably should do a quick test with NVMEM enabled but QFPROM
> > > > > disabled to confirm my theory, but I *think* that should work
> > > > >
> > > > > BR,
> > > > > -R
> > > > >
> > > >
> > > > I tried it on an sc7180 device. The suggested combo (CONFIG_NVMEM + no
> > > > CONFIG_QCOM_QFPROM) makes the gpu probe fail with error "failed to read
> > > > speed-bin. Some OPPs may not be supported by hardware". This is good
> > > > enough clue for the developer that he should fix the broken speedbin
> > > > detection.
> > > >
> > >
> > > Ok, great.. then sounds like selecting NVMEM is a good approach
> > >
> >
> > btw, did anyone ever send a patch to select NVMEM?  I'm not seeing one
> > but I could be overlooking something
>
> Judging by the amount of issues surrounding speed-bin, I might have a
> bold suggestion to revert these patches for now and get them once all
> the issues are sorted, so that we'd have a single working commit
> instead of scattered patch series breaking git bisect, having bad
> side-effects on non-sc7180 platforms, etc.
>

We do really need some pre-merge CI like we have on the mesa side of
things (and we at least have 845 devices in our CI farm, but it would
be useful to add more generations)..  but other than the config issue,
I *think* this fixes the last of the speedbin fallout?

https://patchwork.freedesktop.org/patch/426538/?series=88558&rev=1

Planning to include that in a -fixes pull req in the next day or two.
(And please have a look at msm-next-staging and let me know if you see
anything other fixes that would be good to get in, speedbin related or
otherwise.)

BR,
-R
Akhil P Oommen April 3, 2021, 4:39 a.m. UTC | #15
On 4/2/2021 3:19 AM, Rob Clark wrote:
> On Thu, Apr 1, 2021 at 2:03 PM Dmitry Baryshkov
> <dmitry.baryshkov@linaro.org> wrote:
>>
>> On Thu, 1 Apr 2021 at 23:09, Rob Clark <robdclark@gmail.com> wrote:
>>>
>>> On Mon, Feb 22, 2021 at 8:06 AM Rob Clark <robdclark@gmail.com> wrote:
>>>>
>>>> On Mon, Feb 22, 2021 at 7:45 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>>>>>
>>>>> On 2/19/2021 9:30 PM, Rob Clark wrote:
>>>>>> On Fri, Feb 19, 2021 at 2:44 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>>>>>>>
>>>>>>> On 2/18/2021 9:41 PM, Rob Clark wrote:
>>>>>>>> On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen <akhilpo@codeaurora.org> wrote:
>>>>>>>>>
>>>>>>>>> On 2/18/2021 2:05 AM, Jonathan Marek wrote:
>>>>>>>>>> On 2/17/21 3:18 PM, Rob Clark wrote:
>>>>>>>>>>> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
>>>>>>>>>>> <jcrouse@codeaurora.org> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
>>>>>>>>>>>>> On 2/17/2021 8:36 AM, Rob Clark wrote:
>>>>>>>>>>>>>> On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek <jonathan@marek.ca>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
>>>>>>>>>>>>>>> ENOENT error,
>>>>>>>>>>>>>>> to fix the case where the kernel was compiled without CONFIG_NVMEM.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
>>>>>>>>>>>>>>> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
>>>>>>>>>>>>>>> ---
>>>>>>>>>>>>>>>      drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
>>>>>>>>>>>>>>>      1 file changed, 3 insertions(+), 3 deletions(-)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>>>>>>>>> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>>>>>>>>> index ba8e9d3cf0fe..7fe5d97606aa 100644
>>>>>>>>>>>>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>>>>>>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>>>>>>>>>>>>>> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
>>>>>>>>>>>>>>> device *dev, struct a6xx_gpu *a6xx_gpu,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>             cell = nvmem_cell_get(dev, "speed_bin");
>>>>>>>>>>>>>>>             /*
>>>>>>>>>>>>>>> -        * -ENOENT means that the platform doesn't support
>>>>>>>>>>>>>>> speedbin which is
>>>>>>>>>>>>>>> -        * fine
>>>>>>>>>>>>>>> +        * -ENOENT means no speed bin in device tree,
>>>>>>>>>>>>>>> +        * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> very minor nit, it would be nice to at least preserve the gist of the
>>>>>>>>>>>>>> "which is fine" (ie. some variation of "this is an optional thing and
>>>>>>>>>>>>>> things won't catch fire without it" ;-))
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> (which is, I believe, is true, hopefully Akhil could confirm.. if not
>>>>>>>>>>>>>> we should have a harder dependency on CONFIG_NVMEM..)
>>>>>>>>>>>>> IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
>>>>>>>>>>>>> property,
>>>>>>>>>>>>> we will see some error during boot up if we don't call
>>>>>>>>>>>>> dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
>>>>>>>>>>>>> "speed_bin")"
>>>>>>>>>>>>> is a way to test this.
>>>>>>>>>>>>>
>>>>>>>>>>>>> If there is no other harm, we can put a hard dependency on
>>>>>>>>>>>>> CONFIG_NVMEM.
>>>>>>>>>>>>
>>>>>>>>>>>> I'm not sure if we want to go this far given the squishiness about
>>>>>>>>>>>> module
>>>>>>>>>>>> dependencies. As far as I know we are the only driver that uses this
>>>>>>>>>>>> seriously
>>>>>>>>>>>> on QCOM SoCs and this is only needed for certain targets. I don't
>>>>>>>>>>>> know if we
>>>>>>>>>>>> want to force every target to build NVMEM and QFPROM on our behalf.
>>>>>>>>>>>> But maybe
>>>>>>>>>>>> I'm just saying that because Kconfig dependencies tend to break my
>>>>>>>>>>>> brain (and
>>>>>>>>>>>> then Arnd has to send a patch to fix it).
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
>>>>>>>>>>> other dependencies, so I suppose it wouldn't be the end of the world
>>>>>>>>>>> to select that.. but I guess we don't want to require QFPROM
>>>>>>>>>>>
>>>>>>>>>>> I guess at the end of the day, what is the failure mode if you have a
>>>>>>>>>>> speed-bin device, but your kernel config misses QFPROM (and possibly
>>>>>>>>>>> NVMEM)?  If the result is just not having the highest clk rate(s)
>>>>>>>>>
>>>>>>>>> Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It won't
>>>>>>>>> be very obvious what went wrong when this happens!
>>>>>>>>
>>>>>>>> Ugg, ok..
>>>>>>>>
>>>>>>>> I suppose we could select NVMEM, but not QFPROM, and then the case
>>>>>>>> where QFPROM is not enabled on platforms that have the speed-bin field
>>>>>>>> in DT will fail gracefully and all other platforms would continue on
>>>>>>>> happily?
>>>>>>>>
>>>>>>>> BR,
>>>>>>>> -R
>>>>>>>
>>>>>>> Sounds good to me.
>>>>>>>
>>>>>>
>>>>>> You probably should do a quick test with NVMEM enabled but QFPROM
>>>>>> disabled to confirm my theory, but I *think* that should work
>>>>>>
>>>>>> BR,
>>>>>> -R
>>>>>>
>>>>>
>>>>> I tried it on an sc7180 device. The suggested combo (CONFIG_NVMEM + no
>>>>> CONFIG_QCOM_QFPROM) makes the gpu probe fail with error "failed to read
>>>>> speed-bin. Some OPPs may not be supported by hardware". This is good
>>>>> enough clue for the developer that he should fix the broken speedbin
>>>>> detection.
>>>>>
>>>>
>>>> Ok, great.. then sounds like selecting NVMEM is a good approach
>>>>
>>>
>>> btw, did anyone ever send a patch to select NVMEM?  I'm not seeing one
>>> but I could be overlooking something
I thought Jonathan would send it as the discussion was going on in his 
patch. No problem, I will send it out. :)

-Akhil.

>>
>> Judging by the amount of issues surrounding speed-bin, I might have a
>> bold suggestion to revert these patches for now and get them once all
>> the issues are sorted, so that we'd have a single working commit
>> instead of scattered patch series breaking git bisect, having bad
>> side-effects on non-sc7180 platforms, etc.
>>
> 
> We do really need some pre-merge CI like we have on the mesa side of
> things (and we at least have 845 devices in our CI farm, but it would
> be useful to add more generations)..  but other than the config issue,
> I *think* this fixes the last of the speedbin fallout?
> 
> https://patchwork.freedesktop.org/patch/426538/?series=88558&rev=1
> 
> Planning to include that in a -fixes pull req in the next day or two.
> (And please have a look at msm-next-staging and let me know if you see
> anything other fixes that would be good to get in, speedbin related or
> otherwise.)
> 
> BR,
> -R
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index ba8e9d3cf0fe..7fe5d97606aa 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1356,10 +1356,10 @@  static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
 
 	cell = nvmem_cell_get(dev, "speed_bin");
 	/*
-	 * -ENOENT means that the platform doesn't support speedbin which is
-	 * fine
+	 * -ENOENT means no speed bin in device tree,
+	 * -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
 	 */
-	if (PTR_ERR(cell) == -ENOENT)
+	if (PTR_ERR(cell) == -ENOENT || PTR_ERR(cell) == -EOPNOTSUPP)
 		return 0;
 	else if (IS_ERR(cell)) {
 		DRM_DEV_ERROR(dev,