mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	David Gibson <david@gibson.dropbear.id.au>,
	Paul Mackerras <paulus@samba.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfio powerpc: implement IOMMU driver for VFIO
Date: Thu, 21 Mar 2013 11:57:17 +1100	[thread overview]
Message-ID: <514A5AED.1050405@ozlabs.ru> (raw)
In-Reply-To: <1363812324.24132.544.camel@bling.home>

On 21/03/13 07:45, Alex Williamson wrote:
> On Tue, 2013-03-19 at 18:08 +1100, Alexey Kardashevskiy wrote:
>> VFIO implements platform independent stuff such as
>> a PCI driver, BAR access (via read/write on a file descriptor
>> or direct mapping when possible) and IRQ signaling.
>>
>> The platform dependent part includes IOMMU initialization
>> and handling. This patch implements an IOMMU driver for VFIO
>> which does mapping/unmapping pages for the guest IO and
>> provides information about DMA window (required by a POWERPC
>> guest).
>>
>> The counterpart in QEMU is required to support this functionality.
>>
>> Changelog:
>> * documentation updated
>> * containter enable/disable ioctls added
>> * request_module(spapr_iommu) added
>> * various locks fixed
>>
>> Cc: David Gibson <david@gibson.dropbear.id.au>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>
>
> Looking pretty good.  There's one problem with the detach_group,
> otherwise just some trivial comments below.  What's the status of the
> tce code that this depends on?  Thanks,


It is done, I am just waiting till other patches of the series will be 
reviewed (by guys) and fixed (by me) and then I'll post everything again.

[skipped]

>> +static int tce_iommu_enable(struct tce_container *container)
>> +{
>> +	int ret = 0;
>> +	unsigned long locked, lock_limit, npages;
>> +	struct iommu_table *tbl = container->tbl;
>> +
>> +	if (!container->tbl)
>> +		return -ENXIO;
>> +
>> +	if (!current->mm)
>> +		return -ESRCH; /* process exited */
>> +
>> +	mutex_lock(&container->lock);
>> +	if (container->enabled) {
>> +		mutex_unlock(&container->lock);
>> +		return -EBUSY;
>> +	}
>> +
>> +	/*
>> +	 * Accounting for locked pages.
>> +	 *
>> +	 * On sPAPR platform, IOMMU translation table contains
>> +	 * an entry per 4K page. Every map/unmap request is sent
>> +	 * by the guest via hypercall and supposed to be handled
>> +	 * quickly, ecpesially in real mode (if such option is
>
> s/ecpesially/especially/


I replaced the whole text by the one written by Ben and David.

[skipped]

>> +	}
>> +
>> +	return -ENOTTY;
>> +}
>> +
>> +static int tce_iommu_attach_group(void *iommu_data,
>> +		struct iommu_group *iommu_group)
>> +{
>> +	int ret;
>> +	struct tce_container *container = iommu_data;
>> +	struct iommu_table *tbl = iommu_group_get_iommudata(iommu_group);
>> +
>> +	BUG_ON(!tbl);
>> +	mutex_lock(&container->lock);
>> +	pr_debug("tce_vfio: Attaching group #%u to iommu %p\n",
>> +			iommu_group_id(iommu_group), iommu_group);
>> +	if (container->tbl) {
>> +		pr_warn("tce_vfio: Only one group per IOMMU container is allowed, existing id=%d, attaching id=%d\n",
>> +				iommu_group_id(container->tbl->it_group),
>> +				iommu_group_id(iommu_group));
>> +		mutex_unlock(&container->lock);
>> +		return -EBUSY;
>> +	}
>> +
>> +	ret = iommu_take_ownership(tbl);
>> +	if (!ret)
>> +		container->tbl = tbl;
>> +
>> +	mutex_unlock(&container->lock);
>> +
>> +	return ret;
>> +}
>> +
>> +static void tce_iommu_detach_group(void *iommu_data,
>> +		struct iommu_group *iommu_group)
>> +{
>> +	struct tce_container *container = iommu_data;
>> +	struct iommu_table *tbl = iommu_group_get_iommudata(iommu_group);
>> +
>> +	BUG_ON(!tbl);
>> +	mutex_lock(&container->lock);
>> +	if (tbl != container->tbl) {
>> +		pr_warn("tce_vfio: detaching group #%u, expected group is #%u\n",
>> +				iommu_group_id(iommu_group),
>> +				iommu_group_id(tbl->it_group));
>> +	} else if (container->enabled) {
>> +		pr_err("tce_vfio: detaching group #%u from enabled container\n",
>> +				iommu_group_id(tbl->it_group));
>
> Hmm, something more than a pr_err needs to happen here.  Wouldn't this
> imply a disable and going back to an unprivileged container?

Ah. It does not return error code... Then something like that?

...
          } else if (container->enabled) {
                  pr_warn("tce_vfio: detaching group #%u from enabled 
container, forcing disable\n",
                                  iommu_group_id(tbl->it_group));
                  tce_iommu_disable(container);
...

-- 
Alexey

  reply	other threads:[~2013-03-21  0:56 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-11 11:54 [PATCH 0/2] vfio on power Alexey Kardashevskiy
2013-02-11 11:54 ` [PATCH 1/2] vfio powerpc: enabled on powernv platform Alexey Kardashevskiy
2013-02-11 22:16   ` Alex Williamson
2013-02-11 23:19     ` Alexey Kardashevskiy
2013-02-12  0:01       ` Alex Williamson
2013-02-25  2:21     ` Paul Mackerras
2013-02-11 11:54 ` [PATCH 2/2] vfio powerpc: implemented IOMMU driver for VFIO Alexey Kardashevskiy
2013-02-11 22:17   ` Alex Williamson
2013-02-11 23:45     ` Alexey Kardashevskiy
2013-02-12  0:25       ` Alex Williamson
2013-02-12  4:06         ` [PATCH] iommu: making IOMMU sysfs nodes API public Alexey Kardashevskiy
2013-02-12  5:07           ` Alex Williamson
2013-02-12 14:42             ` Alexey Kardashevskiy
2013-02-12 17:15               ` Alex Williamson
2013-02-18  6:15                 ` Alexey Kardashevskiy
2013-02-19  5:24                   ` Alex Williamson
2013-02-19  5:48                     ` Alexey Kardashevskiy
2013-02-19 19:53                       ` Alex Williamson
2013-02-19  7:38                     ` David Gibson
2013-02-19 20:11                       ` Alex Williamson
2013-02-20  2:31                         ` Alexey Kardashevskiy
2013-02-20  3:47                           ` Alex Williamson
2013-02-20  4:20                             ` Alexey Kardashevskiy
2013-02-20  4:33                               ` Alex Williamson
2013-03-18  3:53                                 ` Alexey Kardashevskiy
2013-03-19  2:40                                   ` Alex Williamson
2013-03-19  7:08                                     ` [PATCH] vfio powerpc: implement IOMMU driver for VFIO Alexey Kardashevskiy
2013-03-20 20:45                                       ` Alex Williamson
2013-03-21  0:57                                         ` Alexey Kardashevskiy [this message]
2013-03-21  1:29                                           ` Alex Williamson
2013-03-21  1:55                                         ` David Gibson
2013-03-21  3:16                                           ` Alex Williamson
2013-03-25  2:12                                             ` David Gibson
2013-02-22  0:04                         ` [PATCH] iommu: making IOMMU sysfs nodes API public David Gibson
2013-02-22  4:11                           ` Alex Williamson
2013-02-25  0:03                             ` David Gibson

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=514A5AED.1050405@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.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