Skip to contentSkip to conversation

xen/arm: Add support for SMMUv3 driver

PATCH Superseded Rahul Singh 4 participants 34 messages Dec 10, 2020 – Dec 15, 2020 Page 2 of 2

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#25 lore raw
In reply to Bertrand Marquis
Quoted 1 line · Bertrand Marquis

Hi Julien,

Hi Bertrand,

Quoted 74 lines
Quoted 62 lines · Julien Grall
Quoted 1 line · Bertrand Marquis

Hi Julien,

Hi,

Quoted 52 lines
Quoted 52 lines · Julien Grall
Quoted 1 line · Rahul Singh

Hello Julien,

Hi Rahul,

Quoted 26 lines
Quoted 18 lines · Julien Grall

Hi Rahul,

Quoted 13 lines · Rahul Singh
  struct arm_smmu_strtab_cfg {
(quoted diff) +7 -1
@@ -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;
Quoted 8 lines

Review enum arm_smmu_domain_stage { · line 640

Quoted 6 lines
(quoted diff) +0 -1
  };
    /* 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?

Quoted 2 lines

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.

I think it would be better to keep the current locking until the investigation is done.

But if you still want to make this change, then you should explain in the commit message why the lock is dropped.

[...]

Quoted 5 lines

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);
}

Right, but this doesn't address the second part of my comment.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This change would *not* be necessary if the implementation of WARN_ON() in Xen return whether the warn was triggered.

Before considering to change the SMMU code, you should first attempt to modify implementation of the WARN_ON(). We can discuss other approach if the discussion goes nowhere.

The code proposed by Rahul is providing the equivalent functionality to what linux does.
Modifying WARN_ON implementation in Xen to fit how Linux version is working would make sense but should be done in its own patch as it will imply modification on more Xen code and some of it will not be related to SMMU and will need some validation.

Let me start that this was a request I already made on v2 and Rahul agreed. I saw no pushback on the request until now. So to me this meant this would be addressed in v3.

I think he agreed on the analysis but he did not say he was going to do it.

Quoted 1 line
Quoted 6 lines
Quoted 1 line

Further, the validation seems to be a common argument everytime I ask to make a change in this series... Yes validation is important, but this often doesn't require a lot of effort when the changes are simple... TBH, you are probably spending more time arguing against it.

Testing is important and effort evaluation also depends on other priorities we have.

There are 20 WARN_ON in Xen and most of them are in x86 code.
If we do this change, the serie will impact a lot more code then it originally did.

What's the problem?

Quoted 3 lines

I am not saying it should not be done, I am saying it should not be done in this serie.
Such a change would need a serie upfront and then rebasing this serie on top of it to prevent mixing stuff to much.

It is trivial enough to be part of this series. But if you prefer to create a separate series then so be it.

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

So I do not think it would be fare to ask Rahul to also do this in the scope of this serie

I would have agreed with this statement if the change is difficult. This is not the case here.

The first step when working upstream should always to improve existing helpers rather than working around it.

I agree with that statement but we should be carefull not to ask to much to people who try to contribute so that they do not feel like all changes asked are not too much to handle.

I am well aware of that and I don't think this request is asking a lot.

Quoted 5 lines

I am open to create new tasks on our side for the future when things to be improved like this ones are revealed by a serie.

If this is a blocker from your point of view, we will evaluate the effort to do this extra work and the serie will wait until january to be pushed again.

This sounds like it would require more effort than it is actually necessary. In fact...

... it took me one minute to check the existing use of WARN_ON() (all of them don't care about the return so far), another 2 minutes to write it,
an extra 5 minutes to test it and 2 minutes to write the commit message.

So a grand total of 10 minutes.

Anyway, please see the patch [1].

Cheers,

[1] https://lore.kernel.org/xen-devel/[email protected]/T/#u

Signature · 1 line
Julien Grall
#26 lore raw

Hi Julien,

Quoted 107 lines · Julien Grall
Quoted 1 line · Bertrand Marquis

Hi Julien,

Hi Bertrand,

Quoted 68 lines
Quoted 68 lines · Julien Grall
Quoted 1 line · Bertrand Marquis

Hi Julien,

Hi,

Quoted 58 lines
Quoted 50 lines · Julien Grall
Quoted 1 line · Rahul Singh

Hello Julien,

Hi Rahul,

Quoted 26 lines
Quoted 18 lines · Julien Grall

Hi Rahul,

Quoted 13 lines · Rahul Singh

struct arm_smmu_strtab_cfg {

(quoted diff) +7 -1
@@ -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;
Quoted 8 lines

Review enum arm_smmu_domain_stage { · line 640

Quoted 6 lines
(quoted diff) +0 -1
 };
   /* 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?

Quoted 2 lines

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.

I think it would be better to keep the current locking until the investigation is done.

But if you still want to make this change, then you should explain in the commit message why the lock is dropped.

[...]

Quoted 5 lines

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);
}
Quoted 5 lines

Right, but this doesn't address the second part of my comment.

This change would *not* be necessary if the implementation of WARN_ON() in Xen return whether the warn was triggered.

Before considering to change the SMMU code, you should first attempt to modify implementation of the WARN_ON(). We can discuss other approach if the discussion goes nowhere.

The code proposed by Rahul is providing the equivalent functionality to what linux does.
Modifying WARN_ON implementation in Xen to fit how Linux version is working would make sense but should be done in its own patch as it will imply modification on more Xen code and some of it will not be related to SMMU and will need some validation.

Quoted 7 lines
Quoted 1 line

Let me start that this was a request I already made on v2 and Rahul agreed. I saw no pushback on the request until now. So to me this meant this would be addressed in v3.

I think he agreed on the analysis but he did not say he was going to do it.

Quoted 2 lines

Further, the validation seems to be a common argument everytime I ask to make a change in this series... Yes validation is important, but this often doesn't require a lot of effort when the changes are simple... TBH, you are probably spending more time arguing against it.

Testing is important and effort evaluation also depends on other priorities we have. There are 20 WARN_ON in Xen and most of them are in x86 code.
If we do this change, the serie will impact a lot more code then it originally did.

What's the problem?

Quoted 2 lines

I am not saying it should not be done, I am saying it should not be done in this serie.
Such a change would need a serie upfront and then rebasing this serie on top of it to prevent mixing stuff to much.

It is trivial enough to be part of this series. But if you prefer to create a separate series then so be it.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

So I do not think it would be fare to ask Rahul to also do this in the scope of this serie

I would have agreed with this statement if the change is difficult. This is not the case here.

The first step when working upstream should always to improve existing helpers rather than working around it.

I agree with that statement but we should be carefull not to ask to much to people who try to contribute so that they do not feel like all changes asked are not too much to handle.

I am well aware of that and I don't think this request is asking a lot.

Quoted 4 lines

I am open to create new tasks on our side for the future when things to be improved like this ones are revealed by a serie.
If this is a blocker from your point of view, we will evaluate the effort to do this extra work and the serie will wait until january to be pushed again.

Quoted 5 lines

This sounds like it would require more effort than it is actually necessary. In fact...

... it took me one minute to check the existing use of WARN_ON() (all of them don't care about the return so far), another 2 minutes to write it, an extra 5 minutes to test it and 2 minutes to write the commit message.

So a grand total of 10 minutes.

Sadly what takes 10 minutes on your side is not taking the same effort on our side for now (due to internal review, validation and required tests).

Quoted 2 lines

Anyway, please see the patch [1].

Thanks for that.
We will review it and rebase the SMMU serie on top of it.

Cheers
Bertrand

Quoted 7 lines

Cheers,

[1] https://lore.kernel.org/xen-devel/[email protected]/T/#u

Signature · 1 line
Julien Grall