All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr <olekstysh@gmail.com>
To: Rahul Singh <Rahul.Singh@arm.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Bertrand Marquis <Bertrand.Marquis@arm.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Ian Jackson <iwj@xenproject.org>, Jan Beulich <jbeulich@suse.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Paul Durrant <paul@xen.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v4 11/11] xen/arm: smmuv3: Add support for SMMUv3 driver
Date: Mon, 18 Jan 2021 18:20:49 +0200	[thread overview]
Message-ID: <03135a22-676b-6642-0fb3-4e3bb62cf014@gmail.com> (raw)
In-Reply-To: <5405ECAE-F22F-4893-B302-5D48C57A8847@arm.com>


On 18.01.21 17:33, Rahul Singh wrote:
> Hello Oleksandr,
>
>> On 11 Jan 2021, at 4:39 pm, Oleksandr <olekstysh@gmail.com> wrote:
>>
>>
>> Hi Rahul

Hi Rahul


>>
>>
>>>> -
>>>>    static int arm_smmu_device_probe(struct platform_device *pdev)
>>>>    {
>>>>        int irq, ret;
>>>> -    struct resource *res;
>>>> -    resource_size_t ioaddr;
>>>> +    paddr_t ioaddr, iosize;
>>>>        struct arm_smmu_device *smmu;
>>>> -    struct device *dev = &pdev->dev;
>>>> -    bool bypass;
>>>>    -    smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL);
>>>> +    smmu = xzalloc(struct arm_smmu_device);
>>>>        if (!smmu) {
>>>> -        dev_err(dev, "failed to allocate arm_smmu_device\n");
>>>> +        dev_err(pdev, "failed to allocate arm_smmu_device\n");
>>>>            return -ENOMEM;
>>>>        }
>>>> -    smmu->dev = dev;
>>>> +    smmu->dev = pdev;
>>>>    -    if (dev->of_node) {
>>>> +    if (pdev->of_node) {
>>>>            ret = arm_smmu_device_dt_probe(pdev, smmu);
>>>> +        if (ret)
>>>> +            return -EINVAL;
>>>>        } else {
>>>>            ret = arm_smmu_device_acpi_probe(pdev, smmu);
>>>>            if (ret == -ENODEV)
>>>>                return ret;
>>>>        }
>>>>    -    /* Set bypass mode according to firmware probing result */
>>>> -    bypass = !!ret;
>>>> -
>>>>        /* Base address */
>>>> -    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> -    if (resource_size(res) < arm_smmu_resource_size(smmu)) {
>>>> -        dev_err(dev, "MMIO region too small (%pr)\n", res);
>>>> +    ret = dt_device_get_address(dev_to_dt(pdev), 0, &ioaddr, &iosize);
>>>> +    if (ret)
>>>> +        return -ENODEV;
>>>> +
>>>> +    if (iosize < arm_smmu_resource_size(smmu)) {
>>>> +        dev_err(pdev, "MMIO region too small (%lx)\n", iosize);
>>>>            return -EINVAL;
>>>>        }
>>>> -    ioaddr = res->start;
>>>>          /*
>>>>         * Don't map the IMPLEMENTATION DEFINED regions, since they may contain
>>>> -     * the PMCG registers which are reserved by the PMU driver.
>>>> +     * the PMCG registers which are optional and currently not supported.
>>>>         */
>>>> -    smmu->base = arm_smmu_ioremap(dev, ioaddr, ARM_SMMU_REG_SZ);
>>>> +    smmu->base = ioremap_nocache(ioaddr, ARM_SMMU_REG_SZ);
>>>>        if (IS_ERR(smmu->base))
>>>>            return PTR_ERR(smmu->base);
>>>>    -    if (arm_smmu_resource_size(smmu) > SZ_64K) {
>>>> -        smmu->page1 = arm_smmu_ioremap(dev, ioaddr + SZ_64K,
>>>> +    if (iosize > SZ_64K) {
>>>> +        smmu->page1 = ioremap_nocache(ioaddr + SZ_64K,
>>>>                               ARM_SMMU_REG_SZ);
>>>>            if (IS_ERR(smmu->page1))
>>>>                return PTR_ERR(smmu->page1);
>>>> @@ -2765,14 +3101,262 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>>>>            return ret;
>>>>          /* Reset the device */
>>>> -    ret = arm_smmu_device_reset(smmu, bypass);
>>>> +    ret = arm_smmu_device_reset(smmu);
>>>>        if (ret)
>>>>            return ret;
>>>>    +    /*
>>>> +     * Keep a list of all probed devices. This will be used to query
>>>> +     * the smmu devices based on the fwnode.
>>>> +     */
>>>> +    INIT_LIST_HEAD(&smmu->devices);
>>>> +
>>>> +    spin_lock(&arm_smmu_devices_lock);
>>>> +    list_add(&smmu->devices, &arm_smmu_devices);
>>>> +    spin_unlock(&arm_smmu_devices_lock);
>> Looks like that we need some kind of manual roll-back logic here in case of error during probe (there is no real devm_*):
>>
>> iounmap, xfree, etc.
> I agree with you that manual roll-back logic is good to have clean code but in this scenario what I have found out that if there is an error during probe arm_smmu_device_probe() will return and XEN will not continue to boot (call panic function) , in that case if we free the memory also there is no much difference. That why I decided not to modify the code that we ported from Linux.
>
> XEN) I/O virtualisation disabled
> (XEN)
> (XEN) ****************************************
> (XEN) Panic on CPU 0:
> (XEN) Couldn't configure correctly all the IOMMUs.
> (XEN) ****************************************
> (XEN)
> (XEN) Manual reset required ('noreboot' specified)
>
> Do we have a requirement to continue to boot the XEN if there is an IOMMU available in the system and IOMMU probe is failed? If yes then I will modify the code to free all the resources if there is error during probe.

Xen won't call panic if IOMMU driver returns -ENODEV and will continue 
to boot. For example, if the IOMMU is present but cannot be used in Xen 
for some reason (doesn't support page table sharing, etc)


-- 
Regards,

Oleksandr Tyshchenko



  reply	other threads:[~2021-01-18 16:21 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 14:46 [PATCH v4 00/11] xen/arm: Add support for SMMUv3 driver Rahul Singh
2021-01-08 14:46 ` [PATCH v4 01/11] xen/arm: smmuv3: Import the SMMUv3 driver from Linux Rahul Singh
2021-01-08 23:42   ` Stefano Stabellini
2021-01-15 11:55   ` Julien Grall
2021-01-08 14:46 ` [PATCH v4 02/11] xen/arm: Revert atomic operation related command-queue insertion patch Rahul Singh
2021-01-08 23:43   ` Stefano Stabellini
2021-01-08 14:46 ` [PATCH v4 03/11] xen/arm: smmuv3: Revert patch related to XArray Rahul Singh
2021-01-08 23:43   ` Stefano Stabellini
2021-01-08 14:46 ` [PATCH v4 04/11] xen/arm: smmuv3: Remove support for Stage-1 translation on SMMUv3 Rahul Singh
2021-01-08 23:52   ` Stefano Stabellini
2021-01-08 14:46 ` [PATCH v4 05/11] xen/arm: smmuv3: Remove Linux specific code that is not usable in XEN Rahul Singh
2021-01-08 23:56   ` Stefano Stabellini
2021-01-12 11:38   ` Bertrand Marquis
2021-01-08 14:46 ` [PATCH v4 06/11] xen/device-tree: Add dt_property_match_string helper Rahul Singh
2021-01-08 23:57   ` Stefano Stabellini
2021-01-12 11:38   ` Bertrand Marquis
2021-01-08 14:46 ` [PATCH v4 07/11] xen/arm: bitops: Implement a ffsll function Rahul Singh
2021-01-09  1:44   ` Stefano Stabellini
2021-01-12 11:35   ` Bertrand Marquis
2021-01-15 12:16   ` Julien Grall
2021-01-18 15:32     ` Rahul Singh
2021-01-08 14:46 ` [PATCH v4 08/11] xen/compiler: import 'fallthrough' keyword from linux Rahul Singh
2021-01-09  1:44   ` Stefano Stabellini
2021-01-12 11:36   ` Bertrand Marquis
2021-01-12 11:41   ` Jan Beulich
2021-01-12 23:30     ` Stefano Stabellini
2021-01-12 23:40       ` Stefano Stabellini
2021-01-14  9:04       ` Jan Beulich
2021-01-14 23:47         ` Stefano Stabellini
2021-01-15 12:14           ` Rahul Singh
2021-01-15 13:09             ` Jan Beulich
2021-01-15 17:56               ` Stefano Stabellini
2021-01-08 14:46 ` [PATCH v4 09/11] xen/arm: smmuv3: Use fallthrough pseudo-keyword Rahul Singh
2021-01-09  1:44   ` Stefano Stabellini
2021-01-09 18:57     ` Rahul Singh
2021-01-12 11:34   ` Bertrand Marquis
2021-01-15 12:18   ` Julien Grall
2021-01-18 15:33     ` Rahul Singh
2021-01-08 14:46 ` [PATCH v4 10/11] xen/arm: smmuv3: Replace linux functions with xen functions Rahul Singh
2021-01-09  1:44   ` Stefano Stabellini
2021-01-12 11:35   ` Bertrand Marquis
2021-01-08 14:46 ` [PATCH v4 11/11] xen/arm: smmuv3: Add support for SMMUv3 driver Rahul Singh
2021-01-09  1:45   ` Stefano Stabellini
2021-01-11 16:09   ` Oleksandr
2021-01-11 16:39     ` Oleksandr
2021-01-18 15:33       ` Rahul Singh
2021-01-18 16:20         ` Oleksandr [this message]
2021-01-18 16:57           ` Rahul Singh
2021-01-19 14:43             ` Oleksandr
2021-01-19 14:53               ` Rahul Singh
2021-01-12  9:41     ` Rahul Singh
2021-01-12 20:59       ` Oleksandr
2021-01-15 12:38         ` Rahul Singh
2021-01-15 12:40           ` Julien Grall
2021-01-15 12:37   ` Julien Grall

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=03135a22-676b-6642-0fb3-4e3bb62cf014@gmail.com \
    --to=olekstysh@gmail.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Rahul.Singh@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=paul@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.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 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.