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

Re: [PATCH] iommu/amd-vi: fix checking for Invalidate All support in amd_iommu_resume()


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 13 Jun 2023 14:45:28 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DwPh9ozuKxsTkqXgll8Bs25n4xuoiBrH5vo5FKhInbk=; b=mtLpm8KZsyoT/zcnTtvdTG8yZvx5yreEIzZqOH4c7L882LUFOeiGn91T3TKzhlhdYLH1l6fjmKsHeOFrsC7g6tCVvK0oXd4i1lTiWzQi4s/DkbsKeV2NKlk6BodV9zH0e/aDBCLVxT1sBLzPomm0N8WmQUMffIJpS4CyYP9fyZ9gphU2W32IFrED4igyHyMdiJlOkvmi+dibNwt/QU6pUEpJC+VdNayBFt33Mw07x6aOJhL4RFLhqbzXwklcw6T6NlfHpPF3U4oK+NqDeZmZZ4ND9KT8VAFi3utjZUfB9/TDG4lSupmjiZyWbXtvL6reG3imORMddlOBV3YBiWxfhQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=huhgTdSjP7ajmhL11JB6kaIv0hoWQ7q2KRjS62AI1WCghVxWli6Q/cUM8GpPtVTrc1I3rsIl0c8yA7xK7tFD7wzpvMHLsU6/ycf4JPeFOOTJPY0PJGnjfIQf1OEVzHTLXDgiKHP1coo045Mij9WfPlVVTUMKpPAjB4rvf7GfnEhB9r0FqM9SCyW9U2D5vTc1KKJ7TuqokTdBxkgRR4gHUVdqued6xIyY0hCQCJlfLKQL+RdOFnyD4dwpA3oLiDCG2QUy7zw7p0lyBCv92c8B8jp0upVj2/9BfLK+uGLopZL1e5m6d5jK7sIncjgx8iyvTUfAwh4q2rEfneu0tS5Z/g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 13 Jun 2023 12:45:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13.06.2023 12:33, Roger Pau Monné wrote:
> On Tue, Jun 13, 2023 at 12:23:37PM +0200, Jan Beulich wrote:
>> On 13.06.2023 12:13, Roger Pau Monne wrote:
>>> Do not rely on iommu local variable pointing to a valid amd_iommu
>>
>> "Do not rely" sounds like we might, but we choose not to. But we may
>> not rely on this, as the pointer simply isn't valid to deref past
>> the loop. Hence perhaps better "We cannot rely ..." or even "The
>> iommu local variable does not point to ..."?
> 
> "Xen cannot rely ..." doesn't modify the sentence too much and could
> likely be adjusted at commit if you agree?
> 
> Otherwise your last suggestion would also be OK by me.

I used that latter one, as being more concise.

>>> --- a/xen/drivers/passthrough/amd/iommu_init.c
>>> +++ b/xen/drivers/passthrough/amd/iommu_init.c
>>> @@ -1580,6 +1580,7 @@ void cf_check amd_iommu_crash_shutdown(void)
>>>  void cf_check amd_iommu_resume(void)
>>>  {
>>>      struct amd_iommu *iommu;
>>> +    bool invalidate_all = true;
>>>  
>>>      for_each_amd_iommu ( iommu )
>>>      {
>>> @@ -1589,10 +1590,12 @@ void cf_check amd_iommu_resume(void)
>>>          */
>>>          disable_iommu(iommu);
>>>          enable_iommu(iommu);
>>> +        if ( !iommu->features.flds.ia_sup && invalidate_all )
>>
>> You don't really need the right hand part of the condition, do you?
>>
>> Preferably with the adjustments (which I'd be happy to do while
>> committing, as long as you agree)
>> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Wanted to avoid repeatedly setting `invalidate_all = false` if all the
> IOMMUs on the system don't support Invalidate All.
> 
> I don't have a strong opinion, my first (local) version didn't have
> the right hand side of the condition, but then I realized that setting
> this for every IOMMU on the system could be wasteful.

I've dropped that part: We don't care much about that tiny performance
difference here (and it's unclear whether the extra check actually is
a win or a loss), and imo the code is more clear with the simpler
conditional.

Jan



 


Rackspace

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