diff mbox series

drm/msm: Upgrade gxpd checks to IS_ERR_OR_NULL

Message ID 20190515170104.155525-1-sean@poorly.run (mailing list archive)
State Not Applicable, archived
Headers show
Series drm/msm: Upgrade gxpd checks to IS_ERR_OR_NULL | expand

Commit Message

Sean Paul May 15, 2019, 5 p.m. UTC
From: Sean Paul <seanpaul@chromium.org>

dev_pm_domain_attach_by_name() can return NULL, so we should check for
that case when we're about to dereference gxpd.

Fixes: 9325d4266afd ("drm/msm/gpu: Attach to the GPU GX power domain")
Cc: Jordan Crouse <jcrouse@codeaurora.org>
Cc: Rob Clark <robdclark@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jordan Crouse May 15, 2019, 7:39 p.m. UTC | #1
On Wed, May 15, 2019 at 01:00:52PM -0400, Sean Paul wrote:
> From: Sean Paul <seanpaul@chromium.org>
> 
> dev_pm_domain_attach_by_name() can return NULL, so we should check for
> that case when we're about to dereference gxpd.
> 
> Fixes: 9325d4266afd ("drm/msm/gpu: Attach to the GPU GX power domain")
> Cc: Jordan Crouse <jcrouse@codeaurora.org>
> Cc: Rob Clark <robdclark@chromium.org>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>

Reviewed-by: Jordan Crouse <jcrouse@codeauorora.org>

> ---
>  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 9155dafae2a90..38e2cfa9cec79 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -747,7 +747,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
>  	 * will make sure that the refcounting is correct in case we need to
>  	 * bring down the GX after a GMU failure
>  	 */
> -	if (!IS_ERR(gmu->gxpd))
> +	if (!IS_ERR_OR_NULL(gmu->gxpd))
>  		pm_runtime_get(gmu->gxpd);
>  
>  out:
> @@ -863,7 +863,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
>  	 * domain. Usually the GMU does this but only if the shutdown sequence
>  	 * was successful
>  	 */
> -	if (!IS_ERR(gmu->gxpd))
> +	if (!IS_ERR_OR_NULL(gmu->gxpd))
>  		pm_runtime_put_sync(gmu->gxpd);
>  
>  	clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
> @@ -1234,7 +1234,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
>  
>  	pm_runtime_disable(gmu->dev);
>  
> -	if (!IS_ERR(gmu->gxpd)) {
> +	if (!IS_ERR_OR_NULL(gmu->gxpd)) {
>  		pm_runtime_disable(gmu->gxpd);
>  		dev_pm_domain_detach(gmu->gxpd, false);
>  	}
> -- 
> Sean Paul, Software Engineer, Google / Chromium OS
>
Sean Paul May 15, 2019, 8:07 p.m. UTC | #2
On Wed, May 15, 2019 at 3:39 PM Jordan Crouse <jcrouse@codeaurora.org> wrote:
>
> On Wed, May 15, 2019 at 01:00:52PM -0400, Sean Paul wrote:
> > From: Sean Paul <seanpaul@chromium.org>
> >
> > dev_pm_domain_attach_by_name() can return NULL, so we should check for
> > that case when we're about to dereference gxpd.
> >
> > Fixes: 9325d4266afd ("drm/msm/gpu: Attach to the GPU GX power domain")
> > Cc: Jordan Crouse <jcrouse@codeaurora.org>
> > Cc: Rob Clark <robdclark@chromium.org>
> > Signed-off-by: Sean Paul <seanpaul@chromium.org>
>
> Reviewed-by: Jordan Crouse <jcrouse@codeauorora.org>
>

Thanks for the review, I've applied it to -misc-next-fixes with the
other msm fixes for 5.2


Sean

> > ---
> >  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > index 9155dafae2a90..38e2cfa9cec79 100644
> > --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > @@ -747,7 +747,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
> >        * will make sure that the refcounting is correct in case we need to
> >        * bring down the GX after a GMU failure
> >        */
> > -     if (!IS_ERR(gmu->gxpd))
> > +     if (!IS_ERR_OR_NULL(gmu->gxpd))
> >               pm_runtime_get(gmu->gxpd);
> >
> >  out:
> > @@ -863,7 +863,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
> >        * domain. Usually the GMU does this but only if the shutdown sequence
> >        * was successful
> >        */
> > -     if (!IS_ERR(gmu->gxpd))
> > +     if (!IS_ERR_OR_NULL(gmu->gxpd))
> >               pm_runtime_put_sync(gmu->gxpd);
> >
> >       clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
> > @@ -1234,7 +1234,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
> >
> >       pm_runtime_disable(gmu->dev);
> >
> > -     if (!IS_ERR(gmu->gxpd)) {
> > +     if (!IS_ERR_OR_NULL(gmu->gxpd)) {
> >               pm_runtime_disable(gmu->gxpd);
> >               dev_pm_domain_detach(gmu->gxpd, false);
> >       }
> > --
> > Sean Paul, Software Engineer, Google / Chromium OS
> >
>
> --
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
Bjorn Andersson May 15, 2019, 11:50 p.m. UTC | #3
On Wed 15 May 13:07 PDT 2019, Sean Paul wrote:

> On Wed, May 15, 2019 at 3:39 PM Jordan Crouse <jcrouse@codeaurora.org> wrote:
> >
> > On Wed, May 15, 2019 at 01:00:52PM -0400, Sean Paul wrote:
> > > From: Sean Paul <seanpaul@chromium.org>
> > >
> > > dev_pm_domain_attach_by_name() can return NULL, so we should check for
> > > that case when we're about to dereference gxpd.
> > >
> > > Fixes: 9325d4266afd ("drm/msm/gpu: Attach to the GPU GX power domain")
> > > Cc: Jordan Crouse <jcrouse@codeaurora.org>
> > > Cc: Rob Clark <robdclark@chromium.org>
> > > Signed-off-by: Sean Paul <seanpaul@chromium.org>
> >
> > Reviewed-by: Jordan Crouse <jcrouse@codeauorora.org>
> >
> 
> Thanks for the review, I've applied it to -misc-next-fixes with the
> other msm fixes for 5.2
> 

Thanks for fixing this.

I hadn't published my for-next-next branch when I spotted this, so the
addition of the GPU in the dts was amended to include the gxpd - and
will show up on -next after -rc1.

Regards,
Bjorn

> 
> Sean
> 
> > > ---
> > >  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > > index 9155dafae2a90..38e2cfa9cec79 100644
> > > --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> > > @@ -747,7 +747,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
> > >        * will make sure that the refcounting is correct in case we need to
> > >        * bring down the GX after a GMU failure
> > >        */
> > > -     if (!IS_ERR(gmu->gxpd))
> > > +     if (!IS_ERR_OR_NULL(gmu->gxpd))
> > >               pm_runtime_get(gmu->gxpd);
> > >
> > >  out:
> > > @@ -863,7 +863,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
> > >        * domain. Usually the GMU does this but only if the shutdown sequence
> > >        * was successful
> > >        */
> > > -     if (!IS_ERR(gmu->gxpd))
> > > +     if (!IS_ERR_OR_NULL(gmu->gxpd))
> > >               pm_runtime_put_sync(gmu->gxpd);
> > >
> > >       clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
> > > @@ -1234,7 +1234,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
> > >
> > >       pm_runtime_disable(gmu->dev);
> > >
> > > -     if (!IS_ERR(gmu->gxpd)) {
> > > +     if (!IS_ERR_OR_NULL(gmu->gxpd)) {
> > >               pm_runtime_disable(gmu->gxpd);
> > >               dev_pm_domain_detach(gmu->gxpd, false);
> > >       }
> > > --
> > > Sean Paul, Software Engineer, Google / Chromium OS
> > >
> >
> > --
> > The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> > a Linux Foundation Collaborative Project
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 9155dafae2a90..38e2cfa9cec79 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -747,7 +747,7 @@  int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 	 * will make sure that the refcounting is correct in case we need to
 	 * bring down the GX after a GMU failure
 	 */
-	if (!IS_ERR(gmu->gxpd))
+	if (!IS_ERR_OR_NULL(gmu->gxpd))
 		pm_runtime_get(gmu->gxpd);
 
 out:
@@ -863,7 +863,7 @@  int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
 	 * domain. Usually the GMU does this but only if the shutdown sequence
 	 * was successful
 	 */
-	if (!IS_ERR(gmu->gxpd))
+	if (!IS_ERR_OR_NULL(gmu->gxpd))
 		pm_runtime_put_sync(gmu->gxpd);
 
 	clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
@@ -1234,7 +1234,7 @@  void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
 
 	pm_runtime_disable(gmu->dev);
 
-	if (!IS_ERR(gmu->gxpd)) {
+	if (!IS_ERR_OR_NULL(gmu->gxpd)) {
 		pm_runtime_disable(gmu->gxpd);
 		dev_pm_domain_detach(gmu->gxpd, false);
 	}