Received: by 10.223.176.5 with SMTP id f5csp1034575wra; Fri, 2 Feb 2018 10:03:22 -0800 (PST) X-Google-Smtp-Source: AH8x224Faj1DeOnPyHuBKK0dVlFrJQOI890kMemwy2A+OQLEPUJ9y5pi9neumGRLWXZS3ZB/m3X/ X-Received: by 10.98.65.156 with SMTP id g28mr6414858pfd.124.1517594602715; Fri, 02 Feb 2018 10:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594602; cv=none; d=google.com; s=arc-20160816; b=H75hmEDMmdXNcIa1qJ5oVgY/dwEg6e6Wke0MQjNbE+2DHeQON+0HL1p/Mr4xhXxDYP /LPNGusesoonbcKkeJ4hIMFJYRgrdv+UwGq6hbtQ5SjdC79EpogzUTdEsGQhA0nC0cEh FcIibO/HkQt/0VjHdn53ueKpKodmerwzi7ghYjXLM8KvkzcW7NREWEUSfssIkobMIvf2 eEar2wr/E3eUJB+CgTz5lIXo4QY7IYdUDUrRPGai4DNsCfVckjOKOuswtoUFNDjh2gl+ 91b5zEWibw09cMM2cbYvPg33VGr6iH+kI4p0km2h8GzxrAHzkwk1gzPiwawlM1Xj8IVR ZbSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zD9Z2Tg6Aj9bRAehCXhKOZN+pbIQR1owPWgDow2xeis=; b=do+AJVss0Fu7iBlwcQDqRLJNZ5Xxs7KkldxCa5tSPMyzHbj0jP7HPmLcSoy4Rjy7X5 kZCMgpzp/MWpfCplR4PhTxwSCfFzxmRqmRvlaJ2hCwqhSVvTXtp3Wz11RhvPK2gd+SAD 7NUFyeVYSsKujT3G9AU6f1O5P0XguionfsZdn1qMLD8Iy4IL0s5F/RHtEOTVWNzicNNU QfIA4dvLVO4hkfluE/y06WZjzV0ckT4lPFuwz4w1+IqdWAVdqh1NcdfhG/E6bP244kuv HoZIYsb7YrK4y528ZKtr9OzcqF+ZSZtE4BjpQDQG6MqB8Ze4qn9MKGgja8bDfEJMWrLf rDmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17-v6si2109534plo.357.2018.02.02.10.03.07; Fri, 02 Feb 2018 10:03:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753637AbeBBSAg (ORCPT + 99 others); Fri, 2 Feb 2018 13:00:36 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38068 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753029AbeBBRJv (ORCPT ); Fri, 2 Feb 2018 12:09:51 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7944CEF7; Fri, 2 Feb 2018 17:09:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, shaoyun liu , Felix Kuehling , Oded Gabbay , Sasha Levin Subject: [PATCH 4.14 062/156] drm/amdgpu: Fix SDMA load/unload sequence on HWS disabled mode Date: Fri, 2 Feb 2018 17:57:23 +0100 Message-Id: <20180202140843.100000679@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Felix Kuehling [ Upstream commit cf21654b40968609779751b34e7923180968fe5b ] Fix the SDMA load and unload sequence as suggested by HW document. Signed-off-by: shaoyun liu Signed-off-by: Felix Kuehling Acked-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 47 +++++++++++++++------- 1 file changed, 34 insertions(+), 13 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c @@ -369,29 +369,50 @@ static int kgd_hqd_sdma_load(struct kgd_ { struct amdgpu_device *adev = get_amdgpu_device(kgd); struct cik_sdma_rlc_registers *m; + unsigned long end_jiffies; uint32_t sdma_base_addr; + uint32_t data; m = get_sdma_mqd(mqd); sdma_base_addr = get_sdma_base_addr(m); - WREG32(sdma_base_addr + mmSDMA0_RLC0_VIRTUAL_ADDR, - m->sdma_rlc_virtual_addr); + WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_CNTL, + m->sdma_rlc_rb_cntl & (~SDMA0_RLC0_RB_CNTL__RB_ENABLE_MASK)); - WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_BASE, - m->sdma_rlc_rb_base); + end_jiffies = msecs_to_jiffies(2000) + jiffies; + while (true) { + data = RREG32(sdma_base_addr + mmSDMA0_RLC0_CONTEXT_STATUS); + if (data & SDMA0_RLC0_CONTEXT_STATUS__IDLE_MASK) + break; + if (time_after(jiffies, end_jiffies)) + return -ETIME; + usleep_range(500, 1000); + } + if (m->sdma_engine_id) { + data = RREG32(mmSDMA1_GFX_CONTEXT_CNTL); + data = REG_SET_FIELD(data, SDMA1_GFX_CONTEXT_CNTL, + RESUME_CTX, 0); + WREG32(mmSDMA1_GFX_CONTEXT_CNTL, data); + } else { + data = RREG32(mmSDMA0_GFX_CONTEXT_CNTL); + data = REG_SET_FIELD(data, SDMA0_GFX_CONTEXT_CNTL, + RESUME_CTX, 0); + WREG32(mmSDMA0_GFX_CONTEXT_CNTL, data); + } + WREG32(sdma_base_addr + mmSDMA0_RLC0_DOORBELL, + m->sdma_rlc_doorbell); + WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_RPTR, 0); + WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_WPTR, 0); + WREG32(sdma_base_addr + mmSDMA0_RLC0_VIRTUAL_ADDR, + m->sdma_rlc_virtual_addr); + WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_BASE, m->sdma_rlc_rb_base); WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_BASE_HI, m->sdma_rlc_rb_base_hi); - WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_RPTR_ADDR_LO, m->sdma_rlc_rb_rptr_addr_lo); - WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_RPTR_ADDR_HI, m->sdma_rlc_rb_rptr_addr_hi); - - WREG32(sdma_base_addr + mmSDMA0_RLC0_DOORBELL, - m->sdma_rlc_doorbell); - WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_CNTL, m->sdma_rlc_rb_cntl); @@ -564,9 +585,9 @@ static int kgd_hqd_sdma_destroy(struct k } WREG32(sdma_base_addr + mmSDMA0_RLC0_DOORBELL, 0); - WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_RPTR, 0); - WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_WPTR, 0); - WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_BASE, 0); + WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_CNTL, + RREG32(sdma_base_addr + mmSDMA0_RLC0_RB_CNTL) | + SDMA0_RLC0_RB_CNTL__RB_ENABLE_MASK); return 0; }