All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rahul Singh <Rahul.Singh@arm.com>
To: Julien Grall <julien@xen.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>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Paul Durrant <paul@xen.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v3 7/8] xen/arm: Add support for SMMUv3 driver
Date: Mon, 14 Dec 2020 19:08:55 +0000	[thread overview]
Message-ID: <1660236F-7BB0-4F3E-8CDD-10AE9282E2A3@arm.com> (raw)
In-Reply-To: <e26c96cb-245b-6927-c4a7-224c2114df42@xen.org>

Hello Julien,

> On 11 Dec 2020, at 2:25 pm, Julien Grall <julien@xen.org> wrote:
> 
> Hi Rahul,
> 
> On 10/12/2020 16:57, Rahul Singh wrote:
>>  struct arm_smmu_strtab_cfg {
>> @@ -613,8 +847,13 @@ struct arm_smmu_device {
>>  		u64			padding;
>>  	};
>>  -	/* IOMMU core code handle */
>> -	struct iommu_device		iommu;
>> +	/* Need to keep a list of SMMU devices */
>> +	struct list_head		devices;
>> +
>> +	/* Tasklets for handling evts/faults and pci page request IRQs*/
>> +	struct tasklet		evtq_irq_tasklet;
>> +	struct tasklet		priq_irq_tasklet;
>> +	struct tasklet		combined_irq_tasklet;
>>  };
>>    /* SMMU private data for each master */
>> @@ -638,7 +877,6 @@ enum arm_smmu_domain_stage {
>>    struct arm_smmu_domain {
>>  	struct arm_smmu_device		*smmu;
>> -	struct mutex			init_mutex; /* Protects smmu pointer */
> 
> Hmmm... Your commit message says the mutex would be replaced by a spinlock. However, you are dropping the lock. What I did miss?

Linux code using the mutex in the function arm_smmu_attach_dev() but in XEN this function is called from arm_smmu_assign_dev() which already has the spin_lock when arm_smmu_attach_dev() function I called so I drop the mutex to avoid nested spinlock. 
Timing analysis of using spin lock in place of mutex as compared to linux  when attaching a  device to SMMU is still valid.

> 
> [...]
> 
>> @@ -1578,6 +1841,17 @@ static int arm_smmu_domain_finalise_s2(struct arm_smmu_domain *smmu_domain,
>>  	struct arm_smmu_device *smmu = smmu_domain->smmu;
>>  	struct arm_smmu_s2_cfg *cfg = &smmu_domain->s2_cfg;
>>  	typeof(&arm_lpae_s2_cfg.vtcr) vtcr = &arm_lpae_s2_cfg.vtcr;
>> +	uint64_t reg = READ_SYSREG64(VTCR_EL2);
> 
> Please don't use VTCR_EL2 here. You should be able to infer the parameter from the p2m_ipa_bits.

Ok.

> 
> Also, I still don't see code that will restrict the IPA bits because on the support for the SMMU.

Ok I will add the code to restrict the IPA bits in next version.
> 
>> +
>> +	vtcr->tsz	= FIELD_GET(STRTAB_STE_2_VTCR_S2T0SZ, reg);
>> +	vtcr->sl	= FIELD_GET(STRTAB_STE_2_VTCR_S2SL0, reg);
>> +	vtcr->irgn	= FIELD_GET(STRTAB_STE_2_VTCR_S2IR0, reg);
>> +	vtcr->orgn	= FIELD_GET(STRTAB_STE_2_VTCR_S2OR0, reg);
>> +	vtcr->sh	= FIELD_GET(STRTAB_STE_2_VTCR_S2SH0, reg);
>> +	vtcr->tg	= FIELD_GET(STRTAB_STE_2_VTCR_S2TG, reg);
>> +	vtcr->ps	= FIELD_GET(STRTAB_STE_2_VTCR_S2PS, reg);
>> +
>> +	arm_lpae_s2_cfg.vttbr  = page_to_maddr(cfg->domain->arch.p2m.root);
>>    	vmid = arm_smmu_bitmap_alloc(smmu->vmid_map, smmu->vmid_bits);
>>  	if (vmid < 0)
>> @@ -1592,6 +1866,11 @@ static int arm_smmu_domain_finalise_s2(struct arm_smmu_domain *smmu_domain,
>>  			  FIELD_PREP(STRTAB_STE_2_VTCR_S2SH0, vtcr->sh) |
>>  			  FIELD_PREP(STRTAB_STE_2_VTCR_S2TG, vtcr->tg) |
>>  			  FIELD_PREP(STRTAB_STE_2_VTCR_S2PS, vtcr->ps);
>> +
>> +	printk(XENLOG_DEBUG
>> +		   "SMMUv3: d%u: vmid 0x%x vtcr 0x%"PRIpaddr" p2maddr 0x%"PRIpaddr"\n",
>> +		   cfg->domain->domain_id, cfg->vmid, cfg->vtcr, cfg->vttbr);
>> +
>>  	return 0;
>>  }
> 
> [...]
> 
>> @@ -1923,8 +2239,8 @@ static int arm_smmu_init_one_queue(struct arm_smmu_device *smmu,
>>  		return -ENOMEM;
>>  	}
>>  -	if (!WARN_ON(q->base_dma & (qsz - 1))) { > -		dev_info(smmu->dev, "allocated %u entries for %s\n",
>> +	if (unlikely(q->base_dma & (qsz - 1))) {
>> +		dev_warn(smmu->dev, "allocated %u entries for %s\n",
> dev_warn() is not the same as WARN_ON(). But really, the first step is for you to try to change behavior of WARN_ON() in Xen.

Ok. I will make sure we have the same behaviour as linux by modifying the code as below.

WARN_ON(q->base_dma & (qsz - 1));
if (!unlikely(q->base_dma & (qsz - 1))) {
	dev_info(smmu->dev, "allocated %u entries for %s\n",
		1 << q->llq.max_n_shift, name);
}

Regards,
Rahul

> 
> If this doesn't go through then we can discuss about approach to mitigate it.
> 
> Cheers,
> 
> -- 
> Julien Grall



  reply	other threads:[~2020-12-14 19:09 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 16:56 [PATCH v3 0/8] xen/arm: Add support for SMMUv3 driver Rahul Singh
2020-12-10 16:56 ` [PATCH v3 1/8] xen/arm: Import the SMMUv3 driver from Linux Rahul Singh
2020-12-11  1:28   ` Stefano Stabellini
2020-12-10 16:57 ` [PATCH v3 2/8] xen/arm: revert atomic operation related command-queue insertion patch Rahul Singh
2020-12-11  1:28   ` Stefano Stabellini
2020-12-10 16:57 ` [PATCH v3 3/8] xen/arm: revert patch related to XArray Rahul Singh
2020-12-11  1:28   ` Stefano Stabellini
2020-12-10 16:57 ` [PATCH v3 4/8] xen/arm: Remove support for Stage-1 translation on SMMUv3 Rahul Singh
2020-12-11  1:28   ` Stefano Stabellini
2020-12-11 10:46     ` Rahul Singh
2020-12-10 16:57 ` [PATCH v3 5/8] xen/device-tree: Add dt_property_match_string helper Rahul Singh
2020-12-11  1:28   ` Stefano Stabellini
2020-12-11 13:13   ` Bertrand Marquis
2020-12-10 16:57 ` [PATCH v3 6/8] xen/arm: Remove Linux specific code that is not usable in XEN Rahul Singh
2020-12-11  1:29   ` Stefano Stabellini
2020-12-11 13:16   ` Bertrand Marquis
2020-12-10 16:57 ` [PATCH v3 7/8] xen/arm: Add support for SMMUv3 driver Rahul Singh
2020-12-11  1:28   ` Stefano Stabellini
2020-12-11 19:43     ` Rahul Singh
2020-12-11 14:25   ` Julien Grall
2020-12-14 19:08     ` Rahul Singh [this message]
2020-12-14 19:35       ` Julien Grall
2020-12-15  9:42         ` Bertrand Marquis
2020-12-15 10:13           ` Julien Grall
2020-12-15 10:51             ` Bertrand Marquis
2020-12-15 11:31               ` Julien Grall
2020-12-15 11:35                 ` Bertrand Marquis
2020-12-10 16:57 ` [PATCH v3 8/8] xen/arm: smmuv3: Remove linux compatibility functions Rahul Singh
2020-12-11  1:29   ` Stefano Stabellini
2020-12-11 13:15   ` Bertrand Marquis
2020-12-11 13:57   ` Julien Grall
2020-12-11 14:29 ` [PATCH v3 0/8] xen/arm: Add support for SMMUv3 driver Julien Grall
2020-12-14 20:01   ` Rahul Singh
2020-12-15  1:52     ` Stefano Stabellini

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=1660236F-7BB0-4F3E-8CDD-10AE9282E2A3@arm.com \
    --to=rahul.singh@arm.com \
    --cc=Bertrand.Marquis@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.