Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp2127577rdb; Thu, 17 Aug 2023 11:25:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSOkww9OKIcxQvTp/vpqMB4MHxqSRjTbdtYJGpukEIl3pXJzNzrubM+dxtvpEWbZ+4USZ5 X-Received: by 2002:a17:906:305b:b0:99c:f966:9e9e with SMTP id d27-20020a170906305b00b0099cf9669e9emr172217ejd.49.1692296728592; Thu, 17 Aug 2023 11:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692296728; cv=none; d=google.com; s=arc-20160816; b=UEhbQ6Y3xwN5U3k95oPCt60Oi/lojA0IvvE/dBIcTUUhN9qOLDC0AKLcONfsGs8nXA nyi6ZtXt/yAbchX8I5qZv33gwQC0Ue7vCHe9OGfDXgc5FlHgB5scMzG9jMVvmEm3qkAn /brnPOWmWmBf3KBthUuREgUw9LFBP9o9lF0oSy11b6x2Gn5ySdMfFKO1O6eydGgw9KM4 wumpG/JquwDU5Q7HoWyQGow5ZERyWjDxTrZfpIP064M6YrsMmG0h1sqZxUBEb4lpcfWP 4v3/1Qq1ofieJuTbZLG9M0PUpd4WHgxZRmL5NHwLDuxjIBCM2X+A2Pg5iB8OULLNNjGT ZNjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Abhsr4wAJkBHjt5gPP6KEIw82cxDP5GLaTx4EpSEDTs=; fh=ZFY0izREKkLAdYh7e0/ogvTjudDNaLj3cnTgy4GHeWU=; b=XhDBm9YHzfQ03FeivLdHiss8aqIDOf6+/JIeCAH6kZvfKXYlMwpExdLZJYKC4WQkJN GDbnHEgbKetFsUP3GGUqBzUIgBBfKFV2CGONa66NMDOO+3Y0hDMeGCFJ3UY6xfWnmQW2 SZZxiPUYNf+QDzhX63MfA+0m+Zpk6MvFsYFKrZ8tCzd274RCuNc/kGVrjJ6wqpR4dDjE RbB3PfUVQwD/Yq9tzNRIel2JQ8gGUDEJCQLiulz1C62ZCM8PPz50GSSsOyBIGsWE/Fx5 kmO++AwNlclUwBNlV12eLrrMKvIboQWVxQ3QjkkcoWp0BolSNdDzphxHlE7GQHOmsKJ8 jNjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=s7n2Gqx8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dv12-20020a170906b80c00b00992ca9eab82si59599ejb.393.2023.08.17.11.25.03; Thu, 17 Aug 2023 11:25:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=s7n2Gqx8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353233AbjHQPiy (ORCPT + 99 others); Thu, 17 Aug 2023 11:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353255AbjHQPi3 (ORCPT ); Thu, 17 Aug 2023 11:38:29 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B92130C5 for ; Thu, 17 Aug 2023 08:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Abhsr4wAJkBHjt5gPP6KEIw82cxDP5GLaTx4EpSEDTs=; b=s7n2Gqx8odgjU9jxl0Af1p0Rrl MLMfGUL/lO0LtGt1EKZMJlEW4CbKXZXNIgIw5iJUdVcykDfF7MlXpTedcJ369k6Z4VzpkajMC0BSC LDyMTiXxfQyK2hJizvGMF/3iK48pclfq8ciymfeP6GPUe4wag+r/NQIhWHS/gg+xxnTbR82ciFPsV DoBHx0PKRI3gOu4COtkRNIYZaTW/ZvV/9AbMb98+2V1ZxRDEyLvPSd/VCe3UkmADtBEW0o6mOvbMt Dlis387iIL2yhaiK39sqTD8lwzBdVYiCw5f3Ggg3XtToVb3giyetkF3eSEqTUARlWF6DddVr3FmCl QAip7EYQ==; Received: from [191.193.179.209] (helo=[192.168.1.111]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1qWf4n-001yCJ-VO; Thu, 17 Aug 2023 17:38:22 +0200 Message-ID: <48c9521c-88f5-4975-8bf0-85ac42431a36@igalia.com> Date: Thu, 17 Aug 2023 12:38:17 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 2/4] drm/amdgpu: Rework coredump to use memory dynamically Content-Language: en-US To: Shashank Sharma Cc: pierre-eric.pelloux-prayer@amd.com, amd-gfx@lists.freedesktop.org, =?UTF-8?B?J01hcmVrIE9sxaHDoWsn?= , =?UTF-8?Q?Timur_Krist=C3=B3f?= , Samuel Pitoiset , kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20230815195100.294458-1-andrealmeid@igalia.com> <20230815195100.294458-3-andrealmeid@igalia.com> <07ef59db-da17-15cf-789a-7f5d01b2c9c9@amd.com> <43f2df2f-46ff-4240-a86b-eff5f0c08888@igalia.com> From: =?UTF-8?Q?Andr=C3=A9_Almeida?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em 17/08/2023 12:26, Shashank Sharma escreveu: > > On 17/08/2023 17:17, André Almeida wrote: >> >> >> Em 17/08/2023 12:04, Shashank Sharma escreveu: >>> >>> On 17/08/2023 15:45, André Almeida wrote: >>>> Hi Shashank, >>>> >>>> Em 17/08/2023 03:41, Shashank Sharma escreveu: >>>>> Hello Andre, >>>>> >>>>> On 15/08/2023 21:50, André Almeida wrote: >>>>>> Instead of storing coredump information inside amdgpu_device struct, >>>>>> move if to a proper separated struct and allocate it dynamically. >>>>>> This >>>>>> will make it easier to further expand the logged information. >>>>>> >>>>>> Signed-off-by: André Almeida >>>>>> --- >>>>>> v4: change kmalloc to kzalloc >>>>>> --- >>>>>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 14 +++-- >>>>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 63 >>>>>> ++++++++++++++-------- >>>>>>   2 files changed, 49 insertions(+), 28 deletions(-) >>>>>> >>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>>>>> index 9c6a332261ab..0d560b713948 100644 >>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>>>>> @@ -1088,11 +1088,6 @@ struct amdgpu_device { >>>>>>       uint32_t *reset_dump_reg_list; >>>>>>       uint32_t            *reset_dump_reg_value; >>>>>>       int                             num_regs; >>>>>> -#ifdef CONFIG_DEV_COREDUMP >>>>>> -    struct amdgpu_task_info         reset_task_info; >>>>>> -    bool                            reset_vram_lost; >>>>>> -    struct timespec64               reset_time; >>>>>> -#endif >>>>>>       bool                            scpm_enabled; >>>>>>       uint32_t                        scpm_status; >>>>>> @@ -1105,6 +1100,15 @@ struct amdgpu_device { >>>>>>       uint32_t            aid_mask; >>>>>>   }; >>>>>> +#ifdef CONFIG_DEV_COREDUMP >>>>>> +struct amdgpu_coredump_info { >>>>>> +    struct amdgpu_device        *adev; >>>>>> +    struct amdgpu_task_info         reset_task_info; >>>>>> +    struct timespec64               reset_time; >>>>>> +    bool                            reset_vram_lost; >>>>>> +}; >>>>> >>>>> The patch looks good to me in general, but I would recommend >>>>> slightly different arrangement and segregation of GPU reset >>>>> information. >>>>> >>>>> Please consider a higher level structure adev->gpu_reset_info, and >>>>> move everything related to reset dump info into that, including >>>>> this new coredump_info structure, something like this: >>>>> >>>>> struct amdgpu_reset_info { >>>>> >>>>>      uint32_t *reset_dump_reg_list; >>>>> >>>>>      uint32_t *reset_dump_reg_value; >>>>> >>>>>      int num_regs; >>>>> >>>> >>>> Right, I can encapsulate there reset_dump members, >>>> >>>>> #ifdef CONFIG_DEV_COREDUMP >>>>> >>>>>     struct amdgpu_coredump_info *coredump_info;/* keep this dynamic >>>>> allocation */ >>>> >>>> but we don't need a pointer for amdgpu_coredump_info inside >>>> amdgpu_device or inside of amdgpu_device->gpu_reset_info, right? >>> >>> I think it would be better if we keep all of the GPU reset related >>> data in the same structure, so adev->gpu_reset_info->coredump_info >>> sounds about right to me. >>> >> >> But after patch 2/4, we don't need to store a coredump_info pointer >> inside adev, this is what I meant. What would be the purpose of having >> this pointer? It's freed by amdgpu_devcoredump_free(), so we don't >> need to keep track of it. > > Well, actually we are pulling in some 0parallel efforts on enhancing the > GPU reset information, and we were planning to use the coredump info for > some additional things. So if I have the coredump_info available (like > reset_task_info and vram_lost) across a few functions in the driver with > adev, it would make my job easy there :). It seems dangerous to use an object with this limited lifetime to rely to read on. If you want to use it you will need to change amdgpu_devcoredump_free() to drop a reference or you will need to use it statically, which defeats the purpose of this patch. Anyway, I'll add it as you requested. > > - Shashank > >> >>> - Shashank >>> >>>> >>>>> >>>>> #endif >>>>> >>>>> } >>>>> >>>>> >>>>> This will make sure that all the relevant information is at the >>>>> same place. >>>>> >>>>> - Shashank >>>>> >>>>        amdgpu_inc_vram_lost(tmp_adev);