pci.c (44cc24b04bed578e32a4334cacf95799335b3274) | pci.c (96527d527b271d950367ad13e3de8b0673545622) |
---|---|
1// SPDX-License-Identifier: BSD-3-Clause-Clear 2/* 3 * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. 4 */ 5 6#include <linux/module.h> 7#include <linux/msi.h> 8#include <linux/pci.h> --- 841 unchanged lines hidden (view full) --- 850 851 for (i = 0; i < ab->hw_params.ce_count; i++) { 852 if (ath11k_ce_get_attr_flags(ab, i) & CE_ATTR_DIS_INTR) 853 continue; 854 ath11k_pci_ce_irq_enable(ab, i); 855 } 856} 857 | 1// SPDX-License-Identifier: BSD-3-Clause-Clear 2/* 3 * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. 4 */ 5 6#include <linux/module.h> 7#include <linux/msi.h> 8#include <linux/pci.h> --- 841 unchanged lines hidden (view full) --- 850 851 for (i = 0; i < ab->hw_params.ce_count; i++) { 852 if (ath11k_ce_get_attr_flags(ab, i) & CE_ATTR_DIS_INTR) 853 continue; 854 ath11k_pci_ce_irq_enable(ab, i); 855 } 856} 857 |
858static int ath11k_pci_enable_msi(struct ath11k_pci *ab_pci) | 858static void ath11k_pci_msi_config(struct ath11k_pci *ab_pci, bool enable) |
859{ | 859{ |
860 struct pci_dev *dev = ab_pci->pdev; 861 u16 control; 862 863 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control); 864 865 if (enable) 866 control |= PCI_MSI_FLAGS_ENABLE; 867 else 868 control &= ~PCI_MSI_FLAGS_ENABLE; 869 870 pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control); 871} 872 873static void ath11k_pci_msi_enable(struct ath11k_pci *ab_pci) 874{ 875 ath11k_pci_msi_config(ab_pci, true); 876} 877 878static void ath11k_pci_msi_disable(struct ath11k_pci *ab_pci) 879{ 880 ath11k_pci_msi_config(ab_pci, false); 881} 882 883static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci) 884{ |
|
860 struct ath11k_base *ab = ab_pci->ab; 861 const struct ath11k_msi_config *msi_config = ab_pci->msi_config; 862 struct msi_desc *msi_desc; 863 int num_vectors; 864 int ret; 865 866 num_vectors = pci_alloc_irq_vectors(ab_pci->pdev, 867 msi_config->total_vectors, 868 msi_config->total_vectors, 869 PCI_IRQ_MSI); 870 if (num_vectors != msi_config->total_vectors) { 871 ath11k_err(ab, "failed to get %d MSI vectors, only %d available", 872 msi_config->total_vectors, num_vectors); 873 874 if (num_vectors >= 0) 875 return -EINVAL; 876 else 877 return num_vectors; 878 } | 885 struct ath11k_base *ab = ab_pci->ab; 886 const struct ath11k_msi_config *msi_config = ab_pci->msi_config; 887 struct msi_desc *msi_desc; 888 int num_vectors; 889 int ret; 890 891 num_vectors = pci_alloc_irq_vectors(ab_pci->pdev, 892 msi_config->total_vectors, 893 msi_config->total_vectors, 894 PCI_IRQ_MSI); 895 if (num_vectors != msi_config->total_vectors) { 896 ath11k_err(ab, "failed to get %d MSI vectors, only %d available", 897 msi_config->total_vectors, num_vectors); 898 899 if (num_vectors >= 0) 900 return -EINVAL; 901 else 902 return num_vectors; 903 } |
904 ath11k_pci_msi_disable(ab_pci); |
|
879 880 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq); 881 if (!msi_desc) { 882 ath11k_err(ab, "msi_desc is NULL!\n"); 883 ret = -EINVAL; 884 goto free_msi_vector; 885 } 886 --- 6 unchanged lines hidden (view full) --- 893 return 0; 894 895free_msi_vector: 896 pci_free_irq_vectors(ab_pci->pdev); 897 898 return ret; 899} 900 | 905 906 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq); 907 if (!msi_desc) { 908 ath11k_err(ab, "msi_desc is NULL!\n"); 909 ret = -EINVAL; 910 goto free_msi_vector; 911 } 912 --- 6 unchanged lines hidden (view full) --- 919 return 0; 920 921free_msi_vector: 922 pci_free_irq_vectors(ab_pci->pdev); 923 924 return ret; 925} 926 |
901static void ath11k_pci_disable_msi(struct ath11k_pci *ab_pci) | 927static void ath11k_pci_free_msi(struct ath11k_pci *ab_pci) |
902{ 903 pci_free_irq_vectors(ab_pci->pdev); 904} 905 906static int ath11k_pci_claim(struct ath11k_pci *ab_pci, struct pci_dev *pdev) 907{ 908 struct ath11k_base *ab = ab_pci->ab; 909 u16 device_id; --- 104 unchanged lines hidden (view full) --- 1014 clear_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags); 1015 ath11k_pci_sw_reset(ab_pci->ab, true); 1016 1017 /* Disable ASPM during firmware download due to problems switching 1018 * to AMSS state. 1019 */ 1020 ath11k_pci_aspm_disable(ab_pci); 1021 | 928{ 929 pci_free_irq_vectors(ab_pci->pdev); 930} 931 932static int ath11k_pci_claim(struct ath11k_pci *ab_pci, struct pci_dev *pdev) 933{ 934 struct ath11k_base *ab = ab_pci->ab; 935 u16 device_id; --- 104 unchanged lines hidden (view full) --- 1040 clear_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags); 1041 ath11k_pci_sw_reset(ab_pci->ab, true); 1042 1043 /* Disable ASPM during firmware download due to problems switching 1044 * to AMSS state. 1045 */ 1046 ath11k_pci_aspm_disable(ab_pci); 1047 |
1048 ath11k_pci_msi_enable(ab_pci); 1049 |
|
1022 ret = ath11k_mhi_start(ab_pci); 1023 if (ret) { 1024 ath11k_err(ab, "failed to start mhi: %d\n", ret); 1025 return ret; 1026 } 1027 1028 if (ab->bus_params.static_window_map) 1029 ath11k_pci_select_static_window(ab_pci); --- 4 unchanged lines hidden (view full) --- 1034static void ath11k_pci_power_down(struct ath11k_base *ab) 1035{ 1036 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); 1037 1038 /* restore aspm in case firmware bootup fails */ 1039 ath11k_pci_aspm_restore(ab_pci); 1040 1041 ath11k_pci_force_wake(ab_pci->ab); | 1050 ret = ath11k_mhi_start(ab_pci); 1051 if (ret) { 1052 ath11k_err(ab, "failed to start mhi: %d\n", ret); 1053 return ret; 1054 } 1055 1056 if (ab->bus_params.static_window_map) 1057 ath11k_pci_select_static_window(ab_pci); --- 4 unchanged lines hidden (view full) --- 1062static void ath11k_pci_power_down(struct ath11k_base *ab) 1063{ 1064 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); 1065 1066 /* restore aspm in case firmware bootup fails */ 1067 ath11k_pci_aspm_restore(ab_pci); 1068 1069 ath11k_pci_force_wake(ab_pci->ab); |
1070 1071 ath11k_pci_msi_disable(ab_pci); 1072 |
|
1042 ath11k_mhi_stop(ab_pci); 1043 clear_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags); 1044 ath11k_pci_sw_reset(ab_pci->ab, false); 1045} 1046 1047static int ath11k_pci_hif_suspend(struct ath11k_base *ab) 1048{ 1049 struct ath11k_pci *ar_pci = ath11k_pci_priv(ab); --- 208 unchanged lines hidden (view full) --- 1258 break; 1259 default: 1260 dev_err(&pdev->dev, "Unknown PCI device found: 0x%x\n", 1261 pci_dev->device); 1262 ret = -EOPNOTSUPP; 1263 goto err_pci_free_region; 1264 } 1265 | 1073 ath11k_mhi_stop(ab_pci); 1074 clear_bit(ATH11K_PCI_FLAG_INIT_DONE, &ab_pci->flags); 1075 ath11k_pci_sw_reset(ab_pci->ab, false); 1076} 1077 1078static int ath11k_pci_hif_suspend(struct ath11k_base *ab) 1079{ 1080 struct ath11k_pci *ar_pci = ath11k_pci_priv(ab); --- 208 unchanged lines hidden (view full) --- 1289 break; 1290 default: 1291 dev_err(&pdev->dev, "Unknown PCI device found: 0x%x\n", 1292 pci_dev->device); 1293 ret = -EOPNOTSUPP; 1294 goto err_pci_free_region; 1295 } 1296 |
1266 ret = ath11k_pci_enable_msi(ab_pci); | 1297 ret = ath11k_pci_alloc_msi(ab_pci); |
1267 if (ret) { 1268 ath11k_err(ab, "failed to enable msi: %d\n", ret); 1269 goto err_pci_free_region; 1270 } 1271 1272 ret = ath11k_core_pre_init(ab); 1273 if (ret) 1274 goto err_pci_disable_msi; --- 37 unchanged lines hidden (view full) --- 1312 1313err_hal_srng_deinit: 1314 ath11k_hal_srng_deinit(ab); 1315 1316err_mhi_unregister: 1317 ath11k_mhi_unregister(ab_pci); 1318 1319err_pci_disable_msi: | 1298 if (ret) { 1299 ath11k_err(ab, "failed to enable msi: %d\n", ret); 1300 goto err_pci_free_region; 1301 } 1302 1303 ret = ath11k_core_pre_init(ab); 1304 if (ret) 1305 goto err_pci_disable_msi; --- 37 unchanged lines hidden (view full) --- 1343 1344err_hal_srng_deinit: 1345 ath11k_hal_srng_deinit(ab); 1346 1347err_mhi_unregister: 1348 ath11k_mhi_unregister(ab_pci); 1349 1350err_pci_disable_msi: |
1320 ath11k_pci_disable_msi(ab_pci); | 1351 ath11k_pci_free_msi(ab_pci); |
1321 1322err_pci_free_region: 1323 ath11k_pci_free_region(ab_pci); 1324 1325err_free_core: 1326 ath11k_core_free(ab); 1327 1328 return ret; --- 14 unchanged lines hidden (view full) --- 1343 set_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags); 1344 1345 ath11k_core_deinit(ab); 1346 1347qmi_fail: 1348 ath11k_mhi_unregister(ab_pci); 1349 1350 ath11k_pci_free_irq(ab); | 1352 1353err_pci_free_region: 1354 ath11k_pci_free_region(ab_pci); 1355 1356err_free_core: 1357 ath11k_core_free(ab); 1358 1359 return ret; --- 14 unchanged lines hidden (view full) --- 1374 set_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags); 1375 1376 ath11k_core_deinit(ab); 1377 1378qmi_fail: 1379 ath11k_mhi_unregister(ab_pci); 1380 1381 ath11k_pci_free_irq(ab); |
1351 ath11k_pci_disable_msi(ab_pci); | 1382 ath11k_pci_free_msi(ab_pci); |
1352 ath11k_pci_free_region(ab_pci); 1353 1354 ath11k_hal_srng_deinit(ab); 1355 ath11k_ce_free_pipes(ab); 1356 ath11k_core_free(ab); 1357} 1358 1359static void ath11k_pci_shutdown(struct pci_dev *pdev) --- 72 unchanged lines hidden --- | 1383 ath11k_pci_free_region(ab_pci); 1384 1385 ath11k_hal_srng_deinit(ab); 1386 ath11k_ce_free_pipes(ab); 1387 ath11k_core_free(ab); 1388} 1389 1390static void ath11k_pci_shutdown(struct pci_dev *pdev) --- 72 unchanged lines hidden --- |