[PATCH] drm/amdgpu: replace mutex with spin_lock
Deucher, Alexander
Alexander.Deucher at amd.com
Wed May 30 15:21:47 UTC 2018
> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces at lists.freedesktop.org] On Behalf
> Of Shirish S
> Sent: Wednesday, May 30, 2018 6:20 AM
> To: amd-gfx at lists.freedesktop.org; Wentland, Harry
> <Harry.Wentland at amd.com>; Zhu, Rex <Rex.Zhu at amd.com>
> Cc: S, Shirish <Shirish.S at amd.com>
> Subject: [PATCH] drm/amdgpu: replace mutex with spin_lock
>
> mutex's lead to sleeps which should be avoided in atomic context.
> Hence this patch replaces it with the spin_locks.
>
> Signed-off-by: Shirish S <shirish.s at amd.com>
Does this actually fix a bug or is it just to be safe? Do actually call atom command tables in an atomic context?
Alex
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 +-
> drivers/gpu/drm/amd/amdgpu/atom.c | 4 ++--
> drivers/gpu/drm/amd/amdgpu/atom.h | 3 ++-
> 3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> index bf872f6..ba3d4b9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> @@ -2033,7 +2033,7 @@ int amdgpu_atombios_init(struct amdgpu_device
> *adev)
> return -ENOMEM;
> }
>
> - mutex_init(&adev->mode_info.atom_context->mutex);
> + spin_lock_init(&adev->mode_info.atom_context->lock);
> if (adev->is_atom_fw) {
> amdgpu_atomfirmware_scratch_regs_init(adev);
> amdgpu_atomfirmware_allocate_fb_scratch(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 69500a8..bfd98f0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -1261,7 +1261,7 @@ int amdgpu_atom_execute_table(struct
> atom_context *ctx, int index, uint32_t * pa {
> int r;
>
> - mutex_lock(&ctx->mutex);
> + spin_lock(&ctx->lock);
> /* reset data block */
> ctx->data_block = 0;
> /* reset reg block */
> @@ -1274,7 +1274,7 @@ int amdgpu_atom_execute_table(struct
> atom_context *ctx, int index, uint32_t * pa
> ctx->divmul[0] = 0;
> ctx->divmul[1] = 0;
> r = amdgpu_atom_execute_table_locked(ctx, index, params);
> - mutex_unlock(&ctx->mutex);
> + spin_unlock(&ctx->lock);
> return r;
> }
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.h
> b/drivers/gpu/drm/amd/amdgpu/atom.h
> index a391709..cdfb0d0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.h
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.h
> @@ -26,6 +26,7 @@
> #define ATOM_H
>
> #include <linux/types.h>
> +#include <linux/spinlock_types.h>
> #include <drm/drmP.h>
>
> #define ATOM_BIOS_MAGIC 0xAA55
> @@ -125,7 +126,7 @@ struct card_info {
>
> struct atom_context {
> struct card_info *card;
> - struct mutex mutex;
> + spinlock_t lock;
> void *bios;
> uint32_t cmd_table, data_table;
> uint16_t *iio;
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
More information about the amd-gfx
mailing list