xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Oleksandr Tyshchenko <olekstysh@gmail.com>
To: Julien Grall <julien.grall@arm.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Volodymyr Babchuk <vlad.babchuk@gmail.com>,
	Andrii Anisov <andrii.anisov@gmail.com>,
	Oleksandr Andrushchenko <andr2000@gmail.com>,
	al1img <al1img@gmail.com>, Jan Beulich <JBeulich@suse.com>,
	xen-devel@lists.xenproject.org,
	Artem Mygaiev <joculator@gmail.com>
Subject: Re: [RFC PATCH 2/9] iommu: Add ability to map/unmap the number of pages
Date: Fri, 21 Apr 2017 14:46:00 +0300	[thread overview]
Message-ID: <CAPD2p-=9U2eeOHPP6EOb9Crsvh65wgoOvofAAXv=hWiB+=ZXbA@mail.gmail.com> (raw)
In-Reply-To: <5dd6cde2-6769-cec9-ea64-f0014edd6bc8@arm.com>

On Wed, Apr 19, 2017 at 8:31 PM, Julien Grall <julien.grall@arm.com> wrote:
> Hi Oleksandr,
Hi, Julien

>
>
> On 15/03/17 20:05, Oleksandr Tyshchenko wrote:
>>
>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>
>> Extend the IOMMU code with new APIs and platform callbacks.
>> These new map_pages/unmap_pages API do almost the same thing
>> as existing map_page/unmap_page ones except the formers can
>> handle the number of pages. So do new platform callbacks.
>>
>> Currently, this patch requires to modify neither
>> existing IOMMU drivers nor P2M code.
>> But, the patch might be rewritten to replace existing
>> single-page stuff with the multi-page one followed by modifications
>> of all related parts.
>>
>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>> ---
>>  xen/drivers/passthrough/iommu.c | 50
>> ++++++++++++++++++++++++++++++++---------
>>  xen/include/xen/iommu.h         | 16 ++++++++++---
>>  2 files changed, 52 insertions(+), 14 deletions(-)
>>
>> diff --git a/xen/drivers/passthrough/iommu.c
>> b/xen/drivers/passthrough/iommu.c
>> index 5e81813..115698f 100644
>> --- a/xen/drivers/passthrough/iommu.c
>> +++ b/xen/drivers/passthrough/iommu.c
>> @@ -249,22 +249,37 @@ void iommu_domain_destroy(struct domain *d)
>>      arch_iommu_domain_destroy(d);
>>  }
>>
>> -int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long
>> mfn,
>> -                   unsigned int flags)
>> +int iommu_map_pages(struct domain *d, unsigned long gfn, unsigned long
>> mfn,
>> +                    unsigned long page_count, unsigned int flags)
>
>
> It would be nice if you can use mfn_t and gfn_t instead of unsigned long for
> any new functions. They are typesafe and avoid confusion between gfn and
> mfn.
ok

>
>
>>  {
>>      const struct domain_iommu *hd = dom_iommu(d);
>> -    int rc;
>> +    int rc = 0;
>> +    unsigned long i;
>>
>>      if ( !iommu_enabled || !hd->platform_ops )
>>          return 0;
>>
>> -    rc = hd->platform_ops->map_page(d, gfn, mfn, flags);
>> +    if ( hd->platform_ops->map_pages )
>> +        rc = hd->platform_ops->map_pages(d, gfn, mfn, page_count, flags);
>> +    else
>> +    {
>> +        for ( i = 0; i < page_count; i++ )
>> +        {
>> +            rc = hd->platform_ops->map_page(d, gfn + i, mfn + i, flags);
>> +            if ( unlikely(rc) )
>> +            {
>> +                /* TODO Do we need to unmap if map failed? */
>> +                break;
>> +            }
>> +        }
>> +    }
>> +
>>      if ( unlikely(rc) )
>>      {
>>          if ( !d->is_shutting_down && printk_ratelimit() )
>>              printk(XENLOG_ERR
>> -                   "d%d: IOMMU mapping gfn %#lx to mfn %#lx failed:
>> %d\n",
>> -                   d->domain_id, gfn, mfn, rc);
>> +                   "d%d: IOMMU mapping gfn %#lx to mfn %#lx page count
>> %lu failed: %d\n",
>> +                   d->domain_id, gfn, mfn, page_count, rc);
>>
>>          if ( !is_hardware_domain(d) )
>>              domain_crash(d);
>> @@ -273,21 +288,34 @@ int iommu_map_page(struct domain *d, unsigned long
>> gfn, unsigned long mfn,
>>      return rc;
>>  }
>>
>> -int iommu_unmap_page(struct domain *d, unsigned long gfn)
>> +int iommu_unmap_pages(struct domain *d, unsigned long gfn,
>> +                      unsigned long page_count)
>>  {
>>      const struct domain_iommu *hd = dom_iommu(d);
>> -    int rc;
>> +    int ret, rc = 0;
>> +    unsigned long i;
>>
>>      if ( !iommu_enabled || !hd->platform_ops )
>>          return 0;
>>
>> -    rc = hd->platform_ops->unmap_page(d, gfn);
>> +    if ( hd->platform_ops->unmap_pages )
>> +        rc = hd->platform_ops->unmap_pages(d, gfn, page_count);
>> +    else
>> +    {
>> +        for ( i = 0; i < page_count; i++ )
>> +        {
>> +            ret = hd->platform_ops->unmap_page(d, gfn + i);
>> +            if ( likely(!rc) )
>> +                rc = ret;
>> +        }
>> +    }
>> +
>>      if ( unlikely(rc) )
>>      {
>>          if ( !d->is_shutting_down && printk_ratelimit() )
>>              printk(XENLOG_ERR
>> -                   "d%d: IOMMU unmapping gfn %#lx failed: %d\n",
>> -                   d->domain_id, gfn, rc);
>> +                   "d%d: IOMMU unmapping gfn %#lx page count %lu failed:
>> %d\n",
>> +                   d->domain_id, gfn, page_count, rc);
>>
>>          if ( !is_hardware_domain(d) )
>>              domain_crash(d);
>> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
>> index 5803e3f..0446ed3 100644
>> --- a/xen/include/xen/iommu.h
>> +++ b/xen/include/xen/iommu.h
>> @@ -76,9 +76,14 @@ void iommu_teardown(struct domain *d);
>>  #define IOMMUF_readable  (1u<<_IOMMUF_readable)
>>  #define _IOMMUF_writable 1
>>  #define IOMMUF_writable  (1u<<_IOMMUF_writable)
>> -int __must_check iommu_map_page(struct domain *d, unsigned long gfn,
>> -                                unsigned long mfn, unsigned int flags);
>> -int __must_check iommu_unmap_page(struct domain *d, unsigned long gfn);
>> +int __must_check iommu_map_pages(struct domain *d, unsigned long gfn,
>> +                                 unsigned long mfn, unsigned long
>> page_count,
>> +                                 unsigned int flags);
>> +int __must_check iommu_unmap_pages(struct domain *d, unsigned long gfn,
>> +                                   unsigned long page_count);
>> +
>> +#define iommu_map_page(d,gfn,mfn,flags)
>> (iommu_map_pages(d,gfn,mfn,1,flags))
>> +#define iommu_unmap_page(d,gfn)         (iommu_unmap_pages(d,gfn,1))
>>
>>  enum iommu_feature
>>  {
>> @@ -170,7 +175,12 @@ struct iommu_ops {
>>      void (*teardown)(struct domain *d);
>>      int __must_check (*map_page)(struct domain *d, unsigned long gfn,
>>                                   unsigned long mfn, unsigned int flags);
>> +    int __must_check (*map_pages)(struct domain *d, unsigned long gfn,
>> +                                  unsigned long mfn, unsigned long
>> page_count,
>> +                                  unsigned int flags);
>>      int __must_check (*unmap_page)(struct domain *d, unsigned long gfn);
>> +    int __must_check (*unmap_pages)(struct domain *d, unsigned long gfn,
>> +                                    unsigned long page_count);
>>      void (*free_page_table)(struct page_info *);
>>  #ifdef CONFIG_X86
>>      void (*update_ire_from_apic)(unsigned int apic, unsigned int reg,
>> unsigned int value);
>>
>
> Cheers,
>
> --
> Julien Grall



-- 
Regards,

Oleksandr Tyshchenko

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

  reply	other threads:[~2017-04-21 11:46 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15 20:05 [RFC PATCH 0/9] "Non-shared" IOMMU support on ARM Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 1/9] xen/device-tree: Add dt_count_phandle_with_args helper Oleksandr Tyshchenko
2017-03-16 15:39   ` Julien Grall
2017-03-17 11:24     ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 2/9] iommu: Add ability to map/unmap the number of pages Oleksandr Tyshchenko
2017-03-22 15:44   ` Jan Beulich
2017-03-22 18:01     ` Oleksandr Tyshchenko
2017-03-23  9:07       ` Jan Beulich
2017-03-23 12:47         ` Oleksandr Tyshchenko
2017-04-27 16:56           ` Oleksandr Tyshchenko
2017-04-28  6:23             ` Jan Beulich
2017-04-28 10:16               ` Oleksandr Tyshchenko
2017-04-28 10:29                 ` Jan Beulich
2017-04-28 10:44                   ` Oleksandr Tyshchenko
2017-04-19 17:31   ` Julien Grall
2017-04-21 11:46     ` Oleksandr Tyshchenko [this message]
2017-03-15 20:05 ` [RFC PATCH 3/9] xen/arm: p2m: Add helper to convert p2m type to IOMMU flags Oleksandr Tyshchenko
2017-04-19 17:28   ` Julien Grall
2017-04-21 11:47     ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 4/9] xen/arm: p2m: Update IOMMU mapping whenever possible if page table is not shared Oleksandr Tyshchenko
2017-04-19 17:46   ` Julien Grall
2017-04-21 14:18     ` Oleksandr Tyshchenko
2017-04-21 16:27       ` Julien Grall
2017-04-21 18:44         ` Oleksandr Tyshchenko
2017-04-24 11:41           ` Julien Grall
2017-04-24 16:08             ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 5/9] iommu/arm: Re-define iommu_use_hap_pt(d) as iommu_hap_pt_share Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 6/9] iommu: Pass additional use_iommu argument to iommu_domain_init() Oleksandr Tyshchenko
2017-03-22 15:48   ` Jan Beulich
2017-03-23 12:50     ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 7/9] iommu/arm: Add alloc_page_table platform callback Oleksandr Tyshchenko
2017-03-22 15:49   ` Jan Beulich
2017-03-23 12:57     ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 8/9] iommu: Split iommu_hwdom_init() into arch specific parts Oleksandr Tyshchenko
2017-03-22 15:54   ` Jan Beulich
2017-03-22 18:40     ` Oleksandr Tyshchenko
2017-03-23  9:08       ` Jan Beulich
2017-03-23 12:40         ` Oleksandr Tyshchenko
2017-03-23 13:28           ` Jan Beulich
2017-04-19 18:09           ` Julien Grall
2017-04-21 12:18             ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 9/9] xen: Add use_iommu flag to createdomain domctl Oleksandr Tyshchenko
2017-03-22 15:56   ` Jan Beulich
2017-03-23 16:36     ` Oleksandr Tyshchenko
2017-03-23 17:05       ` Jan Beulich
2017-03-24 11:19         ` Oleksandr Tyshchenko
2017-03-24 11:38           ` Jan Beulich
2017-03-24 13:05             ` Oleksandr Tyshchenko
2017-04-19 18:26   ` Julien Grall
2017-04-21 14:41     ` Oleksandr Tyshchenko
2017-04-25 15:23     ` Wei Liu
2017-04-25 16:07       ` Oleksandr Tyshchenko
2017-04-26 10:05         ` Ian Jackson
2017-04-27 10:41           ` Oleksandr Tyshchenko
2017-03-16 15:31 ` [RFC PATCH 0/9] "Non-shared" IOMMU support on ARM Julien Grall
2017-03-17 11:24   ` Oleksandr Tyshchenko

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='CAPD2p-=9U2eeOHPP6EOb9Crsvh65wgoOvofAAXv=hWiB+=ZXbA@mail.gmail.com' \
    --to=olekstysh@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=al1img@gmail.com \
    --cc=andr2000@gmail.com \
    --cc=andrii.anisov@gmail.com \
    --cc=joculator@gmail.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=vlad.babchuk@gmail.com \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).