[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 7/8] xen/arm: Add support for SMMUv3 driver


  • To: Julien Grall <julien@xxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Mon, 14 Dec 2020 19:08:55 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rSGFIJzYlh9dzy54T2HBNgmjSVHU+KuivH0e2qBhJxQ=; b=HeCWn+KIK2r1O9vpAVkVKs/OUXYJ1Az4yKUX/7XsF5VZmjeMmSxxxKQbL+RR7FxlT4zHU+i1apd0c3QGQRCnvYxFgGz7Uenn5g9V84MnyTt1FLB4XOX8Zc6gldFvV/v//IpCpa7BdpRcEgE7q2wY/roGoQjYrNEpjo8WCloy3nb/pY5/+Dc/GBEhDaj0j7VfR9rNHEd4J3bK0cr1arkL2IaFGRTDXMh5By9lXZ4Xh1+vQC9GNvu9j2sj3tI+idQeyoa6MTVK0lwk8FW2n9blnKDidE4A+JVdfqqGD6usPSVUABZaqWMkA55XuS26DP/n/wwJ84QZuuzuzkaucu6lCA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GozBHyOnQMYnJt74974pwseYItNf4GTTbHH0o8LkHJKA/cIbPHiL8Ex+glvmSqpp+yA70znOBiOgudu3Z6gWAxsUJWqNzos0KbvMMcsHhLTZaDU9/dG300jvw3selVn0m0amJM7slMl4xcyHGQz8lvtuREciMRZGMxwNPE8gBxw+TtJ/BqtJ+FnqJvcSt4hLSguqUISoAXRHl4Us7o2qxgZjFlk57B6TkyIkJ8R+Zrza9KGPl/m+n8tHootNZYTHUzK1KB1TFz+Kt2l4w/My821dB6iqDlqJbnbKQW4T7EwyuFt8WjiqAQWigQkcs7IRVbTocKUs2xb+jwYmrtzREw==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 14 Dec 2020 19:09:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWzxYvTK5u+0PVw0yI12PrfGSPTKnx9LwAgAUFtoA=
  • Thread-topic: [PATCH v3 7/8] xen/arm: Add support for SMMUv3 driver

Hello Julien,

> On 11 Dec 2020, at 2:25 pm, Julien Grall <julien@xxxxxxx> 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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.