From: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Wan Zongshun <vw-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Ray Huang <ray.huang-5C7GfCeVMHo@public.gmane.org>
Subject: Re: [Patch v3 05/12] iommu/amd: change IOMMU_PTE_P to IOMMU_PTE_V
Date: Fri, 29 Jan 2016 11:12:40 +0800 [thread overview]
Message-ID: <20160129031240.GA2506@x1.redhat.com> (raw)
In-Reply-To: <56AAD4B8.8050701-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
On 01/29/16 at 10:55am, Wan Zongshun wrote:
>
>
> -------- Original Message --------
> >On 01/27/16 at 06:18pm, Wan Zongshun wrote:
> >>
> >>
> >>-------- Original Message --------
> >>>In amd-vi spec the name of bit0 in DTE is V. But in code it's defined
> >>>as IOMMU_PTE_P. Here change it to IOMMU_PTE_V to make it be consistent
> >>>with spec.
> >>
> >>Hi, Baoquan
> >>
> >>This should be PR bit which means present, So maybe you got
> >>confusion between DTE and PTE table, right?
> >
> >Well, I got it. In fact the MACRO definition and current code confused
> >me. IOMMU_PTE_P is not only used for PTE table, but used for DTE entry.
> >
> >You can check functions set_dte_entry()/clear_dte_entry() where
> >IOMMU_PTE_P and IOMMU_PTE_TV are set in DTE entry to indicate the DTE
> >entry and translation is valid. Meanwhile I saw in iommu_map_page
> >IOMMU_PTE_P is used to incidate pte is present. This makes us confused. I
> >will post a patch to clean up this, defining new specific MACRO for DTE
> >use only. Do you agree on this?
> >
>
> Baoquan,
>
> It is fine to me, is it better to add a lot of explanation for those
> bits MACRO? like:
>
> /* PTE bit value definition*/
> #define IOMMU_PTE_P (1ULL << 0)
> #define IOMMU_PTE_TV (1ULL << 1)
>
> /* DTE bit value definition*/
> #define IOMMU_DTE_TV (1ULL << 1)
Agree. It makes sense to make code more read-able. Will add.
>
> >>
> >>So please don't change the IOMMU_PTE_P to IOMMU_PTE_V firstly, maybe
> >>you should rename IOMMU_PTE_TV to IOMMU_DTE_TV, or just keep those
> >>codes here, does make sense?
> >
> >As you said, IOMMU_PTE_P need be kept, also IOMMU_DTE_V/IOMMU_DTE_TV are
> >also necessary to re-define separately.
> >>
> >>Vincent.
> >>
> >>>
> >>>Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> >>>---
> >>> drivers/iommu/amd_iommu.c | 10 +++++-----
> >>> drivers/iommu/amd_iommu_types.h | 6 +++---
> >>> 2 files changed, 8 insertions(+), 8 deletions(-)
> >>>
> >>>diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
> >>>index 63f4c6b..f02d4b1 100644
> >>>--- a/drivers/iommu/amd_iommu.c
> >>>+++ b/drivers/iommu/amd_iommu.c
> >>>@@ -1331,9 +1331,9 @@ static int iommu_map_page(struct protection_domain *dom,
> >>>
> >>> if (count > 1) {
> >>> __pte = PAGE_SIZE_PTE(phys_addr, page_size);
> >>>- __pte |= PM_LEVEL_ENC(7) | IOMMU_PTE_P | IOMMU_PTE_FC;
> >>>+ __pte |= PM_LEVEL_ENC(7) | IOMMU_PTE_V | IOMMU_PTE_FC;
> >>> } else
> >>>- __pte = phys_addr | IOMMU_PTE_P | IOMMU_PTE_FC;
> >>>+ __pte = phys_addr | IOMMU_PTE_V | IOMMU_PTE_FC;
> >>>
> >>> if (prot & IOMMU_PROT_IR)
> >>> __pte |= IOMMU_PTE_IR;
> >>>@@ -1978,7 +1978,7 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats)
> >>>
> >>> pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK)
> >>> << DEV_ENTRY_MODE_SHIFT;
> >>>- pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | IOMMU_PTE_TV;
> >>>+ pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_V | IOMMU_PTE_TV;
> >>>
> >>> flags = amd_iommu_dev_table[devid].data[1];
> >>>
> >>>@@ -2021,7 +2021,7 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats)
> >>> static void clear_dte_entry(u16 devid)
> >>> {
> >>> /* remove entry from the device table seen by the hardware */
> >>>- amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_P | IOMMU_PTE_TV;
> >>>+ amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_V | IOMMU_PTE_TV;
> >>> amd_iommu_dev_table[devid].data[1] &= DTE_FLAG_MASK;
> >>>
> >>> amd_iommu_apply_erratum_63(devid);
> >>>@@ -2463,7 +2463,7 @@ static dma_addr_t dma_ops_domain_map(struct dma_ops_domain *dom,
> >>> if (!pte)
> >>> return DMA_ERROR_CODE;
> >>>
> >>>- __pte = paddr | IOMMU_PTE_P | IOMMU_PTE_FC;
> >>>+ __pte = paddr | IOMMU_PTE_V | IOMMU_PTE_FC;
> >>>
> >>> if (direction == DMA_TO_DEVICE)
> >>> __pte |= IOMMU_PTE_IR;
> >>>diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
> >>>index 9b8ace4..65f7988 100644
> >>>--- a/drivers/iommu/amd_iommu_types.h
> >>>+++ b/drivers/iommu/amd_iommu_types.h
> >>>@@ -244,7 +244,7 @@
> >>> #define PM_LEVEL_INDEX(x, a) (((a) >> PM_LEVEL_SHIFT((x))) & 0x1ffULL)
> >>> #define PM_LEVEL_ENC(x) (((x) << 9) & 0xe00ULL)
> >>> #define PM_LEVEL_PDE(x, a) ((a) | PM_LEVEL_ENC((x)) | \
> >>>- IOMMU_PTE_P | IOMMU_PTE_IR | IOMMU_PTE_IW)
> >>>+ IOMMU_PTE_V | IOMMU_PTE_IR | IOMMU_PTE_IW)
> >>> #define PM_PTE_LEVEL(pte) (((pte) >> 9) & 0x7ULL)
> >>>
> >>> #define PM_MAP_4k 0
> >>>@@ -293,7 +293,7 @@
> >>> #define PTE_LEVEL_PAGE_SIZE(level) \
> >>> (1ULL << (12 + (9 * (level))))
> >>>
> >>>-#define IOMMU_PTE_P (1ULL << 0)
> >>>+#define IOMMU_PTE_V (1ULL << 0)
> >>> #define IOMMU_PTE_TV (1ULL << 1)
> >>> #define IOMMU_PTE_U (1ULL << 59)
> >>> #define IOMMU_PTE_FC (1ULL << 60)
> >>>@@ -321,7 +321,7 @@
> >>> #define GCR3_VALID 0x01ULL
> >>>
> >>> #define IOMMU_PAGE_MASK (((1ULL << 52) - 1) & ~0xfffULL)
> >>>-#define IOMMU_PTE_PRESENT(pte) ((pte) & IOMMU_PTE_P)
> >>>+#define IOMMU_PTE_PRESENT(pte) ((pte) & IOMMU_PTE_V)
> >>> #define IOMMU_PTE_PAGE(pte) (phys_to_virt((pte) & IOMMU_PAGE_MASK))
> >>> #define IOMMU_PTE_MODE(pte) (((pte) >> 9) & 0x07)
> >>>
> >>>
> >
next prev parent reply other threads:[~2016-01-29 3:12 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 10:29 [Patch v3 00/12] Fix AMD IOMMU faults in kdump kernel Baoquan He
[not found] ` <1453804166-25646-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-26 10:29 ` [Patch v3 01/12] iommu/amd: Use standard bitmap operation to set bitmap Baoquan He
2016-01-26 10:29 ` [Patch v3 02/12] iommu/amd: Detect pre enabled translation Baoquan He
2016-01-26 10:29 ` [Patch v3 03/12] iommu/amd: move dte irq macro defitions to amd_iommu_types.h Baoquan He
[not found] ` <1453804166-25646-4-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 10:25 ` Wan Zongshun
[not found] ` <56A89B1F.6010004-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28 9:50 ` Baoquan He
2016-01-26 10:29 ` [Patch v3 04/12] iommu/amd: add copy_irq_table function Baoquan He
[not found] ` <1453804166-25646-5-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 11:23 ` Wan Zongshun
[not found] ` <56A8A896.70405-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28 9:52 ` Baoquan He
2016-01-26 10:29 ` [Patch v3 05/12] iommu/amd: change IOMMU_PTE_P to IOMMU_PTE_V Baoquan He
[not found] ` <1453804166-25646-6-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 10:18 ` Wan Zongshun
[not found] ` <56A89981.5010007-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28 10:05 ` Baoquan He
[not found] ` <20160128100533.GD3851-ejN7fcUYdH/by3iVrkZq2A@public.gmane.org>
2016-01-29 2:55 ` Wan Zongshun
[not found] ` <56AAD4B8.8050701-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-29 3:12 ` Baoquan He [this message]
2016-01-26 10:29 ` [Patch v3 06/12] iommu/amd: Clean up the useless IOMMU_PTE_U/IOMMU_PTE_FC Baoquan He
[not found] ` <1453804166-25646-7-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 10:22 ` Wan Zongshun
[not found] ` <56A89A74.6060501-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28 10:30 ` Baoquan He
2016-01-26 10:29 ` [Patch v3 07/12] iommu/amd: Add function copy_dev_tables Baoquan He
2016-01-26 10:29 ` [Patch v3 08/12] iommu/amd: set the device table and re-enable event/cmd buffer Baoquan He
2016-01-26 10:29 ` [Patch v3 09/12] iommu/amd: Don't update the domain information to iommu dev before dev init Baoquan He
2016-01-26 10:29 ` [Patch v3 10/12] iommu/amd: Update related domain info to dev when dev driver init Baoquan He
2016-01-26 10:29 ` [Patch v3 11/12] iommu/amd: No need to wait iommu completion if no dte irq entry change Baoquan He
[not found] ` <1453804166-25646-12-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 11:03 ` Wan Zongshun
[not found] ` <56A8A3EC.7090701-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28 10:24 ` Baoquan He
[not found] ` <20160128102401.GE3851-ejN7fcUYdH/by3iVrkZq2A@public.gmane.org>
2016-01-29 2:57 ` Wan Zongshun
2016-01-26 10:29 ` [Patch v3 12/12] iommu/amd: fix a code bug in do_attach Baoquan He
[not found] ` <1453804166-25646-13-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-26 10:51 ` Baoquan He
2016-01-26 10:48 ` [Patch v3 00/12] Fix AMD IOMMU faults in kdump kernel Baoquan He
2016-01-26 10:52 ` Baoquan He
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=20160129031240.GA2506@x1.redhat.com \
--to=bhe-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=ray.huang-5C7GfCeVMHo@public.gmane.org \
--cc=vw-6ukY98dZOFrYtjvyW6yDsg@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.