@@ -48,23 +48,6 @@ static void *pasid_private_find(ioasid_t pasid)
48
48
return xa_load (& pasid_private_array , pasid );
49
49
}
50
50
51
- static struct intel_svm_dev *
52
- svm_lookup_device_by_sid (struct intel_svm * svm , u16 sid )
53
- {
54
- struct intel_svm_dev * sdev = NULL , * t ;
55
-
56
- rcu_read_lock ();
57
- list_for_each_entry_rcu (t , & svm -> devs , list ) {
58
- if (t -> sid == sid ) {
59
- sdev = t ;
60
- break ;
61
- }
62
- }
63
- rcu_read_unlock ();
64
-
65
- return sdev ;
66
- }
67
-
68
51
static struct intel_svm_dev *
69
52
svm_lookup_device_by_dev (struct intel_svm * svm , struct device * dev )
70
53
{
@@ -706,11 +689,10 @@ static void handle_bad_prq_event(struct intel_iommu *iommu,
706
689
707
690
static irqreturn_t prq_event_thread (int irq , void * d )
708
691
{
709
- struct intel_svm_dev * sdev = NULL ;
710
692
struct intel_iommu * iommu = d ;
711
- struct intel_svm * svm = NULL ;
712
693
struct page_req_dsc * req ;
713
694
int head , tail , handled ;
695
+ struct pci_dev * pdev ;
714
696
u64 address ;
715
697
716
698
/*
@@ -730,8 +712,6 @@ static irqreturn_t prq_event_thread(int irq, void *d)
730
712
pr_err ("IOMMU: %s: Page request without PASID\n" ,
731
713
iommu -> name );
732
714
bad_req :
733
- svm = NULL ;
734
- sdev = NULL ;
735
715
handle_bad_prq_event (iommu , req , QI_RESP_INVALID );
736
716
goto prq_advance ;
737
717
}
@@ -758,34 +738,19 @@ static irqreturn_t prq_event_thread(int irq, void *d)
758
738
if (unlikely (req -> lpig && !req -> rd_req && !req -> wr_req ))
759
739
goto prq_advance ;
760
740
761
- if (!svm || svm -> pasid != req -> pasid ) {
762
- /*
763
- * It can't go away, because the driver is not permitted
764
- * to unbind the mm while any page faults are outstanding.
765
- */
766
- svm = pasid_private_find (req -> pasid );
767
- if (IS_ERR_OR_NULL (svm ) || (svm -> flags & SVM_FLAG_SUPERVISOR_MODE ))
768
- goto bad_req ;
769
- }
770
-
771
- if (!sdev || sdev -> sid != req -> rid ) {
772
- sdev = svm_lookup_device_by_sid (svm , req -> rid );
773
- if (!sdev )
774
- goto bad_req ;
775
- }
776
-
777
- sdev -> prq_seq_number ++ ;
778
-
741
+ pdev = pci_get_domain_bus_and_slot (iommu -> segment ,
742
+ PCI_BUS_NUM (req -> rid ),
743
+ req -> rid & 0xff );
779
744
/*
780
745
* If prq is to be handled outside iommu driver via receiver of
781
746
* the fault notifiers, we skip the page response here.
782
747
*/
783
- if (intel_svm_prq_report (iommu , sdev -> dev , req ))
748
+ if (! pdev || intel_svm_prq_report (iommu , & pdev -> dev , req ))
784
749
handle_bad_prq_event (iommu , req , QI_RESP_INVALID );
785
750
786
- trace_prq_report (iommu , sdev -> dev , req -> qw_0 , req -> qw_1 ,
751
+ trace_prq_report (iommu , & pdev -> dev , req -> qw_0 , req -> qw_1 ,
787
752
req -> priv_data [0 ], req -> priv_data [1 ],
788
- sdev -> prq_seq_number );
753
+ iommu -> prq_seq_number ++ );
789
754
prq_advance :
790
755
head = (head + sizeof (* req )) & PRQ_RING_MASK ;
791
756
}
@@ -881,8 +846,6 @@ int intel_svm_page_response(struct device *dev,
881
846
struct iommu_page_response * msg )
882
847
{
883
848
struct iommu_fault_page_request * prm ;
884
- struct intel_svm_dev * sdev = NULL ;
885
- struct intel_svm * svm = NULL ;
886
849
struct intel_iommu * iommu ;
887
850
bool private_present ;
888
851
bool pasid_present ;
@@ -901,8 +864,6 @@ int intel_svm_page_response(struct device *dev,
901
864
if (!msg || !evt )
902
865
return - EINVAL ;
903
866
904
- mutex_lock (& pasid_mutex );
905
-
906
867
prm = & evt -> fault .prm ;
907
868
sid = PCI_DEVID (bus , devfn );
908
869
pasid_present = prm -> flags & IOMMU_FAULT_PAGE_REQUEST_PASID_VALID ;
@@ -919,12 +880,6 @@ int intel_svm_page_response(struct device *dev,
919
880
goto out ;
920
881
}
921
882
922
- ret = pasid_to_svm_sdev (dev , prm -> pasid , & svm , & sdev );
923
- if (ret || !sdev ) {
924
- ret = - ENODEV ;
925
- goto out ;
926
- }
927
-
928
883
/*
929
884
* Per VT-d spec. v3.0 ch7.7, system software must respond
930
885
* with page group response if private data is present (PDP)
@@ -954,6 +909,5 @@ int intel_svm_page_response(struct device *dev,
954
909
qi_submit_sync (iommu , & desc , 1 , 0 );
955
910
}
956
911
out :
957
- mutex_unlock (& pasid_mutex );
958
912
return ret ;
959
913
}
0 commit comments