All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yijing Wang <wangyijing-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Alex Williamson
	<alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Jiang Liu <jiang.liu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH] iommu/vt-d: Fix broken device issue when using iommu=pt
Date: Mon, 11 Aug 2014 16:36:48 +0800	[thread overview]
Message-ID: <53E880A0.3040702@huawei.com> (raw)
In-Reply-To: <1407732187.9800.11.camel-85EaTFmN5p//9pzu0YdTqQ@public.gmane.org>

>>  extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
>>  
>> @@ -146,6 +148,7 @@ void dma_generic_free_coherent(struct device *dev, size_t size, void *vaddr,
>>   */
>>  static __init int iommu_setup(char *p)
>>  {
>> +	char *end;
>>  	iommu_merge = 1;
>>  
>>  	if (!p)
>> @@ -192,6 +195,11 @@ static __init int iommu_setup(char *p)
>>  #endif
>>  		if (!strncmp(p, "pt", 2))
>>  			iommu_pass_through = 1;
>> +		if (!strncmp(p, "pt_force=", 9)) {
>> +			iommu_pass_through = 1;
>> +			iommu_pt_force_domain = simple_strtol(p+9, &end, 0);
>> +			iommu_pt_force_bus = simple_strtol(end+1, NULL, 0);
> 
> Documentation/kernel-parameters.txt?

Oh, I missed it, I will update it if other guys think the patch is the right fix to the issue later.

> 
>> +		}
>>  
>>  		gart_parse_options(p);
>>  
>> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
>> index d1f5caa..49757f1 100644
>> --- a/drivers/iommu/intel-iommu.c
>> +++ b/drivers/iommu/intel-iommu.c
>> @@ -2705,6 +2705,47 @@ static int __init iommu_prepare_static_identity_mapping(int hw)
>>  				return ret;
>>  		}
>>  
>> +	/* We found some strange devices in HP c7000 and other platforms that
>> +	 * can not be enumerated by OS, but they did DMA read/write without
>> +	 * driver management, so we should create the pt mapping for these
>> +	 * devices to avoid DMA errors. Add iommu=pt_force=segment:busnum to
>> +	 * force to do pt context mapping in the bus number.
>> +	 */
> 
> So best case with this patch is that the user needs to discover that
> this option exists, figure out the undocumented parameters, be running
> on VT-d, permanently add a kernel commandline option, and never have any
> intention of assigning the device to userspace or a VM...

Hmmm, we can add some detection code in dmar fault process functions, and print
some useful messages.

> 
> Can't we handle this with the DMA alias quirks that are now in 3.17?  Or
> can the vendor fix this with a firmware update?  This device behavior is
> really quite broken for this kind of server class product.  Thanks,

Currently, I don't know how many devices have this issue. So I'm not sure
the vendor fix is a proper way to fix it. Alex, sorry, I don't understand
the firmware update to fix it? Do you mean updating the device EEPROM firmware ?

Thanks!
Yijing.


> 
> Alex
> 
>> +	if (iommu_pt_force_bus >= 0 && iommu_pt_force_bus >= 0) {
>> +		int found = 0;
>> +
>> +		iommu = NULL;
>> +		for_each_active_iommu(iommu, drhd) {
>> +			if (iommu_pt_force_domain != drhd->segment)
>> +				continue;
>> +
>> +			for_each_active_dev_scope(drhd->devices, drhd->devices_cnt, i, dev) {
>> +				if (!dev_is_pci(dev))
>> +					continue;
>> +
>> +				pdev = to_pci_dev(dev);
>> +				if (pdev->bus->number == iommu_pt_force_bus ||
>> +						(pdev->subordinate
>> +						 && pdev->subordinate->number <= iommu_pt_force_bus
>> +						 && pdev->subordinate->busn_res.end >= iommu_pt_force_bus)) {
>> +					found = 1;
>> +					break;
>> +				}
>> +			}
>> +
>> +			if (drhd->include_all) {
>> +				found = 1;
>> +				break;
>> +			}
>> +		}
>> +
>> +		if (found && iommu)
>> +			for (i = 0; i < 256; i++)
>> +				domain_context_mapping_one(si_domain, iommu, iommu_pt_force_bus,
>> +						i,  hw ? CONTEXT_TT_PASS_THROUGH :
>> +						CONTEXT_TT_MULTI_LEVEL);
>> +	}
>> +
>>  	return 0;
>>  }
>>  
> 
> 
> 
> 
> .
> 


-- 
Thanks!
Yijing

  parent reply	other threads:[~2014-08-11  8:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-11  2:54 [PATCH] iommu/vt-d: Fix broken device issue when using iommu=pt Yijing Wang
     [not found] ` <1407725674-27271-1-git-send-email-wangyijing-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-08-11  3:15   ` Jiang Liu
     [not found]     ` <53E8355C.4010906-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-08-11  3:46       ` Yijing Wang
     [not found]         ` <53E83C9E.9060405-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-08-11  4:56           ` Jiang Liu
     [not found]             ` <53E84CEA.7080402-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-08-11  8:26               ` Yijing Wang
2014-08-11  4:43   ` Alex Williamson
     [not found]     ` <1407732187.9800.11.camel-85EaTFmN5p//9pzu0YdTqQ@public.gmane.org>
2014-08-11  8:36       ` Yijing Wang [this message]
2014-08-11 14:59       ` Linda Knippers
     [not found]         ` <53E8DA5E.8090406-VXdhtT5mjnY@public.gmane.org>
2014-08-12  1:37           ` Yijing Wang
     [not found]             ` <53E96FE0.7080600-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-08-12  2:34               ` Jiang Liu
2014-08-12  3:18               ` Jiang Liu
     [not found]                 ` <53E9876F.9040300-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-08-12  3:48                   ` Yijing Wang
2014-08-14 16:07               ` Linda Knippers
  -- strict thread matches above, loose matches on Subject: below --
2014-09-24 21:56 Rob Roschewsk
     [not found] ` <1597491265.153338.1411595791727.JavaMail.open-xchange-91tEjvOFe9KcT/DCa4qSTkaJx/dRlJfr5NbjCUgZEJk@public.gmane.org>
2014-09-25  2:36   ` Yijing Wang
     [not found]     ` <54237F92.1090601-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-09-25 13:56       ` Rob Roschewsk
     [not found]         ` <CAE1O4xrQYpc4o6MbN8b7kkgwTbjj+Pszu5WUwM_vErUfyQYfNw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-25 14:29           ` Linda Knippers

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=53E880A0.3040702@huawei.com \
    --to=wangyijing-hv44wf8li93qt0dzr+alfa@public.gmane.org \
    --cc=alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=jiang.liu-VuQAYsv1563Yd54FQh9/CA@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.