All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Shirish S <shirish.s-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Harry.Wentland-5C7GfCeVMHo@public.gmane.org,
	Rex.Zhu-5C7GfCeVMHo@public.gmane.org
Subject: Re: [PATCH] drm/amdgpu: replace mutex with spin_lock
Date: Wed, 30 May 2018 17:40:22 +0200	[thread overview]
Message-ID: <753dc27e-dfd1-ee0c-e592-2883a8110dfe@gmail.com> (raw)
In-Reply-To: <1527675594-24143-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>

Keep in mind that under SRIOV you can read registers while in atomic 
context, e.g. while holding a spinlock.

Please double check if that won't bite us.

Apart from that the change looks good to me,
Christian.

Am 30.05.2018 um 12:19 schrieb Shirish S:
> 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@amd.com>
> ---
>   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;

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-05-30 15:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 10:19 [PATCH] drm/amdgpu: replace mutex with spin_lock Shirish S
     [not found] ` <1527675594-24143-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
2018-05-30 15:21   ` Deucher, Alexander
     [not found]     ` <BN6PR12MB1809BB86BD60CB77FB5A7BADF76C0-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-05-31  9:56       ` S, Shirish
2018-05-30 15:40   ` Christian König [this message]
     [not found]     ` <753dc27e-dfd1-ee0c-e592-2883a8110dfe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-05-31  9:59       ` S, Shirish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=753dc27e-dfd1-ee0c-e592-2883a8110dfe@gmail.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Harry.Wentland-5C7GfCeVMHo@public.gmane.org \
    --cc=Rex.Zhu-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=shirish.s-5C7GfCeVMHo@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.