mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: Fenghua Yu <fenghua.yu@intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	"'Linus Torvalds'" <torvalds@linux-foundation.org>,
	"'Stephen Rothwell'" <sfr@canb.auug.org.au>,
	"'Andrew Morton'" <akpm@linux-foundation.org>,
	"'Ingo Molnar'" <mingo@elte.hu>,
	"'Christopher Wright'" <chrisw@redhat.com>,
	"'Allen Kay'" <allen.m.kay@intel.com>,
	"'iommu'" <iommu@lists.linux-foundation.org>,
	"'lkml'" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] IOMMU Identity Mapping Support: Intel IOMMU implementation
Date: Thu, 18 Jun 2009 12:15:36 -0700	[thread overview]
Message-ID: <20090618191536.GD19771@sequoia.sous-sol.org> (raw)
In-Reply-To: <20090618180527.GA24078@linux-os.sc.intel.com>

* Fenghua Yu (fenghua.yu@intel.com) wrote:
> IOMMU Identity Mapping Support: Intel IOMMU implementation

BTW, this doesn't apply at all to Linus' current tree, and does w/ minor
fuzz and offset to David's VT-d tree.

Some quick feedback.

> @@ -1189,48 +1207,74 @@ void free_dmar_iommu(struct intel_iommu *iommu)
>  	free_context_table(iommu);
>  }
>  
> -static struct dmar_domain * iommu_alloc_domain(struct intel_iommu *iommu)
> +/* Sequential domain id starting from 0. */
> +static unsigned long domain_id;

This doesn't look SMP safe.

> +static int iommu_prepare_static_identity_mapping(void)
> +{
> +	int i;
> +	struct pci_dev *pdev = NULL;
> +	int ret;
> +
> +	ret = si_domain_init();
> +	if (ret)
> +		return -EFAULT;
> +
> +	printk(KERN_INFO "IOMMU: Setting identity map:\n");
> +	for_each_pci_dev(pdev) {
> +		/* Devices not in the identity list won't do identity map. */
> +		if (!identity_list(pdev))
> +			continue;
> +
> +		for (i = 0; i < e820.nr_map; i++) {
> +			struct e820entry *ei = &e820.map[i];
> +
> +			if (ei->type == E820_RAM) {
> +				ret = iommu_prepare_identity_map(pdev,

What about RMRR?

And in this mode,  you shouldn't need gfx workaround.

> +					ei->addr, ei->addr + ei->size);
> +				if (ret)  {
> +					printk(KERN_INFO "1:1 mapping to one domain failed.\n");
> +					return -EFAULT;
> +				}
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +int __init init_dmars(void)
>  {
>  	struct dmar_drhd_unit *drhd;
>  	struct dmar_rmrr_unit *rmrr;
> @@ -2076,6 +2206,7 @@ static int __init init_dmars(void)
>  		}
>  	}
>  
> +
>  	/*
>  	 * If pass through is set and enabled, context entries of all pci
>  	 * devices are intialized by pass through translation type.
> @@ -2093,6 +2224,9 @@ static int __init init_dmars(void)
>  	 * identity mappings for rmrr, gfx, and isa.
>  	 */
>  	if (!iommu_pass_through) {
> +		if (iommu_identity_mapping)
> +			iommu_prepare_static_identity_mapping();
> +
>  		/*
>  		 * For each rmrr
>  		 *   for each dev attached to rmrr
> @@ -2107,6 +2241,7 @@ static int __init init_dmars(void)
>  		 *    endfor
>  		 * endfor
>  		 */

...Ah, RMRR looks OK.

> +		printk(KERN_INFO "IOMMU: Setting RMRR:\n");
>  		for_each_rmrr_units(rmrr) {
>  			for (i = 0; i < rmrr->devices_cnt; i++) {
>  				pdev = rmrr->devices[i];
> @@ -2259,6 +2394,9 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
>  	int ret;
>  	struct intel_iommu *iommu;
>  
> +	if (identity_list(pdev))
> +		return paddr;
> +

This is same as DUMMY_DEVICE_DOMAIN_INFO.  Please consolidate to a test
that just says "do i need translation".

And what about DMA mask smaller than physical memory.  The PT mode drops
back to swiotlb iirc.


>  	BUG_ON(dir == DMA_NONE);
>  	if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
>  		return paddr;
> @@ -2401,6 +2539,9 @@ static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr,
>  	struct iova *iova;
>  	struct intel_iommu *iommu;
>  
> +	if (identity_list(pdev))
> +		return;
> +

Same...duplicate test

>  	if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
>  		return;
>  	domain = find_domain(pdev);
> @@ -2492,6 +2633,9 @@ static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist,
>  	struct scatterlist *sg;
>  	struct intel_iommu *iommu;
>  
> +	if (identity_list(pdev))
> +		return;
> +

Same duplicate test

>  	if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
>  		return;
>  
> @@ -2552,6 +2696,16 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int ne
>  	unsigned long start_addr;
>  	struct intel_iommu *iommu;
>  
> +	if (identity_list(pdev)) {
> +		for_each_sg(sglist, sg, nelems, i) {
> +			addr = page_to_phys(sg_page(sg)) + sg->offset;
> +			sg->dma_address = addr;
> +			sg->dma_length = sg->length;
> +		}
> +

This is just the same as intel_nontranslate_map_sg()
Please consolidate this.

thanks,
-chris

  reply	other threads:[~2009-06-18 19:16 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090327212241.234500000@intel.com>
2009-03-28 14:24 ` [patch 0/4] Intel IOMMU Supspend/Resume Support Andrew Lutomirski
2009-03-30 23:01 ` David Woodhouse
     [not found] ` <20090327212321.520992000@intel.com>
2009-04-03 12:37   ` [patch 4/4] Intel IOMMU Suspend/Resume Support - Code Clean Up David Woodhouse
     [not found] ` <20090327212321.070229000@intel.com>
2009-04-16  0:19   ` [PATCH] Intel IOMMU Pass Through Support Fenghua Yu
2009-04-16  2:13     ` Han, Weidong
2009-04-19 10:05     ` David Woodhouse
2009-04-20 17:27       ` Yu, Fenghua
2009-05-13 23:13         ` [PATCH] Fix Intel IOMMU Compilation Warnings on IA64 Fenghua Yu
2009-05-14 15:17           ` David Woodhouse
2009-05-14 15:31             ` Matthew Wilcox
2009-05-14 17:59             ` Fenghua Yu
2009-06-18 18:05               ` [PATCH 1/2] IOMMU Identity Mapping Support: iommu_identity_mapping definition Fenghua Yu
2009-06-18 18:08                 ` Muli Ben-Yehuda
2009-06-18 18:13                   ` Chris Wright
2009-06-18 18:14                   ` Yu, Fenghua
2009-06-18 18:25                     ` Muli Ben-Yehuda
2009-06-18 18:31                       ` Chris Wright
2009-06-18 18:41                         ` Muli Ben-Yehuda
2009-06-18 18:50                           ` Yu, Fenghua
2009-06-18 18:51                           ` Chris Wright
2009-06-18 19:09                             ` Yu, Fenghua
2009-06-25  0:38                     ` [PATCH] IA64 Compilation Error Fix for Intel IOMMU Identity Mapping Support Fenghua Yu
2009-06-25  1:00                       ` FUJITA Tomonori
2009-06-25  4:16                         ` [PATCH v2] " Fenghua Yu
2009-06-25  4:48                           ` FUJITA Tomonori
2009-06-25  7:11                             ` David Woodhouse
2009-06-25 21:52                               ` David Woodhouse
2009-06-25 21:56                                 ` Yu, Fenghua
2009-06-26 18:21                                   ` David Woodhouse
2009-06-25 22:00                                 ` Linus Torvalds
2009-06-25 22:46                                   ` Tony Luck
2009-06-25 23:43                                 ` Chris Wright
2009-06-26  1:35                                   ` Linus Torvalds
2009-06-26  1:52                                     ` Chris Wright
2009-06-26  2:00                                       ` Linus Torvalds
2009-06-26  2:08                                         ` Chris Wright
2009-06-26 11:15                                           ` David Woodhouse
2009-06-27  0:03                                             ` Chris Wright
2009-06-27 11:44                                         ` David Woodhouse
2009-06-18 18:13                 ` [PATCH 1/2] IOMMU Identity Mapping Support: iommu_identity_mapping definition Chris Wright
2009-06-18 18:28                   ` Yu, Fenghua
2009-06-18 18:34                     ` Chris Wright
2009-07-04 18:40                   ` David Woodhouse
2009-05-20 17:42         ` [PATCH] Time out for possible dead loops during queued invalidation wait Fenghua Yu
2009-05-27  5:51           ` Andrew Morton
2009-05-27 22:40             ` Yu, Fenghua
2009-05-27 22:48               ` Andrew Morton
2009-05-27 23:25                 ` Yu, Fenghua
2009-05-27 23:51                   ` Andrew Morton
2009-05-28  0:47                     ` Yu, Fenghua
2009-06-18 18:05               ` [PATCH 2/2] IOMMU Identity Mapping Support: Intel IOMMU implementation Fenghua Yu
2009-06-18 19:15                 ` Chris Wright [this message]
2009-06-18 19:40                   ` Yu, Fenghua
2009-06-18 20:02                     ` Chris Wright
2009-06-19 20:47                     ` [PATCH v2] IOMMU Identity Mapping Support (drivers/pci/intel_iommu.c) Fenghua Yu
2009-04-30 23:29     ` [PATCH] Intel IOMMU Pass Through Support Andrew Morton
2009-04-30 23:37       ` Randy Dunlap
2009-05-01  0:00         ` Andrew Morton
2009-05-01  0:57           ` Fenghua Yu
2009-05-01  0:05         ` Fenghua Yu
2009-05-01  0:14           ` Andrew Morton

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=20090618191536.GD19771@sequoia.sous-sol.org \
    --to=chrisw@sous-sol.org \
    --cc=akpm@linux-foundation.org \
    --cc=allen.m.kay@intel.com \
    --cc=chrisw@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=fenghua.yu@intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sfr@canb.auug.org.au \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome