Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, MIME_HTML_MOSTLY,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,T_KAM_HTML_FONT_INVALID, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92D97C43603 for ; Thu, 12 Dec 2019 15:20:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B111205C9 for ; Thu, 12 Dec 2019 15:20:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="hvX6L1kt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B111205C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6AAE89BEC; Thu, 12 Dec 2019 15:20:26 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2056.outbound.protection.outlook.com [40.107.236.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C5A089BEC; Thu, 12 Dec 2019 15:20:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WUVzH5SNKljoyIuFSGBTFAuzHqcgZA839ABjRS47PEHPJTrjL84ub0F72qqdJrS+hi/P91yLGIyVWjEr5Y6c+Chmz0rx2+Ke/Yt42D2PHE2B0nyUBeLlDHVbvX9+v7azeFu2wmsvcQDBZcque/+q6jekCg0qW+if0DZfEyT14k93WRR50cM1ulG9S4Z+mWXkjJc9U3r8NjMGukRWM3vjpvjWK9/gFIwmD6g8+vwVDosXFiIiaYgIAK64Rbacl/CGuVP18QDb9O6UtZ2sJWA8gbn8jEhQCuJso0RUxnnGAhvKJ+nsPFFaeVx+h6V3KmBQy23KgB15C0odDqrE69y02g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mvmhn2m2+mcHTkDODqje7D02hV+6jnDqAEW/H18RHYg=; b=edVSqbTQbW8nKgVJB/atdzPObKU3pQppIbcQ2DVHSsd8KeYIKuZsKbPngtBSooU9KQolA1w4b15vVx4e3I2e7B6pK5LfjP+vtxjhcJVI1ZYwysDlYF7dE8WSkJMLT7Vna5+ySNg+B+8GczpULy4g2+3Qls6fpm0seKAi7Q8HXfJVpM2qxCcd0piIbeXs6uQKs0FEMYm4fTcxQ5y+V2CRjkQ8F2p8WKmJGQ4DU5Jm83jRgAgV+UxwSTEG5QLxrtjOtkPxJRFnon67qy9atCTFHTz7TGcYB7gOpabQ5puUaFC5vaKPtPhn1BfaJwu+4Eu7ULD5kUiA2D79xSkMT0xcqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mvmhn2m2+mcHTkDODqje7D02hV+6jnDqAEW/H18RHYg=; b=hvX6L1ktTwa4mOoNtOnd5fH3qkQa0eDIy90iZHavWsdT7QflZyIhvyaozQxd5d6RcyHlUgc7SN9++JxQmJhoyzOw+yvjcnld8gkYBy7CoXYnadXNR3Ofpo5x8MOYGc3jIRm1aldkskbkyFpq4bG8BY/zXwWfZSzwHDEknuC+Q28= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Andrey.Grodzovsky@amd.com; Received: from MWHPR12MB1453.namprd12.prod.outlook.com (10.172.55.22) by MWHPR12MB1693.namprd12.prod.outlook.com (10.172.56.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.18; Thu, 12 Dec 2019 15:20:08 +0000 Received: from MWHPR12MB1453.namprd12.prod.outlook.com ([fe80::514b:dbf8:d19f:a80]) by MWHPR12MB1453.namprd12.prod.outlook.com ([fe80::514b:dbf8:d19f:a80%12]) with mapi id 15.20.2538.016; Thu, 12 Dec 2019 15:20:08 +0000 Subject: Re: [RESEND PATCH 4/5] Subject: drm/amdgpu: Redo XGMI reset synchronization. To: "Ma, Le" , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" References: <1576096732-3596-1-git-send-email-andrey.grodzovsky@amd.com> <1576096732-3596-4-git-send-email-andrey.grodzovsky@amd.com> From: Andrey Grodzovsky Message-ID: Date: Thu, 12 Dec 2019 10:20:05 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: YTBPR01CA0033.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:14::46) To MWHPR12MB1453.namprd12.prod.outlook.com (2603:10b6:301:e::22) MIME-Version: 1.0 X-Originating-IP: [2607:fea8:3edf:e127:3a1e:65e:fc37:38e9] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6ed155b6-8bd1-434d-3e78-08d77f16c59e X-MS-TrafficTypeDiagnostic: MWHPR12MB1693:|MWHPR12MB1693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 0249EFCB0B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(346002)(376002)(136003)(39850400004)(396003)(501774003)(199004)(189003)(13464003)(5660300002)(6666004)(478600001)(53546011)(8676002)(6506007)(52116002)(66946007)(33964004)(66476007)(66556008)(2616005)(2906002)(110136005)(54906003)(31686004)(316002)(6512007)(4326008)(36756003)(8936002)(6486002)(450100002)(31696002)(81156014)(81166006)(186003)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1693; H:MWHPR12MB1453.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yoJ4dFmypIvOUzOybd7UNETyzggnkf1qWkh+l7WpkRxMlTIzgS51Dcu+xQH6qiy2rw7OMZYIVNmu9JJXyRkAR4eBT5wLAG0zTY+qCJvm6TjVrELG8k+B5wDJ2HqVQJGM247aC90H1uNHm4fIQnh20KjGFqBbv8f6pYGoZIgJUCgSwnkn2kn9yyH9oZwP/iBdDPtXL0yhItTrU8IDgIyQNBct1T1oz66gIHMZnTdhAKVP9+D0AwEfbIcmpmerjIShw4Nyx22cESL7QA3OhFyYVQ2Nz9W7I1MGU11rufY7monecMDS0choElMZC/BwzCvsINh3F7OgXoYFPMo00DsORQKOrRs5BWqJnui8oQU6+j/jwjiyRNZtr5jm4x2MjSqMoMv81V5LgLJ/xzu9De5Uj2940zt/ahKc70yN3jU4FPg5iaeqymLwB0W4MGHfv2N6iLJ7EnFYFy6aWaDFnSFgePEp67Hyx6C9uNm008NG7yq65ITb0TC551rOyt3XxyBrsqjseWV/5dfJBLp6teE68A== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ed155b6-8bd1-434d-3e78-08d77f16c59e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2019 15:20:08.1273 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 13tnYTYZKkHazJS/+IlRzCqGjoDY0Mn6ADPfYdrqw/nf1thX44KKF9uuHMWzQMYckTFmhzDMp9FLmG2Fx3hJ0Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1693 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Deucher, Alexander" , "Quan, Evan" , "Zhang, Hawking" Content-Type: multipart/mixed; boundary="===============0326678279==" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --===============0326678279== Content-Type: multipart/alternative; boundary="------------E1B97FE587FE95F3BFF5E1EE" Content-Language: en-US --------------E1B97FE587FE95F3BFF5E1EE Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 12/11/19 11:05 PM, Ma, Le wrote: > > [AMD Official Use Only - Internal Distribution Only] > > -----Original Message----- > From: Andrey Grodzovsky > Sent: Thursday, December 12, 2019 4:39 AM > To: dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org > Cc: Deucher, Alexander ; Ma, Le > ; Zhang, Hawking ; Quan, Evan > ; Grodzovsky, Andrey > Subject: [RESEND PATCH 4/5] Subject: drm/amdgpu: Redo XGMI reset > synchronization. > > Use task barrier in XGMI hive to synchronize ASIC resets across > devices in XGMI hive. > > Signed-off-by: Andrey Grodzovsky > > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 42 > +++++++++++++++++++++++++----- > > 1 file changed, 36 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > index 1d19edfa..e4089a0 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > @@ -67,6 +67,7 @@ > > #include "amdgpu_tmz.h" > >  #include > > +#include > >  MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); > > MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin"); > > @@ -2663,14 +2664,43 @@ static void > amdgpu_device_xgmi_reset_func(struct work_struct *__work)  { > >            struct amdgpu_device *adev = > > container_of(__work, struct amdgpu_device, xgmi_reset_work); > > +          struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev, 0); > > -           if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) > > - adev->asic_reset_res = (adev->in_baco == false) ? > > - amdgpu_device_baco_enter(adev->ddev) : > > - qamdgpu_device_baco_exit(adev->ddev); > > -           else > > - adev->asic_reset_res = amdgpu_asic_reset(adev); > > +          /* > > +          * Use task barrier to synchronize all xgmi reset works > across the > > +          * hive. > > +          * task_barrier_enter and task_barrier_exit will block > untill all the > > +          * threads running the xgmi reset works reach those points. > I assume > > +          * guarantee of progress here for all the threads as the > workqueue code > > +          * creates new worker threads as needed by amount of work > items in queue > > +          * (see worker_thread) and also each thread sleeps in the > barrir and by > > +          * this yielding the CPU for other work threads to make > progress. > > +          */ > > [Le]: This comments can be adjusted since we switch to > system_unbound_wq in patch #5. > > +          if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) { > > + > > +                      if (hive) > > + task_barrier_enter(&hive->tb); > > [Le]: The multiple hive condition can be checked only once and moved > to the location right after the assignment. > Not sure what you meant here but in fact let's note that while in amdgpu_device_xgmi_reset_func it's a bug for amdgpu_get_xgmi_hive to return NULL so I think better instead to add WARN_ON(!hive,"...") and return right at the beginning of the function if indeed hive == NULL Andrey > + > > + adev->asic_reset_res = amdgpu_device_baco_enter(adev->ddev); > > + > > +                      if (adev->asic_reset_res) > > +                                  goto fail; > > + > > +                      if (hive) > > + task_barrier_exit(&hive->tb); > > [Le]: Same as above. > > + > > + adev->asic_reset_res = amdgpu_device_baco_exit(adev->ddev); > > + > > +                      if (adev->asic_reset_res) > > +                                  goto fail; > > +          } else { > > +                      if (hive) > > + task_barrier_full(&hive->tb); > > [Le]: Same as above. > > With above addressed, Reviewed-by: Le Ma > > > Regards, > > Ma Le > > + > > + adev->asic_reset_res =  amdgpu_asic_reset(adev); > > +          } > > +fail: > >            if (adev->asic_reset_res) > >                        DRM_WARN("ASIC reset failed with error, %d for > drm dev, %s", > >  adev->asic_reset_res, adev->ddev->unique); > > -- > > 2.7.4 > --------------E1B97FE587FE95F3BFF5E1EE Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit


On 12/11/19 11:05 PM, Ma, Le wrote:

[AMD Official Use Only - Internal Distribution Only]

 

 

 

-----Original Message-----
From: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Sent: Thursday, December 12, 2019 4:39 AM
To: dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Ma, Le <Le.Ma@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>
Subject: [RESEND PATCH 4/5] Subject: drm/amdgpu: Redo XGMI reset synchronization.

 

Use task barrier in XGMI hive to synchronize ASIC resets across devices in XGMI hive.

 

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>

---

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 42 +++++++++++++++++++++++++-----

1 file changed, 36 insertions(+), 6 deletions(-)

 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 1d19edfa..e4089a0 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

@@ -67,6 +67,7 @@

#include "amdgpu_tmz.h"

 

 #include <linux/suspend.h>

+#include <drm/task_barrier.h>

 

 MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");

MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin");

@@ -2663,14 +2664,43 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)  {

           struct amdgpu_device *adev =

                       container_of(__work, struct amdgpu_device, xgmi_reset_work);

+          struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev, 0);

 

-           if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)

-                       adev->asic_reset_res = (adev->in_baco == false) ?

-                                               amdgpu_device_baco_enter(adev->ddev) :

-                                               qamdgpu_device_baco_exit(adev->ddev);

-           else

-                       adev->asic_reset_res = amdgpu_asic_reset(adev);

+          /*

+          * Use task barrier to synchronize all xgmi reset works across the

+          * hive.

+          * task_barrier_enter and task_barrier_exit will block untill all the

+          * threads running the xgmi reset works reach those points. I assume

+          * guarantee of progress here for all the threads as the workqueue code

+          * creates new worker threads as needed by amount of work items in queue

+          * (see worker_thread) and also each thread sleeps in the barrir and by

+          * this yielding the CPU for other work threads to make progress.

+          */

[Le]: This comments can be adjusted since we switch to system_unbound_wq in patch #5.

+          if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {

+

+                      if (hive)

+                                  task_barrier_enter(&hive->tb);

[Le]: The multiple hive condition can be checked only once and moved to the location right after the assignment.


Not sure what you meant here but in fact let's note that while in amdgpu_device_xgmi_reset_func it's a bug for amdgpu_get_xgmi_hive to return NULL so I think better instead to add WARN_ON(!hive,"...") and return right at the beginning of the function if indeed hive == NULL

Andrey


+

+                      adev->asic_reset_res = amdgpu_device_baco_enter(adev->ddev);

+

+                      if (adev->asic_reset_res)

+                                  goto fail;

+

+                      if (hive)

+                                  task_barrier_exit(&hive->tb);

[Le]: Same as above.

+

+                      adev->asic_reset_res = amdgpu_device_baco_exit(adev->ddev);

+

+                      if (adev->asic_reset_res)

+                                  goto fail;

+          } else {

+                      if (hive)

+                                  task_barrier_full(&hive->tb);

[Le]: Same as above.

 

With above addressed, Reviewed-by: Le Ma <Le.Ma@amd.com>

 

Regards,

Ma Le

+

+                      adev->asic_reset_res =  amdgpu_asic_reset(adev);

+          }

 

+fail:

           if (adev->asic_reset_res)

                       DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",

                                    adev->asic_reset_res, adev->ddev->unique);

--

2.7.4

 

--------------E1B97FE587FE95F3BFF5E1EE-- --===============0326678279== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel --===============0326678279==--