All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
Cc: amd-gfx list <amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines
Date: Fri, 13 Jan 2017 11:28:01 -0500	[thread overview]
Message-ID: <CADnq5_NciQ5i687sw8ybM+uQY0_v0mKyv=tz-HvXYbiAyxWDdQ@mail.gmail.com> (raw)
In-Reply-To: <1484206893-18806-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>

On Thu, Jan 12, 2017 at 2:41 AM, Monk Liu <Monk.Liu@amd.com> wrote:
> Change-Id: I66007a7f7e4e27fb129121f36143dce3cfb43738
> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h   | 31 ++++++++++++++++++
>  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 61 +++++++++++++++++++++++++++++++++++
>  2 files changed, 92 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index e9983fb..2039da7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1599,6 +1599,37 @@ static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)
>         ring->count_dw--;
>  }
>
> +static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, void *src, int count_dw)
> +{
> +       unsigned occupied, chunk1, chunk2;
> +       void *dst;
> +
> +       if (ring->count_dw < count_dw)
> +               DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n");
> +       else {

Parens coding style as noted by Christian.  Also, this behavior
differs from amdgpu_ring_write() which completes the writes anyway.

> +               occupied = ring->wptr & ring->ptr_mask;
> +               dst = (void *)&ring->ring[occupied];
> +               chunk1 = ring->ptr_mask + 1 - occupied;
> +               chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1;
> +               chunk2 = count_dw - chunk1;
> +               chunk1 <<= 2;
> +               chunk2 <<= 2;
> +               if (chunk1) {
> +                       memcpy(dst, src, chunk1);
> +               }
> +
> +               if (chunk2) {
> +                       src += chunk1;
> +                       dst = (void *)ring->ring;
> +                       memcpy(dst, src, chunk2);
> +               }
> +
> +               ring->wptr += count_dw;
> +               ring->wptr &= ring->ptr_mask;
> +               ring->count_dw -= count_dw;
> +       }
> +}
> +

This hunk should be a separate patch.


>  static inline struct amdgpu_sdma_instance *
>  amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
>  {
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> index 375784d..3e8cff3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> @@ -657,6 +657,8 @@ static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev);
>  static void gfx_v8_0_set_rlc_funcs(struct amdgpu_device *adev);
>  static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev);
>  static void gfx_v8_0_get_cu_info(struct amdgpu_device *adev);
> +static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t addr);
> +static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t addr);
>
>  static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev)
>  {
> @@ -7212,3 +7214,62 @@ const struct amdgpu_ip_block_version gfx_v8_1_ip_block =
>         .rev = 0,
>         .funcs = &gfx_v8_0_ip_funcs,
>  };
> +
> +static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr)
> +{
> +       uint64_t ce_payload_addr;
> +       int cnt_ce;
> +       static union {
> +               struct amdgpu_ce_ib_state regular;
> +               struct amdgpu_ce_ib_state_chained_ib chained;
> +       } ce_payload = {0};
> +
> +       if (ring->adev->virt.chained_ib_support) {
> +               ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, ce_payload);
> +               cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2;
> +       } else {
> +               ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, ce_payload);
> +               cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2;
> +       }
> +
> +       amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_ce));
> +       amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
> +                               WRITE_DATA_DST_SEL(8) |
> +                               WR_CONFIRM) |
> +                               WRITE_DATA_CACHE_POLICY(0));
> +       amdgpu_ring_write(ring, lower_32_bits(ce_payload_addr));
> +       amdgpu_ring_write(ring, upper_32_bits(ce_payload_addr));
> +       amdgpu_ring_write_multiple(ring, (void *)&ce_payload, cnt_ce - 2);
> +}
> +
> +static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr)
> +{
> +       uint64_t de_payload_addr, gds_addr;
> +       int cnt_de;
> +       static union {
> +               struct amdgpu_de_ib_state regular;
> +               struct amdgpu_de_ib_state_chained_ib chained;
> +       } de_payload = {0};
> +
> +       gds_addr = csa_addr + 4096;
> +       if (ring->adev->virt.chained_ib_support) {
> +               de_payload.chained.gds_backup_addrlo = lower_32_bits(gds_addr);
> +               de_payload.chained.gds_backup_addrhi = upper_32_bits(gds_addr);
> +               de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, de_payload);
> +               cnt_de = (sizeof(de_payload.chained) >> 2) + 4 - 2;
> +       } else {
> +               de_payload.regular.gds_backup_addrlo = lower_32_bits(gds_addr);
> +               de_payload.regular.gds_backup_addrhi = upper_32_bits(gds_addr);
> +               de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, de_payload);
> +               cnt_de = (sizeof(de_payload.regular) >> 2) + 4 - 2;
> +       }
> +
> +       amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_de));
> +       amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
> +                               WRITE_DATA_DST_SEL(8) |
> +                               WR_CONFIRM) |
> +                               WRITE_DATA_CACHE_POLICY(0));
> +       amdgpu_ring_write(ring, lower_32_bits(de_payload_addr));
> +       amdgpu_ring_write(ring, upper_32_bits(de_payload_addr));
> +       amdgpu_ring_write_multiple(ring, (void *)&de_payload, cnt_de - 2);
> +}
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-01-13 16:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12  7:41 [PATCH 0/3] GFX8's meta-data write feature for SRIOV Monk Liu
     [not found] ` <1484206893-18806-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-12  7:41   ` [PATCH 1/3] drm/amdgpu:add META_DATA struct for CSA/SRIOV Monk Liu
2017-01-12  7:41   ` [PATCH 2/3] drm/amdgpu:implement META-DATA write routines Monk Liu
     [not found]     ` <1484206893-18806-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-12 12:27       ` Christian König
     [not found]         ` <b750813c-5af3-5353-2f08-5b54e0495375-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-16  8:20           ` 答复: " Liu, Monk
     [not found]             ` <BY2PR1201MB111021CE95196ED42C7694E4847D0-O28G1zQ8oGliQkyLPkmea2rFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-01-16 10:50               ` Christian König
2017-01-13 16:28       ` Alex Deucher [this message]
2017-01-12  7:41   ` [PATCH 3/3] drm/amdgpu:invoke meta-data write around cntx_cntl Monk Liu
     [not found]     ` <1484206893-18806-4-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-13 16:28       ` Alex Deucher
     [not found]         ` <CADnq5_Pe=z1hG9RBXPZ1KGfPHEHqksm9PBJdfeNdKsQDOK59eQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-13 16:35           ` Alex Deucher
     [not found]             ` <CADnq5_M3ig9C3N7V6B=5n3XJ8eYy5foucWtG+3V3LqSL80uR2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-16  8:21               ` 答复: " Liu, Monk

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='CADnq5_NciQ5i687sw8ybM+uQY0_v0mKyv=tz-HvXYbiAyxWDdQ@mail.gmail.com' \
    --to=alexdeucher-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Monk.Liu-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@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.