hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/gpu/drm/radeon/cik.c
....@@ -21,18 +21,22 @@
2121 *
2222 * Authors: Alex Deucher
2323 */
24
+
2425 #include <linux/firmware.h>
25
-#include <linux/slab.h>
2626 #include <linux/module.h>
27
-#include <drm/drmP.h>
27
+#include <linux/pci.h>
28
+#include <linux/slab.h>
29
+
30
+#include <drm/drm_vblank.h>
31
+
32
+#include "atom.h"
33
+#include "cik_blit_shaders.h"
34
+#include "cikd.h"
35
+#include "clearstate_ci.h"
2836 #include "radeon.h"
2937 #include "radeon_asic.h"
3038 #include "radeon_audio.h"
31
-#include "cikd.h"
32
-#include "atom.h"
33
-#include "cik_blit_shaders.h"
3439 #include "radeon_ucode.h"
35
-#include "clearstate_ci.h"
3640
3741 #define SH_MEM_CONFIG_GFX_DEFAULT \
3842 ALIGNMENT_MODE(SH_MEM_ALIGNMENT_MODE_UNALIGNED)
....@@ -217,9 +221,7 @@
217221 else
218222 actual_temp = temp & 0x1ff;
219223
220
- actual_temp = actual_temp * 1000;
221
-
222
- return actual_temp;
224
+ return actual_temp * 1000;
223225 }
224226
225227 /* get temperature in millidegrees */
....@@ -235,9 +237,7 @@
235237 else
236238 actual_temp = 0;
237239
238
- actual_temp = actual_temp * 1000;
239
-
240
- return actual_temp;
240
+ return actual_temp * 1000;
241241 }
242242
243243 /*
....@@ -3480,7 +3480,7 @@
34803480 tmp = RREG32(scratch);
34813481 if (tmp == 0xDEADBEEF)
34823482 break;
3483
- DRM_UDELAY(1);
3483
+ udelay(1);
34843484 }
34853485 if (i < rdev->usec_timeout) {
34863486 DRM_INFO("ring test on %d succeeded in %d usecs\n", ring->idx, i);
....@@ -3655,7 +3655,7 @@
36553655 struct radeon_fence *cik_copy_cpdma(struct radeon_device *rdev,
36563656 uint64_t src_offset, uint64_t dst_offset,
36573657 unsigned num_gpu_pages,
3658
- struct reservation_object *resv)
3658
+ struct dma_resv *resv)
36593659 {
36603660 struct radeon_fence *fence;
36613661 struct radeon_sync sync;
....@@ -3825,7 +3825,7 @@
38253825 tmp = RREG32(scratch);
38263826 if (tmp == 0xDEADBEEF)
38273827 break;
3828
- DRM_UDELAY(1);
3828
+ udelay(1);
38293829 }
38303830 if (i < rdev->usec_timeout) {
38313831 DRM_INFO("ib test on ring %d succeeded in %u usecs\n", ib.fence->ring, i);
....@@ -8137,7 +8137,7 @@
81378137 * there. So it is pointless to try to go through that code
81388138 * hence why we disable uvd here.
81398139 */
8140
- rdev->has_uvd = 0;
8140
+ rdev->has_uvd = false;
81418141 return;
81428142 }
81438143 rdev->ring[R600_RING_TYPE_UVD_INDEX].ring_obj = NULL;
....@@ -8209,7 +8209,7 @@
82098209 * there. So it is pointless to try to go through that code
82108210 * hence why we disable vce here.
82118211 */
8212
- rdev->has_vce = 0;
8212
+ rdev->has_vce = false;
82138213 return;
82148214 }
82158215 rdev->ring[TN_RING_TYPE_VCE1_INDEX].ring_obj = NULL;
....@@ -9500,7 +9500,6 @@
95009500 {
95019501 struct pci_dev *root = rdev->pdev->bus->self;
95029502 enum pci_bus_speed speed_cap;
9503
- int bridge_pos, gpu_pos;
95049503 u32 speed_cntl, current_data_rate;
95059504 int i;
95069505 u16 tmp16;
....@@ -9542,12 +9541,7 @@
95429541 DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
95439542 }
95449543
9545
- bridge_pos = pci_pcie_cap(root);
9546
- if (!bridge_pos)
9547
- return;
9548
-
9549
- gpu_pos = pci_pcie_cap(rdev->pdev);
9550
- if (!gpu_pos)
9544
+ if (!pci_is_pcie(root) || !pci_is_pcie(rdev->pdev))
95519545 return;
95529546
95539547 if (speed_cap == PCIE_SPEED_8_0GT) {
....@@ -9557,14 +9551,8 @@
95579551 u16 bridge_cfg2, gpu_cfg2;
95589552 u32 max_lw, current_lw, tmp;
95599553
9560
- pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg);
9561
- pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg);
9562
-
9563
- tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD;
9564
- pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16);
9565
-
9566
- tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD;
9567
- pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16);
9554
+ pcie_capability_set_word(root, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_HAWD);
9555
+ pcie_capability_set_word(rdev->pdev, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_HAWD);
95689556
95699557 tmp = RREG32_PCIE_PORT(PCIE_LC_STATUS1);
95709558 max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT;
....@@ -9582,15 +9570,23 @@
95829570
95839571 for (i = 0; i < 10; i++) {
95849572 /* check status */
9585
- pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_DEVSTA, &tmp16);
9573
+ pcie_capability_read_word(rdev->pdev,
9574
+ PCI_EXP_DEVSTA,
9575
+ &tmp16);
95869576 if (tmp16 & PCI_EXP_DEVSTA_TRPND)
95879577 break;
95889578
9589
- pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg);
9590
- pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg);
9579
+ pcie_capability_read_word(root, PCI_EXP_LNKCTL,
9580
+ &bridge_cfg);
9581
+ pcie_capability_read_word(rdev->pdev,
9582
+ PCI_EXP_LNKCTL,
9583
+ &gpu_cfg);
95919584
9592
- pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2);
9593
- pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2);
9585
+ pcie_capability_read_word(root, PCI_EXP_LNKCTL2,
9586
+ &bridge_cfg2);
9587
+ pcie_capability_read_word(rdev->pdev,
9588
+ PCI_EXP_LNKCTL2,
9589
+ &gpu_cfg2);
95949590
95959591 tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4);
95969592 tmp |= LC_SET_QUIESCE;
....@@ -9600,29 +9596,41 @@
96009596 tmp |= LC_REDO_EQ;
96019597 WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp);
96029598
9603
- mdelay(100);
9599
+ msleep(100);
96049600
96059601 /* linkctl */
9606
- pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &tmp16);
9607
- tmp16 &= ~PCI_EXP_LNKCTL_HAWD;
9608
- tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD);
9609
- pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16);
9610
-
9611
- pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &tmp16);
9612
- tmp16 &= ~PCI_EXP_LNKCTL_HAWD;
9613
- tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD);
9614
- pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16);
9602
+ pcie_capability_clear_and_set_word(root, PCI_EXP_LNKCTL,
9603
+ PCI_EXP_LNKCTL_HAWD,
9604
+ bridge_cfg &
9605
+ PCI_EXP_LNKCTL_HAWD);
9606
+ pcie_capability_clear_and_set_word(rdev->pdev, PCI_EXP_LNKCTL,
9607
+ PCI_EXP_LNKCTL_HAWD,
9608
+ gpu_cfg &
9609
+ PCI_EXP_LNKCTL_HAWD);
96159610
96169611 /* linkctl2 */
9617
- pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &tmp16);
9618
- tmp16 &= ~((1 << 4) | (7 << 9));
9619
- tmp16 |= (bridge_cfg2 & ((1 << 4) | (7 << 9)));
9620
- pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, tmp16);
9612
+ pcie_capability_read_word(root, PCI_EXP_LNKCTL2,
9613
+ &tmp16);
9614
+ tmp16 &= ~(PCI_EXP_LNKCTL2_ENTER_COMP |
9615
+ PCI_EXP_LNKCTL2_TX_MARGIN);
9616
+ tmp16 |= (bridge_cfg2 &
9617
+ (PCI_EXP_LNKCTL2_ENTER_COMP |
9618
+ PCI_EXP_LNKCTL2_TX_MARGIN));
9619
+ pcie_capability_write_word(root,
9620
+ PCI_EXP_LNKCTL2,
9621
+ tmp16);
96219622
9622
- pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16);
9623
- tmp16 &= ~((1 << 4) | (7 << 9));
9624
- tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9)));
9625
- pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16);
9623
+ pcie_capability_read_word(rdev->pdev,
9624
+ PCI_EXP_LNKCTL2,
9625
+ &tmp16);
9626
+ tmp16 &= ~(PCI_EXP_LNKCTL2_ENTER_COMP |
9627
+ PCI_EXP_LNKCTL2_TX_MARGIN);
9628
+ tmp16 |= (gpu_cfg2 &
9629
+ (PCI_EXP_LNKCTL2_ENTER_COMP |
9630
+ PCI_EXP_LNKCTL2_TX_MARGIN));
9631
+ pcie_capability_write_word(rdev->pdev,
9632
+ PCI_EXP_LNKCTL2,
9633
+ tmp16);
96269634
96279635 tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4);
96289636 tmp &= ~LC_SET_QUIESCE;
....@@ -9636,15 +9644,15 @@
96369644 speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE;
96379645 WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl);
96389646
9639
- pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16);
9640
- tmp16 &= ~0xf;
9647
+ pcie_capability_read_word(rdev->pdev, PCI_EXP_LNKCTL2, &tmp16);
9648
+ tmp16 &= ~PCI_EXP_LNKCTL2_TLS;
96419649 if (speed_cap == PCIE_SPEED_8_0GT)
9642
- tmp16 |= 3; /* gen3 */
9650
+ tmp16 |= PCI_EXP_LNKCTL2_TLS_8_0GT; /* gen3 */
96439651 else if (speed_cap == PCIE_SPEED_5_0GT)
9644
- tmp16 |= 2; /* gen2 */
9652
+ tmp16 |= PCI_EXP_LNKCTL2_TLS_5_0GT; /* gen2 */
96459653 else
9646
- tmp16 |= 1; /* gen1 */
9647
- pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16);
9654
+ tmp16 |= PCI_EXP_LNKCTL2_TLS_2_5GT; /* gen1 */
9655
+ pcie_capability_write_word(rdev->pdev, PCI_EXP_LNKCTL2, tmp16);
96489656
96499657 speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);
96509658 speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE;