Received: by 10.223.176.46 with SMTP id f43csp282810wra; Tue, 23 Jan 2018 21:01:11 -0800 (PST) X-Google-Smtp-Source: AH8x227vGB1IQlsFGynUjASLPaDpbQ7+MVik5aKkmfEBYMCVSD3fIsyEDhUSPD5GTtTIV8buZFQ9 X-Received: by 10.99.94.193 with SMTP id s184mr9641214pgb.397.1516770071186; Tue, 23 Jan 2018 21:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516770071; cv=none; d=google.com; s=arc-20160816; b=Rj3U4J5oYvqa3RCWUocNOU7ZPPUluFOagQjcBUTKEwFE3aiKhI+I6n9IFCIgeLd18G bMElaILoJLnUmOuOtTwZxC5VSlPvB05Lo6tNwjhfsM0iQNz1a2k59ERcdCbn0A9gJB/d iMWoupw2P1UEAg3G/bkPqLV0JEdAHRhHCu9QByvGKN2zn09FTQw3aXBcpbyWYtNH/jkH E59Ik+0HHhi4zbj+Z2vBarmUJqXk3k/XRpELrRh/TP1tPzftwlySU3wu6ulmKnLJg/lH uNHtxQeaX18+zs8nBrcNwDvdQYn3jQEkFrpiOYZrkvFzUe0oLeDjQ96j/IAgwhn0/uR3 zxxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=44ip+C6eM79ZZZZ5V+sMbiQF3Ef4W2G92m0jFlTl5Aw=; b=r1+hZv51vi0C2FedD/bVuR9noocsu0V98+3u6KSREd7ENb886JvlPpKn8UoCe7TYwJ 8h7uaca+2ZNuXrqCoylGFYTdIknzVUE8E5kBSIYjiNPCV6rcsHX+aXFypTdU7+cSnEAg uruCGjGgTHMthLEZvD6n/0Qxmi4faatI1uU6erMapEZRCeFOsasI+FqsbEOybTIwjgMJ T2Pay3gGSORq30W8axzUS+FWuRRK+RAVs+uX3tWL8EsnxT5T0Iz267uj2HI99ve/Pnnh KpKNAVyJhKK35FmW0D79W3qhpnP9AmlkxYfbpiu0dd4+J4rO12TteZshjbvI/qqmuepC V6qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=J0hzrmd6; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o13si15362017pgp.740.2018.01.23.21.00.57; Tue, 23 Jan 2018 21:01:11 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=J0hzrmd6; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750992AbeAXFAN (ORCPT + 99 others); Wed, 24 Jan 2018 00:00:13 -0500 Received: from mail-sn1nam01on0111.outbound.protection.outlook.com ([104.47.32.111]:45037 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932115AbeAXEPN (ORCPT ); Tue, 23 Jan 2018 23:15:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=44ip+C6eM79ZZZZ5V+sMbiQF3Ef4W2G92m0jFlTl5Aw=; b=J0hzrmd6nqWch6iooQ4ZnmwWHBuqmlLTOx1Ip8dFC20dM8SUsGxsoTVoJhIczSQR3qvh4Zj9V6r1zobGKDLh7hDB8fPUXX/2FC9670yI3ScSnQX0Kq4lNWTVhNyMRMIeIciIk+EcboZ0h3wg6PlmRY/KyHtdciG99oL/JPMGHjQ= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0998.namprd21.prod.outlook.com (52.132.133.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.0; Wed, 24 Jan 2018 04:15:09 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:15:09 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Felix Kuehling , shaoyun liu , Oded Gabbay , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 033/100] drm/amdgpu: Fix SDMA load/unload sequence on HWS disabled mode Thread-Topic: [PATCH AUTOSEL for 4.14 033/100] drm/amdgpu: Fix SDMA load/unload sequence on HWS disabled mode Thread-Index: AQHTlMnarKgozQszkkuwZUfbhOfQJA== Date: Wed, 24 Jan 2018 04:14:40 +0000 Message-ID: <20180124041414.32065-33-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0998;7:9RauYn23MphU7703zyxK5TetFkpU+1Mow7aX2VXxz/PCr9EvoxaPnvxRNm1U1gLaFeIrPqZ5rGXdeKB3N/2ak9jMCxHBV01ENJtETuICwgNsGIZJej+y+KI0RgvaWhq0OPCfABG0q9N4UeUlOngysdJp72NnHMKI5I8I27fkOKN503cKKFY/cyxso1JYbla7p3ZYrblEEWt1Ge4lc8SGym523yF6e0lac6v+3t3pAUIVUEZZ9upmJtQ3cTxWcbY0 x-ms-office365-filtering-correlation-id: 6f6ef006-33a0-4a78-e18a-08d562e10ecd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB0998; x-ms-traffictypediagnostic: DM5PR2101MB0998: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158)(767451399110); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231046)(2400081)(944501161)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0998;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0998; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(39380400002)(346002)(39860400002)(396003)(376002)(199004)(189003)(14454004)(3660700001)(6346003)(10290500003)(105586002)(66066001)(6506007)(8676002)(22452003)(86612001)(54906003)(10090500001)(81166006)(81156014)(76176011)(110136005)(86362001)(68736007)(106356001)(8936002)(3280700002)(36756003)(25786009)(107886003)(39060400002)(2501003)(6666003)(99286004)(2906002)(26005)(2950100002)(72206003)(102836004)(305945005)(6116002)(3846002)(5660300001)(4326008)(478600001)(316002)(53936002)(97736004)(8666007)(2900100001)(5250100002)(6512007)(6436002)(6486002)(1076002)(7736002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0998;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: +KbTyhyOnIN1XqTljy7uKeUZhPiLWUTqSjnYpSEXtLvARaut9W1+RQ0njnpyeGDqPTNxdtNe4XVw3vx/N4d0MQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f6ef006-33a0-4a78-e18a-08d562e10ecd X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:40.0899 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0998 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 47 ++++++++++++++++---= ---- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c b/drivers/gp= u/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c index b9dbbf9cb8b0..bdabaa3399db 100644 --- 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_dev *kgd, voi= d *mqd) { struct amdgpu_device *adev =3D get_amdgpu_device(kgd); struct cik_sdma_rlc_registers *m; + unsigned long end_jiffies; uint32_t sdma_base_addr; + uint32_t data; =20 m =3D get_sdma_mqd(mqd); sdma_base_addr =3D get_sdma_base_addr(m); =20 - 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)); =20 - WREG32(sdma_base_addr + mmSDMA0_RLC0_RB_BASE, - m->sdma_rlc_rb_base); + end_jiffies =3D msecs_to_jiffies(2000) + jiffies; + while (true) { + data =3D 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 =3D RREG32(mmSDMA1_GFX_CONTEXT_CNTL); + data =3D REG_SET_FIELD(data, SDMA1_GFX_CONTEXT_CNTL, + RESUME_CTX, 0); + WREG32(mmSDMA1_GFX_CONTEXT_CNTL, data); + } else { + data =3D RREG32(mmSDMA0_GFX_CONTEXT_CNTL); + data =3D REG_SET_FIELD(data, SDMA0_GFX_CONTEXT_CNTL, + RESUME_CTX, 0); + WREG32(mmSDMA0_GFX_CONTEXT_CNTL, data); + } =20 + 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); =20 @@ -564,9 +585,9 @@ static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, vo= id *mqd, } =20 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); =20 return 0; } --=20 2.11.0