All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
To: "Liu, Monk" <Monk.Liu-5C7GfCeVMHo@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: 答复: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines
Date: Mon, 16 Jan 2017 11:50:23 +0100	[thread overview]
Message-ID: <d6a5c11f-713a-d2f5-f620-cfae5e4e2423@vodafone.de> (raw)
In-Reply-To: <BY2PR1201MB111021CE95196ED42C7694E4847D0-O28G1zQ8oGliQkyLPkmea2rFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 7077 bytes --]

That is perfectly fine as long as you add the code using it in the same 
set of patches.

What we should avoid is adding a lot of code and then not using for for 
quite some time, that get certainly removed sooner or later.

Regards,
Christian.

Am 16.01.2017 um 09:20 schrieb Liu, Monk:
>
> if ring_write_multiple is organized in a separate patch, doesn't it 
> introduces an function that no client using it ??
>
>
> fine by me although ...
>
>
> BR Monk
>
> ------------------------------------------------------------------------
> *发件人:* Christian König <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
> *发送时间:* 2017年1月12日 20:27:48
> *收件人:* Liu, Monk; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> *主题:* Re: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines
> Am 12.01.2017 um 08:41 schrieb Monk Liu:
> > Change-Id: I66007a7f7e4e27fb129121f36143dce3cfb43738
> > Signed-off-by: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
> > ---
> >   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 {
>
> Coding style says when either the "if" or the "else" branch uses "{" and
> "}" both should use them.
>
> I think even better would be to use a return statement in the "if",
> cause this is just checking the prerequisites for errors.
>
> Additional to that adding this function should be a separate patch.
>
> Christian.
>
> > +             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;
> > +     }
> > +}
> > +
> >   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);
> > +}
>
>


[-- Attachment #1.2: Type: text/html, Size: 12904 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

  parent reply	other threads:[~2017-01-16 10:50 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 [this message]
2017-01-13 16:28       ` Alex Deucher
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=d6a5c11f-713a-d2f5-f620-cfae5e4e2423@vodafone.de \
    --to=deathsimple-antagkrnahcb1svskn2v4q@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.