All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yu, Xiangliang" <Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
	<deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: RE: [V2 05/11] drm/amdgpu/virt: add high level interfaces for virt
Date: Tue, 10 Jan 2017 14:26:19 +0000	[thread overview]
Message-ID: <CY4PR12MB170130F7A8A89BED6606D1A9EB670@CY4PR12MB1701.namprd12.prod.outlook.com> (raw)
In-Reply-To: <9350e215-4325-8c5e-db84-c5318aa480a2-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>

> -----Original Message-----
> From: Christian König [mailto:deathsimple@vodafone.de]
> Sent: Tuesday, January 10, 2017 9:59 PM
> To: Yu, Xiangliang <Xiangliang.Yu@amd.com>; amd-
> gfx@lists.freedesktop.org
> Subject: Re: [V2 05/11] drm/amdgpu/virt: add high level interfaces for virt
> 
> Am 10.01.2017 um 14:33 schrieb Yu, Xiangliang:
> >> -----Original Message-----
> >> From: Christian König [mailto:deathsimple@vodafone.de]
> >> Sent: Tuesday, January 10, 2017 9:12 PM
> >> To: Yu, Xiangliang <Xiangliang.Yu@amd.com>; amd-
> >> gfx@lists.freedesktop.org
> >> Subject: Re: [V2 05/11] drm/amdgpu/virt: add high level interfaces
> >> for virt
> >>
> >> Am 10.01.2017 um 11:00 schrieb Xiangliang Yu:
> >>> Add high level interfaces that is not relate to specific asic. So
> >>> asic files just need to implement the interfaces to support virtualization.
> >>>
> >>> Signed-off-by: Xiangliang Yu <Xiangliang.Yu@amd.com>
> >>> ---
> >>>    drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 57
> >> ++++++++++++++++++++++++++++++++
> >>>    drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 15 +++++++++
> >>>    2 files changed, 72 insertions(+)
> >>>
> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> >>> index 6520a4e..f32a789 100644
> >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> >>> @@ -84,3 +84,60 @@ void amdgpu_virt_kiq_wreg(struct
> amdgpu_device
> >> *adev, uint32_t reg, uint32_t v)
> >>>    		DRM_ERROR("wait for kiq fence error: %ld.\n", r);
> >>>    	fence_put(f);
> >>>    }
> >>> +
> >>> +/**
> >>> + * amdgpu_virt_request_full_gpu() - request full gpu access
> >>> + * @amdgpu:	amdgpu device.
> >>> + * @init:	is driver init time.
> >>> + * When start to init/fini driver, first need to request full gpu access.
> >>> + * Return: Zero if request success, otherwise will return error.
> >>> + */
> >>> +int amdgpu_virt_request_full_gpu(struct amdgpu_device *adev, bool
> >>> +init) {
> >>> +	struct amdgpu_virt *virt = &adev->virt;
> >>> +
> >>> +	if (virt->ops && virt->ops->req_full_gpu) {
> >>> +		adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME;
> >>> +		return virt->ops->req_full_gpu(adev, init);
> >> I would be conservative here and request full GPU access first and
> >> then clear AMDGPU_SRIOV_CAPS_RUNTIME.
> >>
> >> Just in case the function is called concurrently with another thread
> >> checking the caps.
> > It can't be used in parallel, the problem you said shouldn't be appear.
> >
> >> On the other hand req_full_gpu() could need the flag to handle
> >> register reads/writes correctly, but in this case I would question if
> >> we shouldn't add special macros for this.
> > We must clear RUNTIME flag so that can read/write registers with mmio,
> > Otherwise driver will hang.
> 
> Yeah, that's what I expected. Would be nice if we could better split that, e.g.
> have explicit macros for direct register write.
> 
> But that's really only nice to have, patch is ok as it is as far as I can see.

I think it is also very clear. Actually, I have a try but it is not good choice.
If anyone have good idea, can change it later.

> >
> >>
> >>
> >>> +	}
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +/**
> >>> + * amdgpu_virt_release_full_gpu() - release full gpu access
> >>> + * @amdgpu:	amdgpu device.
> >>> + * @init:	is driver init time.
> >>> + * When finishing driver init/fini, need to release full gpu access.
> >>> + * Return: Zero if release success, otherwise will returen error.
> >>> + */
> >>> +int amdgpu_virt_release_full_gpu(struct amdgpu_device *adev, bool
> >>> +init) {
> >>> +	struct amdgpu_virt *virt = &adev->virt;
> >>> +	int r;
> >>> +
> >>> +	if (virt->ops && virt->ops->rel_full_gpu) {
> >>> +		r = virt->ops->rel_full_gpu(adev, init);
> >>> +		adev->virt.caps |= AMDGPU_SRIOV_CAPS_RUNTIME;
> >>> +		return r;
> >>> +	}
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +/**
> >>> + * amdgpu_virt_reset_gpu() - reset gpu
> >>> + * @amdgpu:	amdgpu device.
> >>> + * Send reset command to GPU hypervisor to reset GPU that VM is
> >>> +using
> >>> + * Return: Zero if reset success, otherwise will return error.
> >>> + */
> >>> +int amdgpu_virt_reset_gpu(struct amdgpu_device *adev) {
> >>> +	struct amdgpu_virt *virt = &adev->virt;
> >>> +
> >>> +	if (virt->ops && virt->ops->reset_gpu) {
> >>> +		adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME;
> >>> +		return virt->ops->reset_gpu(adev);
> >>> +	}
> >>> +
> >>> +	return 0;
> >>> +}
> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
> >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
> >>> index 24f0590..3f8fc0f 100644
> >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
> >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
> >>> @@ -29,11 +29,23 @@
> >>>    #define AMDGPU_SRIOV_CAPS_IS_VF        (1 << 2) /* this GPU is a
> virtual
> >> function */
> >>>    #define AMDGPU_PASSTHROUGH_MODE        (1 << 3) /* thw whole
> GPU
> >> is pass through for VM */
> >>>    #define AMDGPU_SRIOV_CAPS_RUNTIME      (1 << 4) /* is out of full
> >> access mode */
> >>> +
> >>> +/**
> >>> + * struct amdgpu_virt_ops - amdgpu device virt operations  */
> >>> +struct amdgpu_virt_ops {
> >>> +	int (*req_full_gpu)(struct amdgpu_device *adev, bool init);
> >>> +	int (*rel_full_gpu)(struct amdgpu_device *adev, bool init);
> >>> +	int (*reset_gpu)(struct amdgpu_device *adev); };
> >>> +
> >>>    /* GPU virtualization */
> >>>    struct amdgpu_virt {
> >>>    	uint32_t		caps;
> >>>    	uint32_t		val_offs;
> >>>    	struct mutex		lock;
> >>> +
> >>> +	const struct amdgpu_virt_ops	*ops;
> >>>    };
> >>>
> >>>    #define amdgpu_sriov_enabled(adev) \ @@ -63,5 +75,8 @@ static
> >>> inline bool is_virtual_machine(void)
> >>>    void amdgpu_virt_init_setting(struct amdgpu_device *adev);
> >>>    uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev,
> >>> uint32_t
> >> reg);
> >>>    void amdgpu_virt_kiq_wreg(struct amdgpu_device *adev, uint32_t
> >>> reg, uint32_t v);
> >>> +int amdgpu_virt_request_full_gpu(struct amdgpu_device *adev, bool
> >>> +init); int amdgpu_virt_release_full_gpu(struct amdgpu_device *adev,
> >>> +bool init); int amdgpu_virt_reset_gpu(struct amdgpu_device *adev);
> >>>
> >>>    #endif
> 

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

  parent reply	other threads:[~2017-01-10 14:26 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10 10:00 [V2 00/11] Add support AMD GPU virtualization soultion Xiangliang Yu
     [not found] ` <1484042450-22987-1-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 10:00   ` [V2 01/11] drm/amdgpu/ring: add two interfaces to support r/w registers with kiq Xiangliang Yu
     [not found]     ` <1484042450-22987-2-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 15:31       ` Deucher, Alexander
2017-01-10 10:00   ` [V2 02/11] drm/amdgpu/gfx8: implement emit_rreg/wreg function Xiangliang Yu
     [not found]     ` <1484042450-22987-3-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 15:34       ` Deucher, Alexander
     [not found]         ` <BN6PR12MB165294D179EF65B87ECFCA6DF7670-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-01-10 15:46           ` Yu, Xiangliang
2017-01-10 10:00   ` [V2 03/11] drm/amdgpu/virt: add runtime flag Xiangliang Yu
     [not found]     ` <1484042450-22987-4-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 15:35       ` Deucher, Alexander
2017-01-10 10:00   ` [V2 04/11] drm/amdgpu/virt: use kiq to access registers Xiangliang Yu
     [not found]     ` <1484042450-22987-5-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 13:09       ` Christian König
     [not found]         ` <35600919-5cd3-4920-f2dd-db0e0620e3fa-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-10 14:01           ` Yu, Xiangliang
     [not found]             ` <CY4PR12MB1701B676A67A72E8B59F545FEB670-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-01-10 14:07               ` Christian König
     [not found]                 ` <623ec744-5911-9777-9271-9a221fac8821-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-10 14:14                   ` Yu, Xiangliang
2017-01-11  2:44           ` 答复: " Liu, Monk
2017-01-11  3:06           ` Liu, Monk
     [not found]             ` <BY2PR1201MB111068093D612E37CCD64DF284660-O28G1zQ8oGliQkyLPkmea2rFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-01-11  8:30               ` Liu, Monk
     [not found]                 ` <BY2PR1201MB11107ADADF57EBE79AB97D7F84660-O28G1zQ8oGliQkyLPkmea2rFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-01-11 11:48                   ` Christian König
2017-01-10 10:00   ` [V2 05/11] drm/amdgpu/virt: add high level interfaces for virt Xiangliang Yu
     [not found]     ` <1484042450-22987-6-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 13:12       ` Christian König
     [not found]         ` <486049d3-8d0f-59fd-87d7-71111f168560-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-10 13:33           ` Yu, Xiangliang
     [not found]             ` <CY4PR12MB1701636B667485FAF5260876EB670-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-01-10 13:59               ` Christian König
     [not found]                 ` <9350e215-4325-8c5e-db84-c5318aa480a2-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-10 14:26                   ` Yu, Xiangliang [this message]
2017-01-10 15:35       ` Deucher, Alexander
2017-01-10 10:00   ` [V2 06/11] drm/amdgpu/virt: implement VI virt operation interfaces Xiangliang Yu
     [not found]     ` <1484042450-22987-7-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 13:15       ` Christian König
     [not found]         ` <c2f40171-37f4-4617-b4d3-62f40d907ebc-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-10 13:20           ` Yu, Xiangliang
     [not found]             ` <CY4PR12MB1701449882D58F66699786E4EB670-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-01-10 13:29               ` Christian König
     [not found]                 ` <33a2d958-38cd-09aa-2bc2-4b3795cba4d4-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-10 13:43                   ` Yu, Xiangliang
     [not found]                     ` <CY4PR12MB170198A2080865A1E95FAF3BEB670-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-01-10 14:05                       ` Christian König
     [not found]                         ` <91042d0c-f0ad-4969-04c8-b4926a6b5d2f-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-10 14:17                           ` Yu, Xiangliang
2017-01-10 15:36       ` Deucher, Alexander
2017-01-10 10:00   ` [V2 07/11] drm/amdgpu: request/release full gpu access if device is vf Xiangliang Yu
     [not found]     ` <1484042450-22987-8-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 15:37       ` Deucher, Alexander
2017-01-10 10:00   ` [V2 08/11] drm/amdgpu/vi: add support virtualization Xiangliang Yu
     [not found]     ` <1484042450-22987-9-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 15:37       ` Deucher, Alexander
2017-01-10 10:00   ` [V2 09/11] drm/amdgpu/virt: enable virtual display Xiangliang Yu
     [not found]     ` <1484042450-22987-10-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 15:44       ` Deucher, Alexander
2017-01-10 10:00   ` [V2 10/11] drm/amdgpu/virt: disable dc Xiangliang Yu
     [not found]     ` <1484042450-22987-11-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 15:44       ` Deucher, Alexander
2017-01-10 10:00   ` [V2 11/11] drm/amdgpu: do not reset gpu for virtualization Xiangliang Yu
     [not found]     ` <1484042450-22987-12-git-send-email-Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 10:05       ` 答复: " Liu, Monk
2017-01-10 13:18       ` Christian König
     [not found]         ` <7106150a-e0e1-f904-6b00-33ee8fe5bd01-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-10 13:36           ` Yu, Xiangliang
     [not found]             ` <CY4PR12MB17016411760E74CE227A7B78EB670-rpdhrqHFk05QaJCA3gGb3wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-01-10 15:28               ` Deucher, Alexander

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=CY4PR12MB170130F7A8A89BED6606D1A9EB670@CY4PR12MB1701.namprd12.prod.outlook.com \
    --to=xiangliang.yu-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=deathsimple-ANTagKRnAhcb1SvskN2V4Q@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.