All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Joerg Roedel <joro@8bytes.org>,
	Linux IOMMU <iommu@lists.linux-foundation.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH 2/3] iommu/ipmmu-vmsa: Calculate context registers' offset instead of a macro
Date: Tue, 15 Oct 2019 05:28:00 +0000	[thread overview]
Message-ID: <TYAPR01MB4544DB942C8B4F016E043B21D8930@TYAPR01MB4544.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAMuHMdXv3ChOHO7RyOjQ0mL+9ugRFWnMUw7MfYD-9aU+ZZMSTQ@mail.gmail.com>

Hi Geert-san,

> From: Geert Uytterhoeven, Sent: Friday, October 11, 2019 9:29 PM
> 
> Hi Shimoda-san,
> 
> On Wed, Oct 9, 2019 at 10:27 AM Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> > Since we will have changed memory mapping of the IPMMU in the future,
> > this patch uses ipmmu_features values instead of a macro to
> > calculate context registers offset. No behavior change.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/iommu/ipmmu-vmsa.c
> > +++ b/drivers/iommu/ipmmu-vmsa.c
> > @@ -50,6 +50,8 @@ struct ipmmu_features {
> >         bool twobit_imttbcr_sl0;
> >         bool reserved_context;
> >         bool cache_snoop;
> > +       u32 ctx_offset_base;
> > +       u32 ctx_offset_stride;
> >  };
> >
> >  struct ipmmu_vmsa_device {
> > @@ -99,8 +101,6 @@ static struct ipmmu_vmsa_device *to_ipmmu(struct device *dev)
> >
> >  #define IM_NS_ALIAS_OFFSET             0x800
> >
> > -#define IM_CTX_SIZE                    0x40
> > -
> >  #define IMCTR                          0x0000
> >  #define IMCTR_TRE                      (1 << 17)
> >  #define IMCTR_AFE                      (1 << 16)
> > @@ -253,18 +253,25 @@ static void ipmmu_write(struct ipmmu_vmsa_device *mmu, unsigned int offset,
> >         iowrite32(data, mmu->base + offset);
> >  }
> >
> > +static u32 ipmmu_ctx_reg(struct ipmmu_vmsa_device *mmu, unsigned int context_id,
> > +                        unsigned int reg)
> > +{
> > +       return mmu->features->ctx_offset_base +
> > +              context_id * mmu->features->ctx_offset_stride + reg;
> > +}
> > +
> >  static u32 ipmmu_ctx_read_root(struct ipmmu_vmsa_domain *domain,
> >                                unsigned int reg)
> >  {
> >         return ipmmu_read(domain->mmu->root,
> > -                         domain->context_id * IM_CTX_SIZE + reg);
> > +                         ipmmu_ctx_reg(domain->mmu, domain->context_id, reg));
> 
> For consistency:
> 
>     ipmmu_ctx_reg(domain->mmu->root, ...)
> 
> but in practice the features for domain->mmu and domain->mmu->root are
> identical anyway.
> 
> >  }
> >
> >  static void ipmmu_ctx_write_root(struct ipmmu_vmsa_domain *domain,
> >                                  unsigned int reg, u32 data)
> >  {
> >         ipmmu_write(domain->mmu->root,
> > -                   domain->context_id * IM_CTX_SIZE + reg, data);
> > +                   ipmmu_ctx_reg(domain->mmu, domain->context_id, reg), data);
> 
> Likewise:
> 
>     ipmmu_ctx_reg(domain->mmu->root, ...)?

Thank you for the comments! Yes, we can use domain->mmu->root to ipmmu_ctx_reg()
because ipmmu_ctx_reg() only use mmu->features.

> I find these ipmmu_{read,write}() a bit hard too read, with passing the
> mmu to both ipmmu_{read,write}() and ipmmu_ctx_reg().

I completely agree.

> What do you think about providing two helpers ipmmu_ctx_{read,write}(),
> so all users can just use e.g.
> 
>     ipmmu_ctx_write(mmu, context_id, reg, data);
> 
> instead of
> 
>     ipmmu_write(mmu, ipmmu_ctx_reg(mmu, context_id, reg), data);
> 
> ?

I think so. I'll fix it. Perhaps, I'll make a patch which changes
the function name at first.

Best regards,
Yoshihiro Shimoda

> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	Linux IOMMU <iommu@lists.linux-foundation.org>
Subject: RE: [PATCH 2/3] iommu/ipmmu-vmsa: Calculate context registers' offset instead of a macro
Date: Tue, 15 Oct 2019 05:28:00 +0000	[thread overview]
Message-ID: <TYAPR01MB4544DB942C8B4F016E043B21D8930@TYAPR01MB4544.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAMuHMdXv3ChOHO7RyOjQ0mL+9ugRFWnMUw7MfYD-9aU+ZZMSTQ@mail.gmail.com>

Hi Geert-san,

> From: Geert Uytterhoeven, Sent: Friday, October 11, 2019 9:29 PM
> 
> Hi Shimoda-san,
> 
> On Wed, Oct 9, 2019 at 10:27 AM Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> > Since we will have changed memory mapping of the IPMMU in the future,
> > this patch uses ipmmu_features values instead of a macro to
> > calculate context registers offset. No behavior change.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/iommu/ipmmu-vmsa.c
> > +++ b/drivers/iommu/ipmmu-vmsa.c
> > @@ -50,6 +50,8 @@ struct ipmmu_features {
> >         bool twobit_imttbcr_sl0;
> >         bool reserved_context;
> >         bool cache_snoop;
> > +       u32 ctx_offset_base;
> > +       u32 ctx_offset_stride;
> >  };
> >
> >  struct ipmmu_vmsa_device {
> > @@ -99,8 +101,6 @@ static struct ipmmu_vmsa_device *to_ipmmu(struct device *dev)
> >
> >  #define IM_NS_ALIAS_OFFSET             0x800
> >
> > -#define IM_CTX_SIZE                    0x40
> > -
> >  #define IMCTR                          0x0000
> >  #define IMCTR_TRE                      (1 << 17)
> >  #define IMCTR_AFE                      (1 << 16)
> > @@ -253,18 +253,25 @@ static void ipmmu_write(struct ipmmu_vmsa_device *mmu, unsigned int offset,
> >         iowrite32(data, mmu->base + offset);
> >  }
> >
> > +static u32 ipmmu_ctx_reg(struct ipmmu_vmsa_device *mmu, unsigned int context_id,
> > +                        unsigned int reg)
> > +{
> > +       return mmu->features->ctx_offset_base +
> > +              context_id * mmu->features->ctx_offset_stride + reg;
> > +}
> > +
> >  static u32 ipmmu_ctx_read_root(struct ipmmu_vmsa_domain *domain,
> >                                unsigned int reg)
> >  {
> >         return ipmmu_read(domain->mmu->root,
> > -                         domain->context_id * IM_CTX_SIZE + reg);
> > +                         ipmmu_ctx_reg(domain->mmu, domain->context_id, reg));
> 
> For consistency:
> 
>     ipmmu_ctx_reg(domain->mmu->root, ...)
> 
> but in practice the features for domain->mmu and domain->mmu->root are
> identical anyway.
> 
> >  }
> >
> >  static void ipmmu_ctx_write_root(struct ipmmu_vmsa_domain *domain,
> >                                  unsigned int reg, u32 data)
> >  {
> >         ipmmu_write(domain->mmu->root,
> > -                   domain->context_id * IM_CTX_SIZE + reg, data);
> > +                   ipmmu_ctx_reg(domain->mmu, domain->context_id, reg), data);
> 
> Likewise:
> 
>     ipmmu_ctx_reg(domain->mmu->root, ...)?

Thank you for the comments! Yes, we can use domain->mmu->root to ipmmu_ctx_reg()
because ipmmu_ctx_reg() only use mmu->features.

> I find these ipmmu_{read,write}() a bit hard too read, with passing the
> mmu to both ipmmu_{read,write}() and ipmmu_ctx_reg().

I completely agree.

> What do you think about providing two helpers ipmmu_ctx_{read,write}(),
> so all users can just use e.g.
> 
>     ipmmu_ctx_write(mmu, context_id, reg, data);
> 
> instead of
> 
>     ipmmu_write(mmu, ipmmu_ctx_reg(mmu, context_id, reg), data);
> 
> ?

I think so. I'll fix it. Perhaps, I'll make a patch which changes
the function name at first.

Best regards,
Yoshihiro Shimoda

> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2019-10-15  5:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09  8:26 [PATCH 0/3] iommu/ipmmu-vmsa: minor updates Yoshihiro Shimoda
2019-10-09  8:26 ` Yoshihiro Shimoda
2019-10-09  8:26 ` [PATCH 1/3] iommu/ipmmu-vmsa: Remove some unused register declarations Yoshihiro Shimoda
2019-10-09  8:26   ` Yoshihiro Shimoda
2019-10-09 21:03   ` Niklas Söderlund
2019-10-09 21:03     ` Niklas Söderlund
2019-10-11 12:10   ` Geert Uytterhoeven
2019-10-11 12:10     ` Geert Uytterhoeven
2019-10-15  5:17     ` Yoshihiro Shimoda
2019-10-15  5:17       ` Yoshihiro Shimoda
2019-10-09  8:26 ` [PATCH 2/3] iommu/ipmmu-vmsa: Calculate context registers' offset instead of a macro Yoshihiro Shimoda
2019-10-09  8:26   ` Yoshihiro Shimoda
2019-10-09 21:13   ` Niklas Söderlund
2019-10-09 21:13     ` Niklas Söderlund
2019-10-11 12:29   ` Geert Uytterhoeven
2019-10-11 12:29     ` Geert Uytterhoeven
2019-10-15  5:28     ` Yoshihiro Shimoda [this message]
2019-10-15  5:28       ` Yoshihiro Shimoda
2019-10-09  8:26 ` [PATCH 3/3] iommu/ipmmu-vmsa: Add utlb_offset_base Yoshihiro Shimoda
2019-10-09  8:26   ` Yoshihiro Shimoda
2019-10-09 22:28   ` Niklas Söderlund
2019-10-09 22:28     ` Niklas Söderlund
2019-10-11 12:32   ` Geert Uytterhoeven
2019-10-11 12:32     ` Geert Uytterhoeven
2019-10-15  5:28     ` Yoshihiro Shimoda
2019-10-15  5:28       ` Yoshihiro Shimoda

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=TYAPR01MB4544DB942C8B4F016E043B21D8930@TYAPR01MB4544.jpnprd01.prod.outlook.com \
    --to=yoshihiro.shimoda.uh@renesas.com \
    --cc=geert@linux-m68k.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-renesas-soc@vger.kernel.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.