All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Rahul Singh <Rahul.Singh@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>
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>,
	Wei Liu <wl@xen.org>, Paul Durrant <paul@xen.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v5 10/10] xen/arm: smmuv3: Add support for SMMUv3 driver
Date: Thu, 21 Jan 2021 18:43:10 +0000	[thread overview]
Message-ID: <81104729-0354-f479-9329-04447df1b096@xen.org> (raw)
In-Reply-To: <9621B25B-E39A-4354-9AA3-1ECAED21B8B2@arm.com>

Hi Rahul,

Please try to trim the e-mail when quoting, otherwise it is quite 
difficult to find the only couple of answer you wrote.

On 21/01/2021 17:10, Rahul Singh wrote:
>> On 20 Jan 2021, at 8:31 pm, Stefano Stabellini <sstabellini@kernel.org> wrote:
>>> -static void __iomem *arm_smmu_ioremap(struct device *dev, resource_size_t start,
>>> -				      resource_size_t size)
>>> +
>>> +static void arm_smmu_free_structures(struct arm_smmu_device *smmu)
>>> {
>>> -	struct resource res = {
>>> -		.flags = IORESOURCE_MEM,
>>> -		.start = start,
>>> -		.end = start + size - 1,
>>> -	};
>>> +	if (smmu->cmdq.q.base)
>>> +		xfree(smmu->cmdq.q.base);
>>> +
>>> +	if (smmu->evtq.q.base)
>>> +		xfree(smmu->evtq.q.base);
>>>
>>> -	return devm_ioremap_resource(dev, &res);
>>> +	if (smmu->priq.q.base)
>>> +		xfree(smmu->priq.q.base);
>>> +
>>> +	if (smmu->strtab_cfg.strtab)
>>> +		xfree(smmu->strtab_cfg.strtab);
>>> +
>>> +	if (smmu->strtab_cfg.l1_desc)
>>> +		xfree(smmu->strtab_cfg.l1_desc);
>>
>>  From what I can tell we also need to free somewhere
>> smmu->strtab_cfg->l1_desc->l2ptr allocated by arm_smmu_init_l2_strtab
> 
> "l1_desc->l2ptr" is a pointer to the Level 1 Stream Table Descriptor if 2-level Stream Table supported.
> 
> If the device is protected by IOMMU, SMMUv3 driver will allocate the  "l1_desc->l2ptr” when the device is added to the IOMMU via arm_smmu_add_device() function and device will be configured in bypass/abort mode.
> 
> Once we assign the device to the domain(arm_smmu_assign_dev() ) smmuv3 hw will be configured correctly to match the StreamID. If there is a failure in assigning the device, that case also XEN will not remove the device and master device still be in bypass/abort mode.

I am a bit confused with this answer. Wouldn't this mean that we are 
"leaking" memory if we fail to assign the device?

> 
> As in XEN, there is no function to remove the master device from the IOMMU, because of that I feel there is no need to free the "l1_desc->l2ptr” in case of failure also.

Hmmm... Xen is able to remove device from the IOMMU. The reason this is 
not implemented yet on Arm is because you can't hot-unplug "platform" 
device.

I expect the removal function to be useful for PCI.

Cheers,

-- 
Julien Grall


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

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 14:52 [PATCH v5 00/10] xen/arm: Add support for SMMUv3 driver Rahul Singh
2021-01-20 14:52 ` [PATCH v5 01/10] xen/arm: smmuv3: Import the SMMUv3 driver from Linux Rahul Singh
2021-01-20 14:52 ` [PATCH v5 02/10] xen/arm: Revert atomic operation related command-queue insertion patch Rahul Singh
2021-01-20 14:52 ` [PATCH v5 03/10] xen/arm: smmuv3: Revert patch related to XArray Rahul Singh
2021-01-20 14:52 ` [PATCH v5 04/10] xen/arm: smmuv3: Remove support for Stage-1 translation on SMMUv3 Rahul Singh
2021-01-20 14:52 ` [PATCH v5 05/10] xen/arm: smmuv3: Remove Linux specific code that is not usable in XEN Rahul Singh
2021-01-20 14:52 ` [PATCH v5 06/10] xen/device-tree: Add dt_property_match_string helper Rahul Singh
2021-01-20 14:52 ` [PATCH v5 07/10] xen/compiler: import 'fallthrough' keyword from linux Rahul Singh
2021-01-20 14:52 ` [PATCH v5 08/10] xen/arm: smmuv3: Use fallthrough pseudo-keyword Rahul Singh
2021-01-20 15:36   ` Bertrand Marquis
2021-01-20 19:56   ` Stefano Stabellini
2021-01-20 14:52 ` [PATCH v5 09/10] xen/arm: smmuv3: Replace linux functions with xen functions Rahul Singh
2021-01-20 14:52 ` [PATCH v5 10/10] xen/arm: smmuv3: Add support for SMMUv3 driver Rahul Singh
2021-01-20 15:35   ` Bertrand Marquis
2021-01-20 20:31   ` Stefano Stabellini
2021-01-21 17:10     ` Rahul Singh
2021-01-21 18:43       ` Julien Grall [this message]
2021-01-21 20:28         ` Rahul Singh
2021-01-21 21:20           ` Stefano Stabellini
2021-01-20 21:33   ` Oleksandr
2021-01-21 17:18     ` Rahul Singh
2021-01-21 18:31       ` Julien Grall
2021-01-21 18:50         ` Rahul Singh
2021-01-21 20:19           ` 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=81104729-0354-f479-9329-04447df1b096@xen.org \
    --to=julien@xen.org \
    --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=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.