@@ -777,6 +777,133 @@ int pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask)
777
777
return 0 ;
778
778
}
779
779
780
+ static int pci_acs_enable ;
781
+
782
+ /**
783
+ * pci_request_acs - ask for ACS to be enabled if supported
784
+ */
785
+ void pci_request_acs (void )
786
+ {
787
+ pci_acs_enable = 1 ;
788
+ }
789
+
790
+ static const char * disable_acs_redir_param ;
791
+
792
+ /**
793
+ * pci_disable_acs_redir - disable ACS redirect capabilities
794
+ * @dev: the PCI device
795
+ *
796
+ * For only devices specified in the disable_acs_redir parameter.
797
+ */
798
+ static void pci_disable_acs_redir (struct pci_dev * dev )
799
+ {
800
+ int ret = 0 ;
801
+ const char * p ;
802
+ int pos ;
803
+ u16 ctrl ;
804
+
805
+ if (!disable_acs_redir_param )
806
+ return ;
807
+
808
+ p = disable_acs_redir_param ;
809
+ while (* p ) {
810
+ ret = pci_dev_str_match (dev , p , & p );
811
+ if (ret < 0 ) {
812
+ pr_info_once ("PCI: Can't parse disable_acs_redir parameter: %s\n" ,
813
+ disable_acs_redir_param );
814
+
815
+ break ;
816
+ } else if (ret == 1 ) {
817
+ /* Found a match */
818
+ break ;
819
+ }
820
+
821
+ if (* p != ';' && * p != ',' ) {
822
+ /* End of param or invalid format */
823
+ break ;
824
+ }
825
+ p ++ ;
826
+ }
827
+
828
+ if (ret != 1 )
829
+ return ;
830
+
831
+ if (!pci_dev_specific_disable_acs_redir (dev ))
832
+ return ;
833
+
834
+ pos = pci_find_ext_capability (dev , PCI_EXT_CAP_ID_ACS );
835
+ if (!pos ) {
836
+ pci_warn (dev , "cannot disable ACS redirect for this hardware as it does not have ACS capabilities\n" );
837
+ return ;
838
+ }
839
+
840
+ pci_read_config_word (dev , pos + PCI_ACS_CTRL , & ctrl );
841
+
842
+ /* P2P Request & Completion Redirect */
843
+ ctrl &= ~(PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC );
844
+
845
+ pci_write_config_word (dev , pos + PCI_ACS_CTRL , ctrl );
846
+
847
+ pci_info (dev , "disabled ACS redirect\n" );
848
+ }
849
+
850
+ /**
851
+ * pci_std_enable_acs - enable ACS on devices using standard ACS capabilities
852
+ * @dev: the PCI device
853
+ */
854
+ static void pci_std_enable_acs (struct pci_dev * dev )
855
+ {
856
+ int pos ;
857
+ u16 cap ;
858
+ u16 ctrl ;
859
+
860
+ pos = pci_find_ext_capability (dev , PCI_EXT_CAP_ID_ACS );
861
+ if (!pos )
862
+ return ;
863
+
864
+ pci_read_config_word (dev , pos + PCI_ACS_CAP , & cap );
865
+ pci_read_config_word (dev , pos + PCI_ACS_CTRL , & ctrl );
866
+
867
+ /* Source Validation */
868
+ ctrl |= (cap & PCI_ACS_SV );
869
+
870
+ /* P2P Request Redirect */
871
+ ctrl |= (cap & PCI_ACS_RR );
872
+
873
+ /* P2P Completion Redirect */
874
+ ctrl |= (cap & PCI_ACS_CR );
875
+
876
+ /* Upstream Forwarding */
877
+ ctrl |= (cap & PCI_ACS_UF );
878
+
879
+ pci_write_config_word (dev , pos + PCI_ACS_CTRL , ctrl );
880
+ }
881
+
882
+ /**
883
+ * pci_enable_acs - enable ACS if hardware support it
884
+ * @dev: the PCI device
885
+ */
886
+ void pci_enable_acs (struct pci_dev * dev )
887
+ {
888
+ if (!pci_acs_enable )
889
+ goto disable_acs_redir ;
890
+
891
+ if (!pci_dev_specific_enable_acs (dev ))
892
+ goto disable_acs_redir ;
893
+
894
+ pci_std_enable_acs (dev );
895
+
896
+ disable_acs_redir :
897
+ /*
898
+ * Note: pci_disable_acs_redir() must be called even if ACS was not
899
+ * enabled by the kernel because it may have been enabled by
900
+ * platform firmware. So if we are told to disable it, we should
901
+ * always disable it after setting the kernel's default
902
+ * preferences.
903
+ */
904
+ pci_disable_acs_redir (dev );
905
+ }
906
+
780
907
/**
781
908
* pci_restore_bars - restore a device's BAR values (e.g. after wake-up)
782
909
* @dev: PCI device to have its BARs restored
@@ -3230,133 +3357,6 @@ void pci_configure_ari(struct pci_dev *dev)
3230
3357
}
3231
3358
}
3232
3359
3233
- static int pci_acs_enable ;
3234
-
3235
- /**
3236
- * pci_request_acs - ask for ACS to be enabled if supported
3237
- */
3238
- void pci_request_acs (void )
3239
- {
3240
- pci_acs_enable = 1 ;
3241
- }
3242
-
3243
- static const char * disable_acs_redir_param ;
3244
-
3245
- /**
3246
- * pci_disable_acs_redir - disable ACS redirect capabilities
3247
- * @dev: the PCI device
3248
- *
3249
- * For only devices specified in the disable_acs_redir parameter.
3250
- */
3251
- static void pci_disable_acs_redir (struct pci_dev * dev )
3252
- {
3253
- int ret = 0 ;
3254
- const char * p ;
3255
- int pos ;
3256
- u16 ctrl ;
3257
-
3258
- if (!disable_acs_redir_param )
3259
- return ;
3260
-
3261
- p = disable_acs_redir_param ;
3262
- while (* p ) {
3263
- ret = pci_dev_str_match (dev , p , & p );
3264
- if (ret < 0 ) {
3265
- pr_info_once ("PCI: Can't parse disable_acs_redir parameter: %s\n" ,
3266
- disable_acs_redir_param );
3267
-
3268
- break ;
3269
- } else if (ret == 1 ) {
3270
- /* Found a match */
3271
- break ;
3272
- }
3273
-
3274
- if (* p != ';' && * p != ',' ) {
3275
- /* End of param or invalid format */
3276
- break ;
3277
- }
3278
- p ++ ;
3279
- }
3280
-
3281
- if (ret != 1 )
3282
- return ;
3283
-
3284
- if (!pci_dev_specific_disable_acs_redir (dev ))
3285
- return ;
3286
-
3287
- pos = pci_find_ext_capability (dev , PCI_EXT_CAP_ID_ACS );
3288
- if (!pos ) {
3289
- pci_warn (dev , "cannot disable ACS redirect for this hardware as it does not have ACS capabilities\n" );
3290
- return ;
3291
- }
3292
-
3293
- pci_read_config_word (dev , pos + PCI_ACS_CTRL , & ctrl );
3294
-
3295
- /* P2P Request & Completion Redirect */
3296
- ctrl &= ~(PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC );
3297
-
3298
- pci_write_config_word (dev , pos + PCI_ACS_CTRL , ctrl );
3299
-
3300
- pci_info (dev , "disabled ACS redirect\n" );
3301
- }
3302
-
3303
- /**
3304
- * pci_std_enable_acs - enable ACS on devices using standard ACS capabilities
3305
- * @dev: the PCI device
3306
- */
3307
- static void pci_std_enable_acs (struct pci_dev * dev )
3308
- {
3309
- int pos ;
3310
- u16 cap ;
3311
- u16 ctrl ;
3312
-
3313
- pos = pci_find_ext_capability (dev , PCI_EXT_CAP_ID_ACS );
3314
- if (!pos )
3315
- return ;
3316
-
3317
- pci_read_config_word (dev , pos + PCI_ACS_CAP , & cap );
3318
- pci_read_config_word (dev , pos + PCI_ACS_CTRL , & ctrl );
3319
-
3320
- /* Source Validation */
3321
- ctrl |= (cap & PCI_ACS_SV );
3322
-
3323
- /* P2P Request Redirect */
3324
- ctrl |= (cap & PCI_ACS_RR );
3325
-
3326
- /* P2P Completion Redirect */
3327
- ctrl |= (cap & PCI_ACS_CR );
3328
-
3329
- /* Upstream Forwarding */
3330
- ctrl |= (cap & PCI_ACS_UF );
3331
-
3332
- pci_write_config_word (dev , pos + PCI_ACS_CTRL , ctrl );
3333
- }
3334
-
3335
- /**
3336
- * pci_enable_acs - enable ACS if hardware support it
3337
- * @dev: the PCI device
3338
- */
3339
- void pci_enable_acs (struct pci_dev * dev )
3340
- {
3341
- if (!pci_acs_enable )
3342
- goto disable_acs_redir ;
3343
-
3344
- if (!pci_dev_specific_enable_acs (dev ))
3345
- goto disable_acs_redir ;
3346
-
3347
- pci_std_enable_acs (dev );
3348
-
3349
- disable_acs_redir :
3350
- /*
3351
- * Note: pci_disable_acs_redir() must be called even if ACS was not
3352
- * enabled by the kernel because it may have been enabled by
3353
- * platform firmware. So if we are told to disable it, we should
3354
- * always disable it after setting the kernel's default
3355
- * preferences.
3356
- */
3357
- pci_disable_acs_redir (dev );
3358
- }
3359
-
3360
3360
static bool pci_acs_flags_enabled (struct pci_dev * pdev , u16 acs_flags )
3361
3361
{
3362
3362
int pos ;
0 commit comments