xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Sergiy Kibrik <sakib@darkstar.site>
To: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>
Cc: Roman Skakun <rm.skakun@gmail.com>,
	xen-devel@lists.xenproject.org,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Andrii Anisov <andrii_anisov@epam.com>,
	Sergiy Kibrik <sergiy_kibrik@epam.com>
Subject: Re: [RFC 1/1] xen/arm: set iommu property for IOMMU-protected devices
Date: Tue, 7 Dec 2021 17:40:59 +0200	[thread overview]
Message-ID: <c789cc71-db2d-0735-f007-e93bd23a81a5@darkstar.site> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2111101306180.440530@ubuntu-linux-20-04-desktop>

hi Stefano, Julien,

On 11/10/21 11:12 пп, Stefano Stabellini wrote:
> On Mon, 8 Nov 2021, Julien Grall wrote:
[..]
>> A few years ago, I attempted to disable the swiotlb when Xen configured the
>> IOMMU for the device (see [1]). Did you have a chance to go through the
>> thread? In particular, I think Ian Campbell suggestion about creating an IOMMU
>> binding is quite interesting.
>>
>> Stefano, what do you think?
> 
> Yes I think it is a good idea. In fact, thinking more about it, it is
> really the best option. Regardless of the implementation (swiotlb or
> whatever) the device tree description is likely to look similar to the
> description of an IOMMU because it is the common pattern shared by all
> controllers (reset, power, clocks, etc.) so it makes sense to re-use it.
> 
> - there is one controller node (the "IOMMU")
> - there is one property under each device node that is protected,
>    pointing to the controller with a phandle and optional parameters (in
>    the case of IOMMUs it is called "iommus")
> 

Code in arch_setup_dma_ops() always forces swiotlb for dom0 regardless 
of any prior IOMMU configuration for the device. So if we are to re-use 
IOMMU bindings and implement kind of dummy iommu (that merely does 
direct allocation and mapping) we'll have to check whether device is 
protected anyway, e.g.:

   diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
   index 49f566ad9acb..6ddef3233095 100644
   --- a/arch/arm/xen/enlighten.c
   +++ b/arch/arm/xen/enlighten.c
   @@ -425,6 +425,10 @@ static int __init xen_pm_init(void)
    }
    late_initcall(xen_pm_init);

   +bool xen_is_device_protected(struct device *dev) {
   +	return dev->dma_ops == &dummy_xen_iommu_ops;
   +}

    /* empty stubs */
    void xen_arch_pre_suspend(void) { }


Have I got it right?

  - Sergiy


  reply	other threads:[~2021-12-07 15:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04  9:54 [RFC 0/1] tag IOMMU-protected devices in Dom0 fdt Roman Skakun
2021-10-04  9:54 ` [RFC 1/1] xen/arm: set iommu property for IOMMU-protected devices Roman Skakun
2021-10-06 12:45   ` Oleksandr
2021-10-07 11:04     ` Roman Skakun
2021-11-08 18:30   ` Julien Grall
2021-11-10 21:12     ` Stefano Stabellini
2021-12-07 15:40       ` Sergiy Kibrik [this message]
2021-12-10  2:04         ` Stefano Stabellini
2021-10-04  9:54 ` [RFC PATCH] dma-mapping: don't set swiotlb-xen fops " Roman Skakun
2021-10-12 14:11 ` [RFC 0/1] tag IOMMU-protected devices in Dom0 fdt Roman Skakun
2021-10-12 14:20   ` Julien Grall
2021-10-12 14:23     ` Roman Skakun

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=c789cc71-db2d-0735-f007-e93bd23a81a5@darkstar.site \
    --to=sakib@darkstar.site \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrii_anisov@epam.com \
    --cc=julien@xen.org \
    --cc=rm.skakun@gmail.com \
    --cc=sergiy_kibrik@epam.com \
    --cc=sstabellini@kernel.org \
    --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).