All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maciek <gotoc64@gmail.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [driver question] IOMMU concept in Xen
Date: Mon, 10 Oct 2016 13:15:27 -0700	[thread overview]
Message-ID: <299659f9-7b91-7f33-9e23-a58da1e4a38f@gmail.com> (raw)
In-Reply-To: <57FB63000200007800115F88@prv-mh.provo.novell.com>

Yes you are right,

I was too focused on my issue that I didn't specify what I am trying to 
achieve :)
My company current driver can work as normal PF pci device, and also we 
support SR-IOV.
In driver initialization we can call sriov_configure to turn on SRIOV 
and enable VFs.
To be able to run on VM using VF we need IOMMU enabled (currently we 
recommend our
customers to add parameter to kernel intel_iommu=on).
But because we have many cases when people were trying to run driver 
without iommu,
caused fail, that VFs were visible but driver not working we decided to 
handle inside sriov_configure
call to handle this case by using simple check by iommu_present.
That solve our issue till we moved to Xen.
As I pointed out on Xen we didn't see iommu on Dom0, and that cause our 
check to don't enable sriov.
After we removed this check driver works perfectly fine, but we are in 
the same place.
So my intention is to leave this check in case of other hypervisor, and 
also meet Xen requirements about iommu handling.

Is that put more sense on my investigation?

Thanks
Maciej


On 10/10/16 00:44, Jan Beulich wrote:
>>>> On 10.10.16 at 02:19, <gotoc64@gmail.com> wrote:
>> During development of linux kernel PCI driver with SR-IOV I meet some
>> difficulty and I wanted to make sure that I understand correctly Xen
>> concepts.
>>
>> Things that confuse me is build in function: iommu_present. Is usually
>> used in driver that are using iommu to work.
>> My problem is that this function work perfectly fine on bare-metal
>> linux, but when I move to Xen (or XenServer) then this function return
>> always false.
>>
>> I know that Xen concept move IOMMU from linux kernel (which is on xen
>> just VM) to the hyperviosr. In XenServer is done using command:
>> xen-cmdline --set-xen iommu=1. After this command (and restart) iommu
>> should work.
>> I can also add this parameter to kernel cmd line (intel_iommu=on). Using
>> that in kernel messages I can see message: Intel-IOMMU: enabled. But no
>> matter which way I follow, iommu_present will always return me false.
>>
>> I just commented out this check block and run whole driver, there wasn't
>> any issue and driver works perfectly.
>>
>> After that I if there are other drivers in kernel that have the same
>> issue, but I didn't find anything that can solve this issue. One driver
>> check has conditional compilation for iommu_present block: #if
>> IS_ENABLED(CONFIG_IOMMU_API), but in XenServer (I checked XS 6.5) this
>> option is set to yes in kernel configuration. (This driver source is:
>> drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c)
>>
>> Using grep I found other drivers that can run into same trouble (doesn't
>> start or throw warning log) inside Xen as dom0:
>> ## drivers that are uisng iommu_present
>> drivers/gpu/drm/tegra/drm.c
>> drivers/infiniband/hw/usnic/usnic_uiom.c
>> drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
>> drivers/vfio/vfio.c
>> drivers/gpu/drm/msm/msm_gem.c
>> drivers/gpu/drm/msm/msm_drv.c
>> drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> drivers/crypto/qat/qat_common/adf_sriov.c
>>
>> So there are two options: there drivers are not designed for Xen or I
>> totally mess up something.
>>
>> In my driver I started thinking to use #if IS_ENABLED(CONFIG_XEN_DOM0)
>> to handle different Hypervisor, but maybe is not right solution.
> What you don't clarify in all of the above explanations and analysis
> is - why do you need to know in the driver in the first place. To a
> guest the presence of an IOMMU should be transparent. There may
> be certain cases where Dom0 drivers need to know, but such then
> need to be made interact with Xen (as the entity driving the IOMMU),
> i.e. can't normally work on Xen without some minimal adjustments.
> And this should really be the exception, not the rule.
>
> Jan
>


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-10-10 20:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10  0:19 [driver question] IOMMU concept in Xen Maciek
2016-10-10  7:44 ` Jan Beulich
2016-10-10 20:15   ` Maciek [this message]
2016-10-11 12:49     ` Jan Beulich

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=299659f9-7b91-7f33-9e23-a58da1e4a38f@gmail.com \
    --to=gotoc64@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xen.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.