All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Alex Deucher <alexander.deucher@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Hawking Zhang <Hawking.Zhang@amd.com>
Subject: Re: [PATCH 1/2] drm/amdgpu: Add graphics cache rinse packet for sdma 5.0
Date: Tue, 4 May 2021 16:08:29 +0200	[thread overview]
Message-ID: <72bdad30-4e73-3f44-b81e-2a8aa16235bd@gmail.com> (raw)
In-Reply-To: <20210504140211.1703369-1-alexander.deucher@amd.com>

Am 04.05.21 um 16:02 schrieb Alex Deucher:
> Add emit mem sync callback for sdma_v5_0
>
> In amdgpu sync object test, three threads created jobs
> to send GFX IB and SDMA IB in sequence. After the first
> GFX thread joined, sometimes the third thread will reuse
> the same physical page to store the SDMA IB. There will
> be a risk that SDMA will read GFX IB in the previous physical
> page. So it's better to flush the cache before commit sdma IB.
>
> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

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

> ---
>   drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 28 ++++++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> index 920fc6d4a127..d294ef6a625a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> @@ -437,6 +437,33 @@ static void sdma_v5_0_ring_emit_ib(struct amdgpu_ring *ring,
>   	amdgpu_ring_write(ring, upper_32_bits(csa_mc_addr));
>   }
>   
> +/**
> + * sdma_v5_0_ring_emit_mem_sync - flush the IB by graphics cache rinse
> + *
> + * @ring: amdgpu ring pointer
> + * @job: job to retrieve vmid from
> + * @ib: IB object to schedule
> + *
> + * flush the IB by graphics cache rinse.
> + */
> +static void sdma_v5_0_ring_emit_mem_sync(struct amdgpu_ring *ring)
> +{
> +    uint32_t gcr_cntl =
> +		    SDMA_GCR_GL2_INV | SDMA_GCR_GL2_WB | SDMA_GCR_GLM_INV |
> +			SDMA_GCR_GL1_INV | SDMA_GCR_GLV_INV | SDMA_GCR_GLK_INV |
> +			SDMA_GCR_GLI_INV(1);
> +
> +	/* flush entire cache L0/L1/L2, this can be optimized by performance requirement */
> +	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_GCR_REQ));
> +	amdgpu_ring_write(ring, SDMA_PKT_GCR_REQ_PAYLOAD1_BASE_VA_31_7(0));
> +	amdgpu_ring_write(ring, SDMA_PKT_GCR_REQ_PAYLOAD2_GCR_CONTROL_15_0(gcr_cntl) |
> +			SDMA_PKT_GCR_REQ_PAYLOAD2_BASE_VA_47_32(0));
> +	amdgpu_ring_write(ring, SDMA_PKT_GCR_REQ_PAYLOAD3_LIMIT_VA_31_7(0) |
> +			SDMA_PKT_GCR_REQ_PAYLOAD3_GCR_CONTROL_18_16(gcr_cntl >> 16));
> +	amdgpu_ring_write(ring, SDMA_PKT_GCR_REQ_PAYLOAD4_LIMIT_VA_47_32(0) |
> +			SDMA_PKT_GCR_REQ_PAYLOAD4_VMID(0));
> +}
> +
>   /**
>    * sdma_v5_0_ring_emit_hdp_flush - emit an hdp flush on the DMA ring
>    *
> @@ -1643,6 +1670,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = {
>   		10 + 10 + 10, /* sdma_v5_0_ring_emit_fence x3 for user fence, vm fence */
>   	.emit_ib_size = 5 + 7 + 6, /* sdma_v5_0_ring_emit_ib */
>   	.emit_ib = sdma_v5_0_ring_emit_ib,
> +	.emit_mem_sync = sdma_v5_0_ring_emit_mem_sync,
>   	.emit_fence = sdma_v5_0_ring_emit_fence,
>   	.emit_pipeline_sync = sdma_v5_0_ring_emit_pipeline_sync,
>   	.emit_vm_flush = sdma_v5_0_ring_emit_vm_flush,

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

      parent reply	other threads:[~2021-05-04 14:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04 14:02 [PATCH 1/2] drm/amdgpu: Add graphics cache rinse packet for sdma 5.0 Alex Deucher
2021-05-04 14:02 ` [PATCH 2/2] drm/amdgpu: drop the GCR packet from the emit_ib frame for sdma5.0 Alex Deucher
2021-05-04 14:20   ` Zhang, Hawking
2021-05-04 14:08 ` Christian König [this message]

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=72bdad30-4e73-3f44-b81e-2a8aa16235bd@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Hawking.Zhang@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.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.