Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp658888pxv; Thu, 15 Jul 2021 12:43:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZG3IVLdi5URLMOsk95OCaTnXhG5tFMNGiH29B/UHmRLhCU0ceGdprduLmLunywssfEdmY X-Received: by 2002:a50:ed89:: with SMTP id h9mr9313415edr.106.1626378189731; Thu, 15 Jul 2021 12:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378189; cv=none; d=google.com; s=arc-20160816; b=gc+8g/QoijgDpLubu+KczZLrY/KjwBzxC7WZBoqf+ub5FswNwBOv0aKuOwjE5Uo0d/ ekpjk7xgFO3P3J1l+eLVlBplb1xqnwj/ybx21MyhumCe8BHzRaNpiSloQIgadFVIOIJa wbjvZBuEr9M1bHWF/2XC/VVWWsvNVkcAeNlMGOZr/jsbuagxOtNtCG7io9kaXX/c8MW4 SO1xfc+O8Gh/gDe5nj9JsSCSFSYpaikYyE9zjPqVM7e3wcT8tYUbEiNhCkSISGWOk/WX 9d7+1TPCWqtylIYowoIrCKHqcblIFjvoGEErV8wlNm56KAsr2HpnckbbvmPO9Vdy4RiJ iTIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H5CENaZXI9lqRjBxa3WTsd/wN/CePG+dSlM6Vl60WUI=; b=BKCkupMer1rrwApW+y9cJm3B38ejqtrFC914umNrx3/3+4holD9pBr2Z9c2dgIUTs5 tXIQdxYb9ZvIRusZ8XyCrxVfaXRRUn+1JF4WtQIE6Nir20VG2LbleNFFZYhjROZ4lnHb gkNT5CuH/c8Q8S+dsPRf5GlJpAmzGboMLxbvui+uvBo2a7DbFtP0RR3sZECz5J9SWbPY yQtE4dh9LeK0WscXqbKCnKmUDqRk6+cpQ4qD3aKQpiezoYw67gQIHArVku7LrpqSsOuN HjRUfQ19UOGRXFKlWg2mByPxdefGUZ2crPZojcfEfw2FtFxyh0P5+2nd/02oDHW9K2AA GUgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Mwa1j/6C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si8337358eds.528.2021.07.15.12.42.46; Thu, 15 Jul 2021 12:43:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Mwa1j/6C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244046AbhGOTnp (ORCPT + 99 others); Thu, 15 Jul 2021 15:43:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:52808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244586AbhGOTO6 (ORCPT ); Thu, 15 Jul 2021 15:14:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2CF7E61405; Thu, 15 Jul 2021 19:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376243; bh=StkZ6aujY2PeZQgeVK7jPZd5eGIXph8XcoWYZQJF4bE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mwa1j/6CnuA1txeoyCsl1mBVDSp7NZQbTgMyp8qL1AOcBSUv3OIyQ95CvxN3xdxKE CHacT2S8DdJmQ90BMySWwKFq8mPDReP3iDzjO0JoSQquwZJr/0JtM60PKClCX103Ub iO3a9f3g0SoIYNcxG8E+UeOfwv1MRk8XjDTTlciU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evan Quan , Lijo Lazar , Alex Deucher Subject: [PATCH 5.13 188/266] drm/amdgpu: fix NAK-G generation during PCI-e link width switch Date: Thu, 15 Jul 2021 20:39:03 +0200 Message-Id: <20210715182644.320727411@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Evan Quan commit 5a5da8ae9546031e43efd4fa5aa8baa481e83dfb upstream. A lot of NAK-G being generated when link widht switching is happening. WA for this issue is to program the SPC to 4 symbols per clock during bootup when the native PCIE width is x4. Signed-off-by: Evan Quan Reviewed-by: Lijo Lazar Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h | 1 + drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/nv.c | 3 +++ 3 files changed, 32 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h @@ -93,6 +93,7 @@ struct amdgpu_nbio_funcs { void (*enable_aspm)(struct amdgpu_device *adev, bool enable); void (*program_aspm)(struct amdgpu_device *adev); + void (*apply_lc_spc_mode_wa)(struct amdgpu_device *adev); }; struct amdgpu_nbio { --- a/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c @@ -51,6 +51,8 @@ #define mmBIF_MMSCH1_DOORBELL_RANGE 0x01d8 #define mmBIF_MMSCH1_DOORBELL_RANGE_BASE_IDX 2 +#define smnPCIE_LC_LINK_WIDTH_CNTL 0x11140288 + static void nbio_v2_3_remap_hdp_registers(struct amdgpu_device *adev) { WREG32_SOC15(NBIO, 0, mmREMAP_HDP_MEM_FLUSH_CNTL, @@ -463,6 +465,31 @@ static void nbio_v2_3_program_aspm(struc WREG32_PCIE(smnPCIE_LC_CNTL3, data); } +static void nbio_v2_3_apply_lc_spc_mode_wa(struct amdgpu_device *adev) +{ + uint32_t reg_data = 0; + uint32_t link_width = 0; + + if (!((adev->asic_type >= CHIP_NAVI10) && + (adev->asic_type <= CHIP_NAVI12))) + return; + + reg_data = RREG32_PCIE(smnPCIE_LC_LINK_WIDTH_CNTL); + link_width = (reg_data & PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_RD_MASK) + >> PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_RD__SHIFT; + + /* + * Program PCIE_LC_CNTL6.LC_SPC_MODE_8GT to 0x2 (4 symbols per clock data) + * if link_width is 0x3 (x4) + */ + if (0x3 == link_width) { + reg_data = RREG32_PCIE(smnPCIE_LC_CNTL6); + reg_data &= ~PCIE_LC_CNTL6__LC_SPC_MODE_8GT_MASK; + reg_data |= (0x2 << PCIE_LC_CNTL6__LC_SPC_MODE_8GT__SHIFT); + WREG32_PCIE(smnPCIE_LC_CNTL6, reg_data); + } +} + const struct amdgpu_nbio_funcs nbio_v2_3_funcs = { .get_hdp_flush_req_offset = nbio_v2_3_get_hdp_flush_req_offset, .get_hdp_flush_done_offset = nbio_v2_3_get_hdp_flush_done_offset, @@ -484,4 +511,5 @@ const struct amdgpu_nbio_funcs nbio_v2_3 .remap_hdp_registers = nbio_v2_3_remap_hdp_registers, .enable_aspm = nbio_v2_3_enable_aspm, .program_aspm = nbio_v2_3_program_aspm, + .apply_lc_spc_mode_wa = nbio_v2_3_apply_lc_spc_mode_wa, }; --- a/drivers/gpu/drm/amd/amdgpu/nv.c +++ b/drivers/gpu/drm/amd/amdgpu/nv.c @@ -1194,6 +1194,9 @@ static int nv_common_hw_init(void *handl { struct amdgpu_device *adev = (struct amdgpu_device *)handle; + if (adev->nbio.funcs->apply_lc_spc_mode_wa) + adev->nbio.funcs->apply_lc_spc_mode_wa(adev); + /* enable pcie gen2/3 link */ nv_pcie_gen3_enable(adev); /* enable aspm */