Mon Aug 27 14:23:31 2018 UTC ()
Disable PCIe stuff until I can figure out what it does.


(riastradh)
diff -r1.1 -r1.2 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c

cvs diff -r1.1 -r1.2 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c 2018/08/27 14:22:31 1.1
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c 2018/08/27 14:23:31 1.2
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $NetBSD: amdgpu_cik.c,v 1.1 2018/08/27 14:22:31 riastradh Exp $ */ 1/* $NetBSD: amdgpu_cik.c,v 1.2 2018/08/27 14:23:31 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2012 Advanced Micro Devices, Inc. 4 * Copyright 2012 Advanced Micro Devices, Inc.
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a 6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"), 7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation 8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the 10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions: 11 * Software is furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice shall be included in 13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software. 14 * all copies or substantial portions of the Software.
15 * 15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE. 22 * OTHER DEALINGS IN THE SOFTWARE.
23 * 23 *
24 * Authors: Alex Deucher 24 * Authors: Alex Deucher
25 */ 25 */
26#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: amdgpu_cik.c,v 1.1 2018/08/27 14:22:31 riastradh Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: amdgpu_cik.c,v 1.2 2018/08/27 14:23:31 riastradh Exp $");
28 28
29#include <linux/firmware.h> 29#include <linux/firmware.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include "drmP.h" 32#include "drmP.h"
33#include "amdgpu.h" 33#include "amdgpu.h"
34#include "amdgpu_atombios.h" 34#include "amdgpu_atombios.h"
35#include "amdgpu_ih.h" 35#include "amdgpu_ih.h"
36#include "amdgpu_uvd.h" 36#include "amdgpu_uvd.h"
37#include "amdgpu_vce.h" 37#include "amdgpu_vce.h"
38#include "cikd.h" 38#include "cikd.h"
39#include "atom.h" 39#include "atom.h"
40 40
@@ -1556,26 +1556,27 @@ static int cik_set_vce_clocks(struct amd @@ -1556,26 +1556,27 @@ static int cik_set_vce_clocks(struct amd
1556 for (i = 0; i < 100; i++) { 1556 for (i = 0; i < 100; i++) {
1557 if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK) 1557 if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK)
1558 break; 1558 break;
1559 mdelay(10); 1559 mdelay(10);
1560 } 1560 }
1561 if (i == 100) 1561 if (i == 100)
1562 return -ETIMEDOUT; 1562 return -ETIMEDOUT;
1563 1563
1564 return 0; 1564 return 0;
1565} 1565}
1566 1566
1567static void cik_pcie_gen3_enable(struct amdgpu_device *adev) 1567static void cik_pcie_gen3_enable(struct amdgpu_device *adev)
1568{ 1568{
 1569#ifndef __NetBSD__ /* XXX amdgpu pcie */
1569 struct pci_dev *root = adev->pdev->bus->self; 1570 struct pci_dev *root = adev->pdev->bus->self;
1570 int bridge_pos, gpu_pos; 1571 int bridge_pos, gpu_pos;
1571 u32 speed_cntl, mask, current_data_rate; 1572 u32 speed_cntl, mask, current_data_rate;
1572 int ret, i; 1573 int ret, i;
1573 u16 tmp16; 1574 u16 tmp16;
1574 1575
1575 if (pci_is_root_bus(adev->pdev->bus)) 1576 if (pci_is_root_bus(adev->pdev->bus))
1576 return; 1577 return;
1577 1578
1578 if (amdgpu_pcie_gen2 == 0) 1579 if (amdgpu_pcie_gen2 == 0)
1579 return; 1580 return;
1580 1581
1581 if (adev->flags & AMD_IS_APU) 1582 if (adev->flags & AMD_IS_APU)
@@ -1716,26 +1717,27 @@ static void cik_pcie_gen3_enable(struct  @@ -1716,26 +1717,27 @@ static void cik_pcie_gen3_enable(struct
1716 tmp16 |= 1; /* gen1 */ 1717 tmp16 |= 1; /* gen1 */
1717 pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); 1718 pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16);
1718 1719
1719 speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL); 1720 speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL);
1720 speed_cntl |= PCIE_LC_SPEED_CNTL__LC_INITIATE_LINK_SPEED_CHANGE_MASK; 1721 speed_cntl |= PCIE_LC_SPEED_CNTL__LC_INITIATE_LINK_SPEED_CHANGE_MASK;
1721 WREG32_PCIE(ixPCIE_LC_SPEED_CNTL, speed_cntl); 1722 WREG32_PCIE(ixPCIE_LC_SPEED_CNTL, speed_cntl);
1722 1723
1723 for (i = 0; i < adev->usec_timeout; i++) { 1724 for (i = 0; i < adev->usec_timeout; i++) {
1724 speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL); 1725 speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL);
1725 if ((speed_cntl & PCIE_LC_SPEED_CNTL__LC_INITIATE_LINK_SPEED_CHANGE_MASK) == 0) 1726 if ((speed_cntl & PCIE_LC_SPEED_CNTL__LC_INITIATE_LINK_SPEED_CHANGE_MASK) == 0)
1726 break; 1727 break;
1727 udelay(1); 1728 udelay(1);
1728 } 1729 }
 1730#endif
1729} 1731}
1730 1732
1731static void cik_program_aspm(struct amdgpu_device *adev) 1733static void cik_program_aspm(struct amdgpu_device *adev)
1732{ 1734{
1733 u32 data, orig; 1735 u32 data, orig;
1734 bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; 1736 bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false;
1735 bool disable_clkreq = false; 1737 bool disable_clkreq = false;
1736 1738
1737 if (amdgpu_aspm == 0) 1739 if (amdgpu_aspm == 0)
1738 return; 1740 return;
1739 1741
1740 /* XXX double check APUs */ 1742 /* XXX double check APUs */
1741 if (adev->flags & AMD_IS_APU) 1743 if (adev->flags & AMD_IS_APU)
@@ -1803,33 +1805,37 @@ static void cik_program_aspm(struct amdg @@ -1803,33 +1805,37 @@ static void cik_program_aspm(struct amdg
1803 PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_TXS2_1_MASK); 1805 PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_TXS2_1_MASK);
1804 data |= (7 << PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_OFF_1__SHIFT) | 1806 data |= (7 << PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_OFF_1__SHIFT) |
1805 (7 << PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_TXS2_1__SHIFT); 1807 (7 << PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_TXS2_1__SHIFT);
1806 if (orig != data) 1808 if (orig != data)
1807 WREG32_PCIE(ixPB1_PIF_PWRDOWN_1, data); 1809 WREG32_PCIE(ixPB1_PIF_PWRDOWN_1, data);
1808 1810
1809 orig = data = RREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL); 1811 orig = data = RREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL);
1810 data &= ~PCIE_LC_LINK_WIDTH_CNTL__LC_DYN_LANES_PWR_STATE_MASK; 1812 data &= ~PCIE_LC_LINK_WIDTH_CNTL__LC_DYN_LANES_PWR_STATE_MASK;
1811 data |= ~(3 << PCIE_LC_LINK_WIDTH_CNTL__LC_DYN_LANES_PWR_STATE__SHIFT); 1813 data |= ~(3 << PCIE_LC_LINK_WIDTH_CNTL__LC_DYN_LANES_PWR_STATE__SHIFT);
1812 if (orig != data) 1814 if (orig != data)
1813 WREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL, data); 1815 WREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL, data);
1814 1816
1815 if (!disable_clkreq) { 1817 if (!disable_clkreq) {
 1818#ifdef __NetBSD__ /* XXX amdgpu pcie */
 1819 clk_req_support = false;
 1820#else
1816 struct pci_dev *root = adev->pdev->bus->self; 1821 struct pci_dev *root = adev->pdev->bus->self;
1817 u32 lnkcap; 1822 u32 lnkcap;
1818 1823
1819 clk_req_support = false; 1824 clk_req_support = false;
1820 pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); 1825 pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap);
1821 if (lnkcap & PCI_EXP_LNKCAP_CLKPM) 1826 if (lnkcap & PCI_EXP_LNKCAP_CLKPM)
1822 clk_req_support = true; 1827 clk_req_support = true;
 1828#endif
1823 } else { 1829 } else {
1824 clk_req_support = false; 1830 clk_req_support = false;
1825 } 1831 }
1826 1832
1827 if (clk_req_support) { 1833 if (clk_req_support) {
1828 orig = data = RREG32_PCIE(ixPCIE_LC_CNTL2); 1834 orig = data = RREG32_PCIE(ixPCIE_LC_CNTL2);
1829 data |= PCIE_LC_CNTL2__LC_ALLOW_PDWN_IN_L1_MASK | 1835 data |= PCIE_LC_CNTL2__LC_ALLOW_PDWN_IN_L1_MASK |
1830 PCIE_LC_CNTL2__LC_ALLOW_PDWN_IN_L23_MASK; 1836 PCIE_LC_CNTL2__LC_ALLOW_PDWN_IN_L23_MASK;
1831 if (orig != data) 1837 if (orig != data)
1832 WREG32_PCIE(ixPCIE_LC_CNTL2, data); 1838 WREG32_PCIE(ixPCIE_LC_CNTL2, data);
1833 1839
1834 orig = data = RREG32_SMC(ixTHM_CLK_CNTL); 1840 orig = data = RREG32_SMC(ixTHM_CLK_CNTL);
1835 data &= ~(THM_CLK_CNTL__CMON_CLK_SEL_MASK | 1841 data &= ~(THM_CLK_CNTL__CMON_CLK_SEL_MASK |