From patchwork Thu Feb 9 05:54:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1739801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=KkN/kwKs; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PC5gQ307Fz23kw for ; Thu, 9 Feb 2023 16:55:14 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pPztj-0002yh-MQ; Thu, 09 Feb 2023 05:55:07 +0000 Received: from mail-pj1-f43.google.com ([209.85.216.43]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pPztg-0002tU-VW for kernel-team@lists.ubuntu.com; Thu, 09 Feb 2023 05:55:05 +0000 Received: by mail-pj1-f43.google.com with SMTP id d2so1104904pjd.5 for ; Wed, 08 Feb 2023 21:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=nXZnH9cz+PgikLcu7peXQDfpvA/1IRx6vww9hS/V/iA=; b=KkN/kwKsAChELXbHdNsblycPTmJzJrY+kFlzQjohCwE6IZ4IbctyQlKk6HWnTlIcry rgM1CrThoTlW6kHqDCdoCBGChSjP53rtYxelsbvbzL7fWfRvuMHQaexpOrxuIvtUztVQ RhMabUdmAjK6B21ureXXM+EIhRJiuqDV7qa8zVxTVl3lwFCITgD17abKtE8ipEpPzAzm vtJbaLV8gjlIZravnyOw95AU0vmvPo9ZTnty6mBhVvjg0d6KtN+qHdMDNO7s5fCR8a/I R93ORoC/hHdv6xbA7PYoLHAVBNJXknYrhv5JhIZmqczNoxpvWW1TfbYGQZGQxzo+z4Uq ny1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=nXZnH9cz+PgikLcu7peXQDfpvA/1IRx6vww9hS/V/iA=; b=x9vnEsbz+WjdiMz7lf7DpsOGEeRUPQLPs8kdJna1QEUHXg1mM7qnJcZk8PLTkS3Kd6 Z2Ha7KPAhM7msSZPuEv0gl44MjLqUdxGSLOQ9LwGNUkVJtH1eP24rQmcqg17ffEgH3tr g4W87SeHhFh/cGOkgKzAynZV+vzdsLaqQ3LqTLAJMcbjxADirqAFIrWcqDu4jR81N6XA pUmkivtzuJyrOqJqHNKN0RaZUPeWMbvBNjWmQTCoEiqMBSGaoS2xbwmVDlQqlxiqPGTQ VbqGlyuqXbyoqTG+1OXmBlx4ILz3+GAvM3ucgU8GH0J0LBQtukVkNiEhnrIi5G8Dnjbx Wp9g== X-Gm-Message-State: AO0yUKVX/Wl5le1JRQpo75/ov/XbgVqRJzcGI+rJofhHe2MEMa2fXUG4 KW7t+v9V4/g1vg5BpOWRjb2bOXtEy+wpVA== X-Google-Smtp-Source: AK7set+gH+dmYL/+ZArt9YIXDUNe5pdNUBiaL6vJzWDtIq3ZUSlv+YUGIC0x+SAI8Itc98Uj3XaGAA== X-Received: by 2002:a17:902:ea05:b0:194:828d:62b0 with SMTP id s5-20020a170902ea0500b00194828d62b0mr10768817plg.48.1675922102403; Wed, 08 Feb 2023 21:55:02 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id jk23-20020a170903331700b001926392adf9sm456657plb.271.2023.02.08.21.55.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 21:55:01 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH v2 4/4][SRU][OEM-5.17] drm/amdgpu: fix sdma doorbell init ordering on APUs Date: Thu, 9 Feb 2023 13:54:33 +0800 Message-Id: <20230209055433.229851-5-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209055433.229851-1-acelan.kao@canonical.com> References: <20230209055433.229851-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.43; envelope-from=acelan@gmail.com; helo=mail-pj1-f43.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Alex Deucher BugLink: https://launchpad.net/bugs/2000110 Commit 8795e182b02d ("PCI/portdrv: Don't disable AER reporting in get_port_device_capability()") uncovered a bug in amdgpu that required a reordering of the driver init sequence to avoid accessing a special register on the GPU before it was properly set up leading to an PCI AER error. This reordering uncovered a different hw programming ordering dependency in some APUs where the SDMA doorbells need to be programmed before the GFX doorbells. To fix this, move the SDMA doorbell programming back into the soc15 common code, but use the actual doorbell range values directly rather than the values stored in the ring structure since those will not be initialized at this point. This is a partial revert, but with the doorbell assignment fixed so the proper doorbell index is set before it's used. Fixes: e3163bc8ffdfdb ("drm/amdgpu: move nbio sdma_doorbell_range() into sdma code for vega") Acked-by: Christian König Signed-off-by: Alex Deucher Cc: skhan@linuxfoundation.org (cherry picked from commit 6c16afdcec20b01879ad17440f42c9944786dc7d) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 5 ----- drivers/gpu/drm/amd/amdgpu/soc15.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index 72e0f98099843..66b6b175ae908 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c @@ -1510,11 +1510,6 @@ static int sdma_v4_0_start(struct amdgpu_device *adev) WREG32_SDMA(i, mmSDMA0_CNTL, temp); if (!amdgpu_sriov_vf(adev)) { - ring = &adev->sdma.instance[i].ring; - adev->nbio.funcs->sdma_doorbell_range(adev, i, - ring->use_doorbell, ring->doorbell_index, - adev->doorbell_index.sdma_doorbell_range); - /* unhalt engine */ temp = RREG32_SDMA(i, mmSDMA0_F32_CNTL); temp = REG_SET_FIELD(temp, SDMA0_F32_CNTL, HALT, 0); diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index 04c564b4dc347..ac1d2e08e6a4b 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c @@ -1262,6 +1262,20 @@ static int soc15_common_sw_fini(void *handle) return 0; } +static void soc15_sdma_doorbell_range_init(struct amdgpu_device *adev) +{ + int i; + + /* sdma doorbell range is programed by hypervisor */ + if (!amdgpu_sriov_vf(adev)) { + for (i = 0; i < adev->sdma.num_instances; i++) { + adev->nbio.funcs->sdma_doorbell_range(adev, i, + true, adev->doorbell_index.sdma_engine[i] << 1, + adev->doorbell_index.sdma_doorbell_range); + } + } +} + static int soc15_common_hw_init(void *handle) { struct amdgpu_device *adev = (struct amdgpu_device *)handle; @@ -1281,6 +1295,13 @@ static int soc15_common_hw_init(void *handle) /* enable the doorbell aperture */ soc15_enable_doorbell_aperture(adev, true); + /* HW doorbell routing policy: doorbell writing not + * in SDMA/IH/MM/ACV range will be routed to CP. So + * we need to init SDMA doorbell range prior + * to CP ip block init and ring test. IH already + * happens before CP. + */ + soc15_sdma_doorbell_range_init(adev); return 0; }