Karol Herbst
2015-Nov-14 19:51 UTC
[Nouveau] [PATCH v2] pmu: use nvkm_msec instead of do while
I hit this while loop in an error state of the gpu v2: unlock mutex only if reply == true Signed-off-by: Karol Herbst <nouveau at karolherbst.de> --- drm/nouveau/nvkm/subdev/pmu/base.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drm/nouveau/nvkm/subdev/pmu/base.c b/drm/nouveau/nvkm/subdev/pmu/base.c index 81a5583..eb248fd 100644 --- a/drm/nouveau/nvkm/subdev/pmu/base.c +++ b/drm/nouveau/nvkm/subdev/pmu/base.c @@ -100,9 +100,16 @@ nvkm_pmu_send(struct nvkm_pmu *pmu, u32 reply[2], } /* acquire data segment access */ - do { + nvkm_wr32(device, 0x10a580, 0x00000001); + if (nvkm_msec(device, 2000, + if (nvkm_rd32(device, 0x10a580) == 0x00000001) + break; nvkm_wr32(device, 0x10a580, 0x00000001); - } while (nvkm_rd32(device, 0x10a580) != 0x00000001); + ) < 0) { + if (reply) + mutex_unlock(&subdev->mutex); + return -EBUSY; + } /* write the packet */ nvkm_wr32(device, 0x10a1c0, 0x01000000 | (((addr & 0x07) << 4) + -- 2.6.3
Emil Velikov
2015-Nov-14 22:44 UTC
[Nouveau] [PATCH v2] pmu: use nvkm_msec instead of do while
On 14 November 2015 at 19:51, Karol Herbst <nouveau at karolherbst.de> wrote:> I hit this while loop in an error state of the gpu > > v2: unlock mutex only if reply == true > > Signed-off-by: Karol Herbst <nouveau at karolherbst.de> > --- > drm/nouveau/nvkm/subdev/pmu/base.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drm/nouveau/nvkm/subdev/pmu/base.c b/drm/nouveau/nvkm/subdev/pmu/base.c > index 81a5583..eb248fd 100644 > --- a/drm/nouveau/nvkm/subdev/pmu/base.c > +++ b/drm/nouveau/nvkm/subdev/pmu/base.c > @@ -100,9 +100,16 @@ nvkm_pmu_send(struct nvkm_pmu *pmu, u32 reply[2], > } > > /* acquire data segment access */ > - do { > + nvkm_wr32(device, 0x10a580, 0x00000001); > + if (nvkm_msec(device, 2000, > + if (nvkm_rd32(device, 0x10a580) == 0x00000001) > + break; > nvkm_wr32(device, 0x10a580, 0x00000001); > - } while (nvkm_rd32(device, 0x10a580) != 0x00000001); > + ) < 0) { > + if (reply) > + mutex_unlock(&subdev->mutex); > + return -EBUSY; > + }As you're here might as well use the new nvkm_wait_Xsec macros ? -Emil
Karol Herbst
2015-Nov-15 12:07 UTC
[Nouveau] [PATCH v2] pmu: use nvkm_msec instead of do while
> Emil Velikov <emil.l.velikov at gmail.com> hat am 14. November 2015 um 23:44 > geschrieben: > > On 14 November 2015 at 19:51, Karol Herbst <nouveau at karolherbst.de> wrote: > > I hit this while loop in an error state of the gpu > > > > v2: unlock mutex only if reply == true > > > > Signed-off-by: Karol Herbst <nouveau at karolherbst.de> > > --- > > drm/nouveau/nvkm/subdev/pmu/base.c | 11 +++++++++-- > > 1 file changed, 9 insertions(+), 2 deletions(-) > > > > diff --git a/drm/nouveau/nvkm/subdev/pmu/base.c > > b/drm/nouveau/nvkm/subdev/pmu/base.c > > index 81a5583..eb248fd 100644 > > --- a/drm/nouveau/nvkm/subdev/pmu/base.c > > +++ b/drm/nouveau/nvkm/subdev/pmu/base.c > > @@ -100,9 +100,16 @@ nvkm_pmu_send(struct nvkm_pmu *pmu, u32 reply[2], > > } > > > > /* acquire data segment access */ > > - do { > > + nvkm_wr32(device, 0x10a580, 0x00000001); > > + if (nvkm_msec(device, 2000, > > + if (nvkm_rd32(device, 0x10a580) == 0x00000001) > > + break; > > nvkm_wr32(device, 0x10a580, 0x00000001); > > - } while (nvkm_rd32(device, 0x10a580) != 0x00000001); > > + ) < 0) { > > + if (reply) > > + mutex_unlock(&subdev->mutex); > > + return -EBUSY; > > + } > As you're here might as well use the new nvkm_wait_Xsec macros ?On a second thought, I don't want to use those timer functions at all, because they still depend on the gpu being in a sane state and I want to abort whenever something fishy is going on, too. I just want to let this while loop timeout after a second or so.> > -EmilKarol
Reasonably Related Threads
- [PATCH v2] pmu: use nvkm_msec instead of do while
- [PATCH] pmu: use nvkm_msec instead of do while
- [PATCH v2] pmu: fix queued messages while getting no IRQ
- [PATCH v3] pmu: fix queued messages while getting no IRQ
- [PATCH 1/3] nvkm/clk/gf100+: Clean up PLL locking test