On Mon, Feb 20, 2012 at 5:57 PM, <j.glisse@xxxxxxxxx> wrote: > From: Jerome Glisse <jglisse@xxxxxxxxxx> > > If accel is not working many subsystem such as the ib pool might not be > initialized properly that can lead to segfault inside kernel when cs > ioctl is call with non working acceleration. To avoid this make sure > the accel working flag is false when an error in GPU startup happen and > return EBUSY from cs ioctl if accel is not working. > > Signed-off-by: Jerome Glisse <jglisse@xxxxxxxxxx> Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx> > --- > drivers/gpu/drm/radeon/evergreen.c | 1 + > drivers/gpu/drm/radeon/ni.c | 1 + > drivers/gpu/drm/radeon/r100.c | 8 +++++++- > drivers/gpu/drm/radeon/r300.c | 8 +++++++- > drivers/gpu/drm/radeon/r420.c | 8 +++++++- > drivers/gpu/drm/radeon/r520.c | 8 +++++++- > drivers/gpu/drm/radeon/r600.c | 1 + > drivers/gpu/drm/radeon/radeon_cs.c | 4 ++++ > drivers/gpu/drm/radeon/rs400.c | 8 +++++++- > drivers/gpu/drm/radeon/rs600.c | 8 +++++++- > drivers/gpu/drm/radeon/rs690.c | 8 +++++++- > drivers/gpu/drm/radeon/rv515.c | 8 +++++++- > drivers/gpu/drm/radeon/rv770.c | 1 + > 13 files changed, 64 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c > index 1a816ea..cb86330 100644 > --- a/drivers/gpu/drm/radeon/evergreen.c > +++ b/drivers/gpu/drm/radeon/evergreen.c > @@ -3254,6 +3254,7 @@ int evergreen_resume(struct radeon_device *rdev) > r = evergreen_startup(rdev); > if (r) { > DRM_ERROR("evergreen startup failed on resume\n"); > + rdev->accel_working = false; > return r; > } > > diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c > index db09065..2509c50 100644 > --- a/drivers/gpu/drm/radeon/ni.c > +++ b/drivers/gpu/drm/radeon/ni.c > @@ -1547,6 +1547,7 @@ int cayman_resume(struct radeon_device *rdev) > r = cayman_startup(rdev); > if (r) { > DRM_ERROR("cayman startup failed on resume\n"); > + rdev->accel_working = false; > return r; > } > return r; > diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c > index bfd36ab..3563756 100644 > --- a/drivers/gpu/drm/radeon/r100.c > +++ b/drivers/gpu/drm/radeon/r100.c > @@ -3930,6 +3930,8 @@ static int r100_startup(struct radeon_device *rdev) > > int r100_resume(struct radeon_device *rdev) > { > + int r; > + > /* Make sur GART are not working */ > if (rdev->flags & RADEON_IS_PCI) > r100_pci_gart_disable(rdev); > @@ -3949,7 +3951,11 @@ int r100_resume(struct radeon_device *rdev) > radeon_surface_init(rdev); > > rdev->accel_working = true; > - return r100_startup(rdev); > + r = r100_startup(rdev); > + if (r) { > + rdev->accel_working = false; > + } > + return r; > } > > int r100_suspend(struct radeon_device *rdev) > diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c > index 3fc0d29..6829638 100644 > --- a/drivers/gpu/drm/radeon/r300.c > +++ b/drivers/gpu/drm/radeon/r300.c > @@ -1431,6 +1431,8 @@ static int r300_startup(struct radeon_device *rdev) > > int r300_resume(struct radeon_device *rdev) > { > + int r; > + > /* Make sur GART are not working */ > if (rdev->flags & RADEON_IS_PCIE) > rv370_pcie_gart_disable(rdev); > @@ -1452,7 +1454,11 @@ int r300_resume(struct radeon_device *rdev) > radeon_surface_init(rdev); > > rdev->accel_working = true; > - return r300_startup(rdev); > + r = r300_startup(rdev); > + if (r) { > + rdev->accel_working = false; > + } > + return r; > } > > int r300_suspend(struct radeon_device *rdev) > diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c > index 666e28f..b143230 100644 > --- a/drivers/gpu/drm/radeon/r420.c > +++ b/drivers/gpu/drm/radeon/r420.c > @@ -291,6 +291,8 @@ static int r420_startup(struct radeon_device *rdev) > > int r420_resume(struct radeon_device *rdev) > { > + int r; > + > /* Make sur GART are not working */ > if (rdev->flags & RADEON_IS_PCIE) > rv370_pcie_gart_disable(rdev); > @@ -316,7 +318,11 @@ int r420_resume(struct radeon_device *rdev) > radeon_surface_init(rdev); > > rdev->accel_working = true; > - return r420_startup(rdev); > + r = r420_startup(rdev); > + if (r) { > + rdev->accel_working = false; > + } > + return r; > } > > int r420_suspend(struct radeon_device *rdev) > diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c > index 4ae1615..25084e8 100644 > --- a/drivers/gpu/drm/radeon/r520.c > +++ b/drivers/gpu/drm/radeon/r520.c > @@ -218,6 +218,8 @@ static int r520_startup(struct radeon_device *rdev) > > int r520_resume(struct radeon_device *rdev) > { > + int r; > + > /* Make sur GART are not working */ > if (rdev->flags & RADEON_IS_PCIE) > rv370_pcie_gart_disable(rdev); > @@ -237,7 +239,11 @@ int r520_resume(struct radeon_device *rdev) > radeon_surface_init(rdev); > > rdev->accel_working = true; > - return r520_startup(rdev); > + r = r520_startup(rdev); > + if (r) { > + rdev->accel_working = false; > + } > + return r; > } > > int r520_init(struct radeon_device *rdev) > diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c > index 4f08e5e..fbcd848 100644 > --- a/drivers/gpu/drm/radeon/r600.c > +++ b/drivers/gpu/drm/radeon/r600.c > @@ -2529,6 +2529,7 @@ int r600_resume(struct radeon_device *rdev) > r = r600_startup(rdev); > if (r) { > DRM_ERROR("r600 startup failed on resume\n"); > + rdev->accel_working = false; > return r; > } > > diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c > index 435a3d9..e64bec4 100644 > --- a/drivers/gpu/drm/radeon/radeon_cs.c > +++ b/drivers/gpu/drm/radeon/radeon_cs.c > @@ -453,6 +453,10 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) > int r; > > radeon_mutex_lock(&rdev->cs_mutex); > + if (!rdev->accel_working) { > + radeon_mutex_unlock(&rdev->cs_mutex); > + return -EBUSY; > + } > /* initialize parser */ > memset(&parser, 0, sizeof(struct radeon_cs_parser)); > parser.filp = filp; > diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c > index b0ce84a..866a05b 100644 > --- a/drivers/gpu/drm/radeon/rs400.c > +++ b/drivers/gpu/drm/radeon/rs400.c > @@ -442,6 +442,8 @@ static int rs400_startup(struct radeon_device *rdev) > > int rs400_resume(struct radeon_device *rdev) > { > + int r; > + > /* Make sur GART are not working */ > rs400_gart_disable(rdev); > /* Resume clock before doing reset */ > @@ -462,7 +464,11 @@ int rs400_resume(struct radeon_device *rdev) > radeon_surface_init(rdev); > > rdev->accel_working = true; > - return rs400_startup(rdev); > + r = rs400_startup(rdev); > + if (r) { > + rdev->accel_working = false; > + } > + return r; > } > > int rs400_suspend(struct radeon_device *rdev) > diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c > index ec46eb4..a436ff1 100644 > --- a/drivers/gpu/drm/radeon/rs600.c > +++ b/drivers/gpu/drm/radeon/rs600.c > @@ -878,6 +878,8 @@ static int rs600_startup(struct radeon_device *rdev) > > int rs600_resume(struct radeon_device *rdev) > { > + int r; > + > /* Make sur GART are not working */ > rs600_gart_disable(rdev); > /* Resume clock before doing reset */ > @@ -896,7 +898,11 @@ int rs600_resume(struct radeon_device *rdev) > radeon_surface_init(rdev); > > rdev->accel_working = true; > - return rs600_startup(rdev); > + r = rs600_startup(rdev); > + if (r) { > + rdev->accel_working = false; > + } > + return r; > } > > int rs600_suspend(struct radeon_device *rdev) > diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c > index 4f24a0f..f68dff2 100644 > --- a/drivers/gpu/drm/radeon/rs690.c > +++ b/drivers/gpu/drm/radeon/rs690.c > @@ -659,6 +659,8 @@ static int rs690_startup(struct radeon_device *rdev) > > int rs690_resume(struct radeon_device *rdev) > { > + int r; > + > /* Make sur GART are not working */ > rs400_gart_disable(rdev); > /* Resume clock before doing reset */ > @@ -677,7 +679,11 @@ int rs690_resume(struct radeon_device *rdev) > radeon_surface_init(rdev); > > rdev->accel_working = true; > - return rs690_startup(rdev); > + r = rs690_startup(rdev); > + if (r) { > + rdev->accel_working = false; > + } > + return r; > } > > int rs690_suspend(struct radeon_device *rdev) > diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c > index 880637f..959bf44 100644 > --- a/drivers/gpu/drm/radeon/rv515.c > +++ b/drivers/gpu/drm/radeon/rv515.c > @@ -424,6 +424,8 @@ static int rv515_startup(struct radeon_device *rdev) > > int rv515_resume(struct radeon_device *rdev) > { > + int r; > + > /* Make sur GART are not working */ > if (rdev->flags & RADEON_IS_PCIE) > rv370_pcie_gart_disable(rdev); > @@ -443,7 +445,11 @@ int rv515_resume(struct radeon_device *rdev) > radeon_surface_init(rdev); > > rdev->accel_working = true; > - return rv515_startup(rdev); > + r = rv515_startup(rdev); > + if (r) { > + rdev->accel_working = false; > + } > + return r; > } > > int rv515_suspend(struct radeon_device *rdev) > diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c > index a1668b6..c049c0c 100644 > --- a/drivers/gpu/drm/radeon/rv770.c > +++ b/drivers/gpu/drm/radeon/rv770.c > @@ -1139,6 +1139,7 @@ int rv770_resume(struct radeon_device *rdev) > r = rv770_startup(rdev); > if (r) { > DRM_ERROR("r600 startup failed on resume\n"); > + rdev->accel_working = false; > return r; > } > > -- > 1.7.7.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel