From: Oleksandr <olekstysh@gmail.com>
To: Julien Grall <julien.grall@arm.com>, xen-devel@lists.xenproject.org
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
sstabellini@kernel.org, Volodymyr_Babchuk@epam.com
Subject: Re: [Xen-devel] [PATCH V3 2/8] iommu/arm: Add ability to handle deferred probing request
Date: Mon, 9 Sep 2019 17:19:31 +0300 [thread overview]
Message-ID: <ff171664-8ddc-9072-e38a-f9d9cf5100e0@gmail.com> (raw)
In-Reply-To: <93f7a752-b674-5418-55b4-3031ff67990e@arm.com>
On 09.09.19 15:24, Julien Grall wrote:
> Hi Oleksandr,
Hi, Julien
>
> The code looks code, few comments below.
>
> On 8/20/19 7:09 PM, Oleksandr Tyshchenko wrote:
>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>
>> This patch adds minimal required support to General IOMMU framework
>> to be able to handle a case when IOMMU driver requesting deferred
>> probing for a device.
>>
>> In order not to pull Linux's error code (-EPROBE_DEFER) to Xen
>> we have chosen -EAGAIN to be used for indicating that device
>> probing is deferred.
>>
>> This is needed for the upcoming IPMMU driver which may request
>> deferred probing depending on what device will be probed the first
>> (there is some dependency between these devices, Root device must be
>> registered before Cache devices. If not the case, driver will deny
>> further Cache device probes until Root device is registered).
>> As we can't guarantee a fixed pre-defined order for the device nodes
>> in DT, we need to be ready for the situation where devices being
>> probed in "any" order.
>>
>> While here, order the headers alphabetically.
>
> It is common to clean code you modify in the same patch if they are
> not complex, but this is not the case here... Indeed, the headers are
> not touched. So I would prefer this to be in a separate patch unless
> it breaks the compilation without it.
Well, will make this change in a separate patch.
>
>
>>
>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>> CC: Julien Grall <julien.grall@arm.com>
>>
>> ---
>> Changes V2 -> V3:
>> - removed deferred_probe field from struct dt_device_node,
>> re-used domain_list instead
>> - documented domain_list usage
>> - added ASSERT to check that np->domain_list is empty
>> before re-using it
>> - put deferred_probe_list to init section
>> - used more strict logic regarding processing devices in
>> the deferred list
>> - added more comments to code
>> - put headers in alphabetical order
>> ---
>> xen/drivers/passthrough/arm/iommu.c | 59
>> ++++++++++++++++++++++++++++++++++---
>> xen/include/asm-arm/device.h | 6 +++-
>> xen/include/xen/device_tree.h | 7 +++++
>> 3 files changed, 67 insertions(+), 5 deletions(-)
>>
>> diff --git a/xen/drivers/passthrough/arm/iommu.c
>> b/xen/drivers/passthrough/arm/iommu.c
>> index f219de9..72a30e0 100644
>> --- a/xen/drivers/passthrough/arm/iommu.c
>> +++ b/xen/drivers/passthrough/arm/iommu.c
>> @@ -15,11 +15,20 @@
>> * GNU General Public License for more details.
>> */
>> -#include <xen/lib.h>
>> -#include <xen/iommu.h>
>> #include <xen/device_tree.h>
>> +#include <xen/iommu.h>
>> +#include <xen/lib.h>
>> +
>> #include <asm/device.h>
>> +/*
>> + * Deferred probe list is used to keep track of devices for which
>> driver
>> + * requested deferred probing (returned -EAGAIN).
>> + *
>> + * We re-use device's domain_list to link the device in the deferred
>> list.
>> + */
>> +static __initdata LIST_HEAD(deferred_probe_list);
>> +
>> static const struct iommu_ops *iommu_ops;
>> const struct iommu_ops *iommu_get_ops(void)
>> @@ -42,7 +51,7 @@ void __init iommu_set_ops(const struct iommu_ops *ops)
>> int __init iommu_hardware_setup(void)
>> {
>> - struct dt_device_node *np;
>> + struct dt_device_node *np, *tmp;
>> int rc;
>> unsigned int num_iommus = 0;
>> @@ -51,6 +60,17 @@ int __init iommu_hardware_setup(void)
>> rc = device_init(np, DEVICE_IOMMU, NULL);
>> if ( !rc )
>> num_iommus++;
>> + else if ( rc == -EAGAIN )
>> + {
>> + /* We expect nobody uses domain_list at such early
>> stage. */
>
> AFAICT, this comment is only an English version of the next line. It
> would be best if you explain why domain_list is re-used here.
Will do.
>
>
>> + ASSERT(list_empty(&np->domain_list));
>> +
>> + /*
>> + * Driver requested deferred probing, so add this device to
>> + * the deferred list for further processing.
>> + */
>> + list_add(&np->domain_list, &deferred_probe_list);
>> + }
>> /*
>> * Ignore the following error codes:
>> * - EBADF: Indicate the current not is not an IOMMU
>> @@ -61,7 +81,38 @@ int __init iommu_hardware_setup(void)
>> return rc;
>> }
>> - return ( num_iommus > 0 ) ? 0 : -ENODEV;
>> + /* Return immediately if there are no initialized devices. */
>> + if ( !num_iommus )
>> + return ( list_empty(&deferred_probe_list) ) ? -ENODEV :
>> -EAGAIN;
>
> NIT: Do you need the outer ()?
No, I don't.
--
Regards,
Oleksandr Tyshchenko
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-09-09 14:19 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-20 18:09 [Xen-devel] [PATCH V3 0/8] iommu/arm: Add Renesas IPMMU-VMSA support + Linux's iommu_fwspec Oleksandr Tyshchenko
2019-08-20 18:09 ` [Xen-devel] [PATCH V3 1/8] iommu/arm: Add iommu_helpers.c file to keep common for IOMMUs stuff Oleksandr Tyshchenko
2019-09-09 11:45 ` Julien Grall
2019-09-09 14:12 ` Oleksandr
2019-08-20 18:09 ` [Xen-devel] [PATCH V3 2/8] iommu/arm: Add ability to handle deferred probing request Oleksandr Tyshchenko
2019-09-09 12:24 ` Julien Grall
2019-09-09 14:19 ` Oleksandr [this message]
2019-08-20 18:09 ` [Xen-devel] [PATCH V3 3/8] xen/common: Introduce _xrealloc function Oleksandr Tyshchenko
2019-08-21 8:09 ` Paul Durrant
2019-08-21 14:36 ` Oleksandr
2019-08-21 15:47 ` Paul Durrant
2019-08-21 17:04 ` Oleksandr
2019-08-20 18:09 ` [Xen-devel] [PATCH V3 4/8] xen/common: Introduce xrealloc_flex_struct() helper macros Oleksandr Tyshchenko
2019-08-27 13:28 ` Jan Beulich
2019-08-28 18:23 ` Oleksandr
2019-08-29 7:21 ` Jan Beulich
2019-08-29 19:04 ` Oleksandr
2019-08-20 18:09 ` [Xen-devel] [PATCH V3 5/8] iommu/arm: Add lightweight iommu_fwspec support Oleksandr Tyshchenko
2019-09-09 14:36 ` Julien Grall
2019-09-09 14:41 ` Oleksandr
2019-08-20 18:09 ` [Xen-devel] [PATCH V3 6/8] iommu: Add of_xlate callback Oleksandr Tyshchenko
2019-08-27 13:30 ` Jan Beulich
2019-08-27 14:59 ` Oleksandr
2019-08-27 15:11 ` Jan Beulich
2019-09-09 12:37 ` Julien Grall
2019-09-09 14:28 ` Oleksandr
2019-08-20 18:09 ` [Xen-devel] [PATCH V3 7/8] iommu/arm: Introduce iommu_add_dt_device API Oleksandr Tyshchenko
2019-09-09 15:04 ` Julien Grall
2019-09-09 15:48 ` Oleksandr
2019-09-10 13:34 ` Oleksandr
2019-09-10 14:30 ` Julien Grall
2019-08-20 18:09 ` [Xen-devel] [PATCH V3 8/8] iommu/arm: Add Renesas IPMMU-VMSA support Oleksandr Tyshchenko
2019-08-29 8:37 ` Yoshihiro Shimoda
2019-08-29 10:56 ` Oleksandr
2019-09-02 7:04 ` Yoshihiro Shimoda
2019-09-09 14:33 ` Oleksandr
2019-08-29 11:19 ` Oleksandr
2019-09-09 21:24 ` Julien Grall
2019-09-10 11:04 ` Oleksandr
2019-09-10 14:31 ` Julien Grall
2019-09-11 15:29 ` Oleksandr
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=ff171664-8ddc-9072-e38a-f9d9cf5100e0@gmail.com \
--to=olekstysh@gmail.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=julien.grall@arm.com \
--cc=oleksandr_tyshchenko@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).