drm/radeon: Don't flush the GART TLB if rdev->gart.ptr == NULL
diff mbox

Message ID 1435885347-5448-1-git-send-email-michel@daenzer.net
State New
Headers show

Commit Message

Michel Dänzer July 3, 2015, 1:02 a.m. UTC
From: Michel Dänzer <michel.daenzer@amd.com>

This can be the case when the GPU is powered off, e.g. via vgaswitcheroo
or runpm. When the GPU is powered up again, radeon_gart_table_vram_pin
flushes the TLB after setting rdev->gart.ptr to non-NULL.

Fixes panic on powering off R7xx GPUs.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61529
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 drivers/gpu/drm/radeon/radeon_gart.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Christian König July 3, 2015, 9:46 a.m. UTC | #1
On 03.07.2015 03:02, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> This can be the case when the GPU is powered off, e.g. via vgaswitcheroo
> or runpm. When the GPU is powered up again, radeon_gart_table_vram_pin
> flushes the TLB after setting rdev->gart.ptr to non-NULL.
>
> Fixes panic on powering off R7xx GPUs.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61529
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/radeon/radeon_gart.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
> index 5450fa9..c4777c8 100644
> --- a/drivers/gpu/drm/radeon/radeon_gart.c
> +++ b/drivers/gpu/drm/radeon/radeon_gart.c
> @@ -260,8 +260,10 @@ void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
>   			}
>   		}
>   	}
> -	mb();
> -	radeon_gart_tlb_flush(rdev);
> +	if (rdev->gart.ptr) {
> +		mb();
> +		radeon_gart_tlb_flush(rdev);
> +	}
>   }
>   
>   /**
> @@ -306,8 +308,10 @@ int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
>   			page_base += RADEON_GPU_PAGE_SIZE;
>   		}
>   	}
> -	mb();
> -	radeon_gart_tlb_flush(rdev);
> +	if (rdev->gart.ptr) {
> +		mb();
> +		radeon_gart_tlb_flush(rdev);
> +	}
>   	return 0;
>   }
>
Alex Deucher July 3, 2015, 7:27 p.m. UTC | #2
On Thu, Jul 2, 2015 at 9:02 PM, Michel Dänzer <michel@daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> This can be the case when the GPU is powered off, e.g. via vgaswitcheroo
> or runpm. When the GPU is powered up again, radeon_gart_table_vram_pin
> flushes the TLB after setting rdev->gart.ptr to non-NULL.
>
> Fixes panic on powering off R7xx GPUs.

This is a nice safely measure, but the underlying issue is that the
acpiphp code is broken again on some boards and attempts to remove the
device after the driver has already suspended the driver for runtime
pm.  So the the driver's pci_remove callback ends up being called
after the driver has already been suspended and the the hw has been
disabled.

Alex

>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61529
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
> ---
>  drivers/gpu/drm/radeon/radeon_gart.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
> index 5450fa9..c4777c8 100644
> --- a/drivers/gpu/drm/radeon/radeon_gart.c
> +++ b/drivers/gpu/drm/radeon/radeon_gart.c
> @@ -260,8 +260,10 @@ void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
>                         }
>                 }
>         }
> -       mb();
> -       radeon_gart_tlb_flush(rdev);
> +       if (rdev->gart.ptr) {
> +               mb();
> +               radeon_gart_tlb_flush(rdev);
> +       }
>  }
>
>  /**
> @@ -306,8 +308,10 @@ int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
>                         page_base += RADEON_GPU_PAGE_SIZE;
>                 }
>         }
> -       mb();
> -       radeon_gart_tlb_flush(rdev);
> +       if (rdev->gart.ptr) {
> +               mb();
> +               radeon_gart_tlb_flush(rdev);
> +       }
>         return 0;
>  }
>
> --
> 2.1.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox

diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 5450fa9..c4777c8 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -260,8 +260,10 @@  void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
 			}
 		}
 	}
-	mb();
-	radeon_gart_tlb_flush(rdev);
+	if (rdev->gart.ptr) {
+		mb();
+		radeon_gart_tlb_flush(rdev);
+	}
 }
 
 /**
@@ -306,8 +308,10 @@  int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
 			page_base += RADEON_GPU_PAGE_SIZE;
 		}
 	}
-	mb();
-	radeon_gart_tlb_flush(rdev);
+	if (rdev->gart.ptr) {
+		mb();
+		radeon_gart_tlb_flush(rdev);
+	}
 	return 0;
 }