From patchwork Mon Feb 12 21:15:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 13553993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 551FDC48BC3 for ; Mon, 12 Feb 2024 21:16:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C28AC10E5AF; Mon, 12 Feb 2024 21:16:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="XMIK6suj"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2079.outbound.protection.outlook.com [40.107.220.79]) by gabe.freedesktop.org (Postfix) with ESMTPS id 65EE010E3D2; Mon, 12 Feb 2024 21:16:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QpBqHRHd4m/6ss1XIOJ60I0BRl7TVLnS5Q2X1ptRhczBy5pe/adEaXzh9+OUJ4UuGRMEDxfstiAlk8lpgfQHndz/YqWa0bxv5NIrMeiPWy5BeprpISnQjl9xE3O3t8twZ1cGz0PQwUsuR1GDJEUe77XWPxckgHMtgdqOW/EvnjQ47+06EAYUgD4lI6UaGzACOgdMg9OvOARlOpEMbQz6QnWI1ehFIbHn3UrPVReDkXgcnuw1CCcd2AsP0kJWtxaHpppXuTrKIm6/BZAWseLjL5HIWTl2myIP4O8QWnr1YBjeDcp89ZMRWXu2In90Yu7y/wZGD6WxhviWI49fXrjT3w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jurtFpPky2rTAr7zBd0w6oCAWMb+lT0VIckZxa/oYl4=; b=jfj27gdfdREKOhBJ9eyLPQ+Bpv6Jt6Cofsoc+zWzdc37C+ailVU6R9YmdulryAT+Ax5fLg5QJrGX9KYuH9HQ1we51OIwxK56YQpTKfoWfFKaw8k4baIXv5GCpqqKiXczr30eT122tLGreVH+e+s4DtJgdjErVz4O55B4W1GLxvimCTuqrwOIrJOf03eamhBwaxLvuOireR8nu7Mv1rDOzOvXQ7x6QViYqHuhwnciDNhqWKfqQ79k9TstqxB83EOKVz9SOVXXcaMWZgNW6skdhrHIdKCzeD8o0jTPkH57XOiKfnHOXOF0WeT1DXav/dCWP3t6rqDzsMTrjW1os5UDyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jurtFpPky2rTAr7zBd0w6oCAWMb+lT0VIckZxa/oYl4=; b=XMIK6sujvnTHbF9vkHN6x5MS1b/PA9C9HlZryF/UEkwRFNWrhGP+c/68aVVC1MVBvAMGPJz6K3xsjkytfEYfKeSOnZ5EqE1DlQo+rBAuB34ofXwoEiOtpkUcECN4+Fh8xDOjdAy/sCMjQPmENm5rHe3uapt5p8PK7/Fr/NTwjSpc4ax5y1tsfzorip0Y8Dj4SbmJsszpM+JNGMaBx9GJr6gEeRu69VoQ3hBIJu/QmyS4fJ/U1vDjixLQ6BC7EGVaUnSjckD/WwrfP/LW5+aFkKJYL6KwcD2TEAz02+HWnTHoR2+qSebK+zNBmAA2tCcjr+vGEZMH1oSfh+quwoEuhQ== Received: from DM6PR02CA0098.namprd02.prod.outlook.com (2603:10b6:5:1f4::39) by MW4PR12MB7189.namprd12.prod.outlook.com (2603:10b6:303:224::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.24; Mon, 12 Feb 2024 21:16:11 +0000 Received: from SA2PEPF000015CD.namprd03.prod.outlook.com (2603:10b6:5:1f4:cafe::25) by DM6PR02CA0098.outlook.office365.com (2603:10b6:5:1f4::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.39 via Frontend Transport; Mon, 12 Feb 2024 21:16:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF000015CD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Mon, 12 Feb 2024 21:16:11 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 12 Feb 2024 13:15:53 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 12 Feb 2024 13:15:53 -0800 Received: from ttabi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Mon, 12 Feb 2024 13:15:52 -0800 From: Timur Tabi To: Dave Airlie , Lyude Paul , "Danilo Krummrich" , , Subject: [PATCH 1/2] [v3] nouveau: add command-line GSP-RM registry support Date: Mon, 12 Feb 2024 15:15:47 -0600 Message-ID: <20240212211548.1094496-2-ttabi@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240212211548.1094496-1-ttabi@nvidia.com> References: <20240212211548.1094496-1-ttabi@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CD:EE_|MW4PR12MB7189:EE_ X-MS-Office365-Filtering-Correlation-Id: c5ac3e00-46fc-49d9-58c2-08dc2c0fd699 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XzGu5OhMb8EJKbpmSCxdD4rSRMVWY5vItZqJeFBKL0K5NU6Rw9bE0xjcwnkqXQbvyWtN5lx2duuxLyp5O7jdRZRRr96rubaE491adQkyJs0p78qdcjTQEhRW+XGaVB6m3KCOe2BJU0pi9zzuucbFGzPd5idh4VnT8f7Kt/wO+dEZ803RPCYpBk2+ySQtTHxcikafisa1rov2ESgNw6S/Z2oW3vNR1lksMEAM4gOY3QnYq5teeMva+CImnHmCpwJodeTslHwDPhn+UyvcTBMQRV91pQStkLJ4IE11Wkj+Zet3Xi5R8MYdLMe/qLlQwFD/9OQrkMWvV2KkZZ9vIg1zXIF4IqCI1DEIzUjvyLmmgMhG8hgv5zE9ZGgwftte8GCYOUsqGJ5gDgV1OLNCMdca+8peyU0SCKsUp9fVyIoaOayLSP0gwMupmd/M38InT/nM+ywkVWlTADh8Nb4yfXv11fc7G/MToLkV32zVp/Hb2sRJpmP06WMq3erg/jtEaC8nGr8lbh9pLIxDu5wtx83AgUvqOxcq4VPf5tUki4ZaAp8ZKrRHlA+ScCX4vmiKjTCJJyi+P9T/W8ZMOjbbc04TLK9dgBLKyKuljnWBIq52AT4= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(136003)(39860400002)(396003)(376002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(82310400011)(36840700001)(46966006)(40470700004)(86362001)(70206006)(5660300002)(30864003)(70586007)(8676002)(8936002)(7696005)(2906002)(478600001)(336012)(7636003)(26005)(82740400003)(356005)(83380400001)(41300700001)(1076003)(2616005)(426003)(316002)(6666004)(36756003)(110136005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2024 21:16:11.4710 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5ac3e00-46fc-49d9-58c2-08dc2c0fd699 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015CD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7189 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add the NVreg_RegistryDwords command line parameter, which allows specifying additional registry keys to be sent to GSP-RM. This allows additional configuration, debugging, and experimentation with GSP-RM, which uses these keys to alter its behavior. Note that these keys are passed as-is to GSP-RM, and Nouveau does not parse them. This is in contrast to the Nvidia driver, which may parse some of the keys to configure some functionality in concert with GSP-RM. Therefore, any keys which also require action by the driver may not function correctly when passed by Nouveau. Caveat emptor. The name and format of NVreg_RegistryDwords is the same as used by the Nvidia driver, to maintain compatibility. Signed-off-by: Timur Tabi --- v3: rebased to drm-next .../gpu/drm/nouveau/include/nvkm/subdev/gsp.h | 6 + .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 279 ++++++++++++++++-- 2 files changed, 261 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h index 6f5d376d8fcc..3fbc57b16a05 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h @@ -211,6 +211,12 @@ struct nvkm_gsp { struct mutex mutex;; struct idr idr; } client_id; + + /* A linked list of registry items. The registry RPC will be built from it. */ + struct list_head registry_list; + + /* The size of the registry RPC */ + size_t registry_rpc_size; }; static inline bool diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c index 1c46e3f919be..86b62c7e1229 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c @@ -54,6 +54,8 @@ #include #include +#include +#include #define GSP_MSG_MIN_SIZE GSP_PAGE_SIZE #define GSP_MSG_MAX_SIZE GSP_PAGE_MIN_SIZE * 16 @@ -1082,51 +1084,280 @@ r535_gsp_rpc_unloading_guest_driver(struct nvkm_gsp *gsp, bool suspend) return nvkm_gsp_rpc_wr(gsp, rpc, true); } +struct registry_list_entry { + struct list_head list; + size_t name_len; + u32 type; + u32 data; + u32 length; + char name[]; +}; + +/** + * add_registry -- adds a registry entry + * @gsp: gsp pointer + * @name: name of the registry key + * @type: type of data (1 = integer) + * @data: value + * @length: size of data, in bytes + * + * Adds a registry key/value pair to the registry database. + * + * Currently, only 32-bit integers (type == 1, length == 4) are supported. + * + * This function collects the registry information in a linked list. After + * all registry keys have been added, build_registry() is used to create the + * RPC data structure. + * + * registry_rpc_size is a running total of the size of all registry keys. + * It's used to avoid an O(n) calculation of the size when the RPC is built. + * + * Returns 0 on success, or negative error code on error. + */ +static int add_registry(struct nvkm_gsp *gsp, const char *name, u32 type, u32 data, u32 length) +{ + struct registry_list_entry *reg; + size_t nlen = strlen(name) + 1; + + /* Set an arbitrary limit to avoid problems with broken command lines */ + if (strlen(name) > 64) + return -EFBIG; + + reg = kmalloc(sizeof(struct registry_list_entry) + nlen, GFP_KERNEL); + if (!reg) + return -ENOMEM; + + memcpy(reg->name, name, nlen); + reg->name_len = nlen; + reg->type = type; + reg->data = data; + reg->length = length; + + nvkm_debug(&gsp->subdev, "adding GSP-RM registry '%s=%u'\n", name, data); + list_add_tail(®->list, &gsp->registry_list); + gsp->registry_rpc_size += sizeof(PACKED_REGISTRY_ENTRY) + nlen; + + return 0; +} + +static int add_registry_num(struct nvkm_gsp *gsp, const char *name, u32 value) +{ + return add_registry(gsp, name, 1, value, sizeof(u32)); +} + +/** + * build_registry -- create the registry RPC data + * @gsp: gsp pointer + * @registry: pointer to the RPC payload to fill + * + * After all registry key/value pairs have been added, call this function to + * build the RPC. + * + * The registry RPC looks like this: + * + * +-----------------+ + * |NvU32 size; | + * |NvU32 numEntries;| + * +-----------------+ + * +---------------------+ + * |PACKED_REGISTRY_ENTRY| + * +---------------------+ + * |PACKED_REGISTRY_ENTRY| + * +---------------------+ + * ... (one copy for each entry) + * + * +----------------------------------+ + * |Null-terminated string for entry 0| + * +----------------------------------+ + * |Null-terminated string for entry 1| + * +----------------------------------+ + * ... (one copy for each entry) + * + * All memory allocated by add_registry() is released. + */ +static void build_registry(struct nvkm_gsp *gsp, PACKED_REGISTRY_TABLE *registry) +{ + struct registry_list_entry *reg, *n; + size_t str_offset; + unsigned int i = 0; + + registry->numEntries = list_count_nodes(&gsp->registry_list); + str_offset = struct_size(registry, entries, registry->numEntries); + + list_for_each_entry_safe(reg, n, &gsp->registry_list, list) { + registry->entries[i].type = reg->type; + registry->entries[i].data = reg->data; + registry->entries[i].length = reg->length; + registry->entries[i].nameOffset = str_offset; + memcpy((void *)registry + str_offset, reg->name, reg->name_len); + str_offset += reg->name_len; + i++; + + list_del(®->list); + kfree(reg); + } + + /* Double-check that we calculated the sizes correctly */ + WARN_ON(gsp->registry_rpc_size != str_offset); + + registry->size = gsp->registry_rpc_size; +} + +/** + * clean_registry -- clean up registry memory in case of error + * @gsp: gsp pointer + * + * Call this function to clean up all memory allocated by add_registry() + * in case of error and build_registry() is not called. + */ +static void clean_registry(struct nvkm_gsp *gsp) +{ + struct registry_list_entry *reg, *n; + + list_for_each_entry_safe(reg, n, &gsp->registry_list, list) { + list_del(®->list); + kfree(reg); + } + + gsp->registry_rpc_size = sizeof(PACKED_REGISTRY_TABLE); +} + +MODULE_PARM_DESC(NVreg_RegistryDwords, + "A semicolon-separated list of key=integer pairs of GSP-RM registry keys"); +static char *NVreg_RegistryDwords; +module_param(NVreg_RegistryDwords, charp, 0400); + /* dword only */ struct nv_gsp_registry_entries { const char *name; u32 value; }; +/** + * r535_registry_entries - required registry entries for GSP-RM + * + * This array lists registry entries that are required for GSP-RM to + * function correctly. + * + * RMSecBusResetEnable - enables PCI secondary bus reset + * RMForcePcieConfigSave - forces GSP-RM to preserve PCI configuration + * registers on any PCI reset. + */ static const struct nv_gsp_registry_entries r535_registry_entries[] = { { "RMSecBusResetEnable", 1 }, { "RMForcePcieConfigSave", 1 }, }; #define NV_GSP_REG_NUM_ENTRIES ARRAY_SIZE(r535_registry_entries) +/** + * strip - strips all characters in 'reject' from 's' + * @s: string to strip + * @reject: string of characters to remove + * + * 's' is modified. + * + * Returns the length of the new string. + */ +static size_t strip(char *s, const char *reject) +{ + char *p = s, *p2 = s; + size_t length = 0; + char c; + + do { + while ((c = *p2) && strchr(reject, c)) + p2++; + + *p++ = c = *p2++; + length++; + } while (c); + + return length; +} + +/** + * r535_gsp_rpc_set_registry - build registry RPC and call GSP-RM + * @gsp: gsp pointer + * + * The GSP-RM registry is a set of key/value pairs that configure some aspects + * of GSP-RM. The keys are strings, and the values are 32-bit integers. + * + * The registry is built from a combination of a static hard-coded list (see + * above) and entries passed on the driver's command line. + */ static int r535_gsp_rpc_set_registry(struct nvkm_gsp *gsp) { PACKED_REGISTRY_TABLE *rpc; - char *strings; - int str_offset; - int i; - size_t rpc_size = struct_size(rpc, entries, NV_GSP_REG_NUM_ENTRIES); + unsigned int i; + int ret; - /* add strings + null terminator */ - for (i = 0; i < NV_GSP_REG_NUM_ENTRIES; i++) - rpc_size += strlen(r535_registry_entries[i].name) + 1; + INIT_LIST_HEAD(&gsp->registry_list); + gsp->registry_rpc_size = sizeof(PACKED_REGISTRY_TABLE); - rpc = nvkm_gsp_rpc_get(gsp, NV_VGPU_MSG_FUNCTION_SET_REGISTRY, rpc_size); - if (IS_ERR(rpc)) - return PTR_ERR(rpc); + /* Add the required registry entries first */ + for (i = 0; i < NV_GSP_REG_NUM_ENTRIES; i++) { + ret = add_registry_num(gsp, r535_registry_entries[i].name, + r535_registry_entries[i].value); + if (ret) { + clean_registry(gsp); + return ret; + } + } + + /* + * The NVreg_RegistryDwords parameter is a string of key=value + * pairs separated by semicolons. We need to extract and trim each + * substring, and then parse the substring to extract the key and + * value. + */ + if (NVreg_RegistryDwords) { + char *p = kstrdup(NVreg_RegistryDwords, GFP_KERNEL); + char *start, *next = p, *equal; + size_t length; + + /* Remove any whitespace from the parameter string */ + length = strip(p, " \t\n"); + + while ((start = strsep(&next, ";"))) { + long value; + + equal = strchr(start, '='); + if (!equal || (equal == start) || !isdigit(equal[1])) { + nvkm_error(&gsp->subdev, + "ignoring invalid registry string '%s'\n", start); + continue; + } - rpc->numEntries = NV_GSP_REG_NUM_ENTRIES; + ret = kstrtol(equal + 1, 0, &value); + if (ret) { + nvkm_error(&gsp->subdev, + "ignoring invalid registry value in '%s'\n", start); + continue; + } - str_offset = offsetof(typeof(*rpc), entries[NV_GSP_REG_NUM_ENTRIES]); - strings = (char *)&rpc->entries[NV_GSP_REG_NUM_ENTRIES]; - for (i = 0; i < NV_GSP_REG_NUM_ENTRIES; i++) { - int name_len = strlen(r535_registry_entries[i].name) + 1; - - rpc->entries[i].nameOffset = str_offset; - rpc->entries[i].type = 1; - rpc->entries[i].data = r535_registry_entries[i].value; - rpc->entries[i].length = 4; - memcpy(strings, r535_registry_entries[i].name, name_len); - strings += name_len; - str_offset += name_len; + /* Truncate the key=value string to just key */ + *equal = 0; + + ret = add_registry_num(gsp, start, value); + if (ret) { + nvkm_error(&gsp->subdev, + "ignoring invalid registry key/value '%s=%lu'\n", + start, value); + continue; + } + } + + kfree(p); } - rpc->size = str_offset; + + rpc = nvkm_gsp_rpc_get(gsp, NV_VGPU_MSG_FUNCTION_SET_REGISTRY, gsp->registry_rpc_size); + if (IS_ERR(rpc)) { + clean_registry(gsp); + return PTR_ERR(rpc); + } + + build_registry(gsp, rpc); return nvkm_gsp_rpc_wr(gsp, rpc, false); } From patchwork Mon Feb 12 21:15:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 13553991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F1F22C4829E for ; Mon, 12 Feb 2024 21:16:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF44E10E2D5; Mon, 12 Feb 2024 21:16:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="QrzKp8j+"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2081.outbound.protection.outlook.com [40.107.94.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8DAF210E2D5; Mon, 12 Feb 2024 21:16:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h/RsIhq0xyj+X2iSlzFN3Ya3rzx7Aooab94Q8happTGwW6Ar78v/iWEzb1VW/+reGdRiR17Zlrt+aUXp3onkUK16AtfPBbN6vrp4qP7hZ6VOdnUvn6M3GkUhvAY6A6Z31iuzQd7f0EfcTRfqrkE4nstFNM3Oa8KOwDtDdxpiYP/uRV1ymZtMfkyK5IhLrV5qXMl/P948kkPvuTbJGsHz5DZbk+e2R3kCbI5riBWQsryMX9r8FeaHgDEbpbxQ1iPTAAWK13+Mga5/TRxo1akCDi8pSctCNhDonQobUVlE/SRvrWIHPI99zaC2ZFHI5p7fm1WV9nyyR66xJfzoleIxUg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5HMVINJIFZxsk8w+gQacoD1pTxiK4mrj+tEVKeJ3W5A=; b=UiwnPoT8npwJPEiYmsTIxoYdD8h2GVtNLcVLYQVGXGNSTzxc+GMXppkQb9BMARnzY6wLKuTqeTaF5MqizHcmYAxi7jgLVBn7rS9rpswiNpJUsGLsKtknBvg5kA7hWiYyQSyG9VSj1nG1WmqJAC6lfIwmjvwcn8UUEx1O614QPpt8JsjGlC2ZCJmXvDsS4PDraCw+ROErFllKFCpgujkO9J/Tu70FEg8hC6cv7R49b4iyL134LHpTnXooP2qdscR0k1ZlHF+L+90ZXaBGzP0bpm/syiCUy6pkl+vGx8FOLrOnm58yFIkPbTQ0Nw1d/cXqVMgeH8LfoidzAQNB4+u0Iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5HMVINJIFZxsk8w+gQacoD1pTxiK4mrj+tEVKeJ3W5A=; b=QrzKp8j+c0jNWXESwtl8W714r6l5WdpeinuDbWQ9Hn5yufsfpMbZMR0FvLti5ekxDXM1A9i7yXdNSjL0yLiX27ihmprc3ctD1EzYsA8OBjmTwM7VaV2V6wAOJhQDnBhKL+Ef4SyW359prdHVbxEmLBuOldFeukRFAl2TlKW/Y4RiYWA1JsbWgS3jH53hagWyhKCHuSVUnNWJWbtzcrcInHFUhtEDF62NSlbA8sOM9ytv85lCblE5Gydw1/7tLeYfdUzgl0WVrwy4LRfRBpLqPig3bsjb+kK16vvasLLyxPGMh6r67FCQ7IkqtTWbVt8idG15oyQ5AuEIfk9gBXabNQ== Received: from PH8PR07CA0010.namprd07.prod.outlook.com (2603:10b6:510:2cd::22) by MW4PR12MB7167.namprd12.prod.outlook.com (2603:10b6:303:225::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.11; Mon, 12 Feb 2024 21:16:08 +0000 Received: from SN1PEPF000252A2.namprd05.prod.outlook.com (2603:10b6:510:2cd:cafe::c) by PH8PR07CA0010.outlook.office365.com (2603:10b6:510:2cd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.39 via Frontend Transport; Mon, 12 Feb 2024 21:16:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SN1PEPF000252A2.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Mon, 12 Feb 2024 21:16:08 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 12 Feb 2024 13:15:54 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 12 Feb 2024 13:15:54 -0800 Received: from ttabi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Mon, 12 Feb 2024 13:15:53 -0800 From: Timur Tabi To: Dave Airlie , Lyude Paul , "Danilo Krummrich" , , Subject: [PATCH 2/2] [v3] drm/nouveau: expose GSP-RM logging buffers via debugfs Date: Mon, 12 Feb 2024 15:15:48 -0600 Message-ID: <20240212211548.1094496-3-ttabi@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240212211548.1094496-1-ttabi@nvidia.com> References: <20240212211548.1094496-1-ttabi@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A2:EE_|MW4PR12MB7167:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fc93b89-a127-41c2-780e-08dc2c0fd4bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4/B96MhVlmwnWH1MrAf8woUY3E8oG0rCF0TLEmrTkGcVpBw77xxLIpWcdTnq38XAlJ2PdIeTixPJ2nRDKBpaPgcCtxETX4jtWuYUbuT1OOL1Qxk1L+YJq2UZbiSH4aaPdeprWRgEgZ+nTOnoMkvLVQ9Y7dNpnMfbLT5kavXOuTNcEpPZglPDjJSiaATNtbLxc2K2D1rlWyb/M6QS7Atl1hBVSG1B9WVHRI49BNoUjKUaRb9cIYA5R4rCn/1fW/vNsDoRcCvIfYnjvBI5zVrXqbMvmqcQ+Om0cnxqZySzaf1Q1lZAtAwsXFTB3Mmq7tVNZcfYLWFBD6vs6/1j+la5cXELreq1I2Ezbyj7QW2f55Y/Oy6P06xsnF4HUSt/Bc6aWJTPOerc+cZMmCrj497pqtuZ2mv4C4WVc0K0JE+tJWcVET/GVnQ6SuCtN6i/DnEjG7hGJ10SoEYIIpqWA5EXivjdxINqf0hnVC8yhU0ZKjOQ078s0HhAnc5Bowj6qBp/oU5YYR0USXWJiyXamDwDJJ2xIlwpf7y0AD9JE2WbecbHuEhKMYFsddLWfDspLkjpDFMydK2MWmK6eWwy3T+53PAWw4ZT3hV0aG+uKFAgTNg= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(39860400002)(376002)(346002)(396003)(230273577357003)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799012)(40470700004)(46966006)(36840700001)(41300700001)(66899024)(7636003)(30864003)(2906002)(356005)(5660300002)(426003)(8936002)(70206006)(8676002)(316002)(2616005)(70586007)(110136005)(82740400003)(86362001)(83380400001)(478600001)(26005)(1076003)(336012)(6666004)(7696005)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2024 21:16:08.3679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fc93b89-a127-41c2-780e-08dc2c0fd4bd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000252A2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7167 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The LOGINIT, LOGINTR, LOGRM, and LOGPMU buffers are circular buffers that have printf-like logs from GSP-RM and PMU encoded in them. LOGINIT, LOGINTR, and LOGRM are allocated by Nouveau and their DMA addresses are passed to GSP-RM during initialization. The buffers are required for GSP-RM to initialize properly. LOGPMU is also allocated by Nouveau, but its contents are updated when Nouveau receives an NV_VGPU_MSG_EVENT_UCODE_LIBOS_PRINT RPC from GSP-RM. Nouveau then copies the RPC to the buffer. The messages are encoded as an array of variable-length structures that contain the parameters to an NV_PRINTF call. The format string and parameter count are stored in a special ELF image that contains only logging strings. This image is not currently shipped with the Nvidia driver. There are two methods to extract the logs. OpenRM tries to load the logging ELF, and if present, parses the log buffers in real time and outputs the strings to the kernel console. Alternatively, and this is the method used by this patch, the buffers can be exposed to user space, and a user-space tool (along with the logging ELF image) can parse the buffer and dump the logs. This method has the advantage that it allows the buffers to be parsed even when the logging ELF file is not available to the user. However, it has the disadvantage the debubfs entries need to remain until the driver is unloaded. The buffers are exposed via debugfs. The debugfs entries must be created before GSP-RM is started, to ensure that they are available during GSP-RM initialization. If GSP-RM fails to initialize, then Nouveau immediately shuts down the GSP interface. This would normally also deallocate the logging buffers, thereby preventing the user from capturing the debug logs. To avoid this, the keep-gsp-logging command line parameter can be specified. This parmater is marked as *unsafe* (thereby taining the kernel) because the DMA buffer and debugfs entries are never deallocated, even if the driver unloads. This gives the user the time to capture the logs, but it also means that resources can only be recovered by a reboot. An end-user can capture the logs using the following commands: cp /sys/kernel/debug/dri//loginit loginit cp /sys/kernel/debug/dri//logrm logrm cp /sys/kernel/debug/dri//logintr logintr cp /sys/kernel/debug/dri//logpmu logpmu where is the PCI ID of the GPU (e.g. 0000:65:00.0). If keep-gsp-logging is specified, then the is the same but with -debug appended (e.g. 0000:65:00.0-debug). Since LOGPMU is not needed for normal GSP-RM operation, it is only created if debugfs is available. Otherwise, the NV_VGPU_MSG_EVENT_UCODE_LIBOS_PRINT RPCs are ignored. Signed-off-by: Timur Tabi --- v3: reworked r535_gsp_libos_debugfs_init, rebased for drm-next .../gpu/drm/nouveau/include/nvkm/subdev/gsp.h | 12 + .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 215 +++++++++++++++++- 2 files changed, 223 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h index 3fbc57b16a05..2ee44bdf8be7 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h @@ -5,6 +5,8 @@ #include #include +#include + #define GSP_PAGE_SHIFT 12 #define GSP_PAGE_SIZE BIT(GSP_PAGE_SHIFT) @@ -217,6 +219,16 @@ struct nvkm_gsp { /* The size of the registry RPC */ size_t registry_rpc_size; + + /* + * Logging buffers in debugfs. The wrapper objects need to remain + * in memory until the dentry is deleted. + */ + struct debugfs_blob_wrapper blob_init; + struct debugfs_blob_wrapper blob_intr; + struct debugfs_blob_wrapper blob_rm; + struct debugfs_blob_wrapper blob_pmu; + struct dentry *debugfs_logging_dir; }; static inline bool diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c index 86b62c7e1229..56209bf81360 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -1979,6 +1980,196 @@ r535_gsp_rmargs_init(struct nvkm_gsp *gsp, bool resume) return 0; } +#define NV_GSP_MSG_EVENT_UCODE_LIBOS_CLASS_PMU 0xf3d722 + +/** + * r535_gsp_msg_libos_print - capture log message from the PMU + * @priv: gsp pointer + * @fn: function number (ignored) + * @repv: pointer to libos print RPC + * @repc: message size + * + * See _kgspRpcUcodeLibosPrint + */ +static int r535_gsp_msg_libos_print(void *priv, u32 fn, void *repv, u32 repc) +{ + struct nvkm_gsp *gsp = priv; + struct nvkm_subdev *subdev = &gsp->subdev; + struct { + u32 ucodeEngDesc; + u32 libosPrintBufSize; + u8 libosPrintBuf[]; + } *rpc = repv; + unsigned int class = rpc->ucodeEngDesc >> 8; + + nvkm_debug(subdev, "received libos print from class 0x%x for %u bytes\n", + class, rpc->libosPrintBufSize); + + if (class != NV_GSP_MSG_EVENT_UCODE_LIBOS_CLASS_PMU) { + nvkm_warn(subdev, + "received libos print from unknown class 0x%x\n", + class); + return -ENOMSG; + } + if (rpc->libosPrintBufSize > GSP_PAGE_SIZE) { + nvkm_error(subdev, "libos print is too large (%u bytes)\n", + rpc->libosPrintBufSize); + return -E2BIG; + + } + memcpy(gsp->blob_pmu.data, rpc->libosPrintBuf, rpc->libosPrintBufSize); + + return 0; +} + +/* + * If GSP-RM load fails, then the GSP nvkm object will be deleted, the + * logging debugfs entries will be deleted, and it will not be possible to + * debug the load failure. The keep_gsp_logging parameter tells Nouveau + * not to free these resources, even if the driver is unloading. In this + * case, the only recovery is a reboot. + */ +static bool keep_gsp_logging; +module_param_unsafe(keep_gsp_logging, bool, 0444); +MODULE_PARM_DESC(keep_gsp_logging, + "Do not remove the GSP-RM logging debugfs entries upon exit"); + +/** + * r535_gsp_libos_debugfs_init - create logging debugfs entries + * @gsp: gsp pointer + * + * Create the debugfs entries. This exposes the log buffers to + * userspace so that an external tool can parse it. + * + * The 'logpmu' contains exception dumps from the PMU. It is written via an + * RPC sent from GSP-RM and must be only 4KB. We create it here because it's + * only useful if there is a debugfs entry to expose it. If we get the PMU + * logging RPC and there is no debugfs entry, the RPC is just ignored. + * + * The blob_init, blob_rm, and blob_pmu objects can't be transient + * because debugfs_create_blob doesn't copy them. + * + * NOTE: OpenRM loads the logging elf image and prints the log messages + * in real-time. We may add that capability in the future, but that + * requires loading an ELF images that are not distributed with the driver, + * and adding the parsing code to Nouveau. + * + * Ideally, this should be part of nouveau_debugfs_init(), but that function + * is called too late. We really want to create these debugfs entries before + * r535_gsp_booter_load() is called, so that if GSP-RM fails to initialize, + * there could still be a log to capture. + * + * If the unsafe command line pararameter 'keep-gsp-logging' is specified, + * then the logging buffer and debugfs entries will be retained when the + * driver shuts down. This is necessary to debug initialization failures, + * because otherwise the buffers will disappear before the logs can be + * captured. + */ +static void r535_gsp_libos_debugfs_init(struct nvkm_gsp *gsp) +{ + struct dentry *dir_init, *dir_intr, *dir_rm, *dir_pmu; + struct dentry *root, *dir; + struct device *dev = gsp->subdev.device->dev; + + /* + * Under normal circumstances, we add our debugfs entries to the dentry + * created by the DRM layer when the driver registered. However, this + * dentry and everything in it is deleted if GSP fails to initialize. + * + * If keep-gsp-logging is specified, then a different top-entry dentry + * is created and that is used. This dentry is never deleted, even if + * the driver exits. + */ + if (keep_gsp_logging) { + char temp[64]; + + /* Find the 'dri' root debugfs entry. Every GPU has a dentry under it */ + root = debugfs_lookup("dri", NULL); + if (IS_ERR(root)) { + /* No debugfs, or no root dentry for DRM */ + return; + } + + scnprintf(temp, sizeof(temp), "%s-debug", dev_name(dev)); + dir = debugfs_create_dir(temp, root); + dput(root); + if (IS_ERR(dir)) { + nvkm_error(&gsp->subdev, + "failed to create %s debugfs entry\n", temp); + return; + } + + gsp->debugfs_logging_dir = dir; + } else { + /* Each GPU has a subdir based on its device name, so find it */ + struct drm_device *drm_dev = dev_get_drvdata(dev); + + if (!drm_dev || !drm_dev->debugfs_root) { + nvkm_error(&gsp->subdev, "could not find debugfs path\n"); + return; + } + + dir = drm_dev->debugfs_root; + } + + gsp->blob_init.data = gsp->loginit.data; + gsp->blob_init.size = gsp->loginit.size; + gsp->blob_intr.data = gsp->logintr.data; + gsp->blob_intr.size = gsp->logintr.size; + gsp->blob_rm.data = gsp->logrm.data; + gsp->blob_rm.size = gsp->logrm.size; + + /* + * Since the PMU buffer is copied from an RPC, it doesn't need to be + * a DMA buffer. + */ + gsp->blob_pmu.size = GSP_PAGE_SIZE; + gsp->blob_pmu.data = kzalloc(gsp->blob_pmu.size, GFP_KERNEL); + if (!gsp->blob_pmu.data) + goto error; + + dir_init = debugfs_create_blob("loginit", 0444, dir, &gsp->blob_init); + if (IS_ERR(dir_init)) { + nvkm_error(&gsp->subdev, "failed to create loginit debugfs entry\n"); + goto error; + } + + dir_intr = debugfs_create_blob("logintr", 0444, dir, &gsp->blob_intr); + if (IS_ERR(dir_intr)) { + nvkm_error(&gsp->subdev, "failed to create logintr debugfs entry\n"); + goto error; + } + + dir_rm = debugfs_create_blob("logrm", 0444, dir, &gsp->blob_rm); + if (IS_ERR(dir_rm)) { + nvkm_error(&gsp->subdev, "failed to create logrm debugfs entry\n"); + goto error; + } + + dir_pmu = debugfs_create_blob("logpmu", 0444, dir, &gsp->blob_pmu); + if (IS_ERR(dir_pmu)) { + nvkm_error(&gsp->subdev, "failed to create logpmu debugfs entry\n"); + goto error; + } + + i_size_write(d_inode(dir_init), gsp->blob_init.size); + i_size_write(d_inode(dir_intr), gsp->blob_intr.size); + i_size_write(d_inode(dir_rm), gsp->blob_rm.size); + i_size_write(d_inode(dir_pmu), gsp->blob_pmu.size); + + r535_gsp_msg_ntfy_add(gsp, 0x0000100C, r535_gsp_msg_libos_print, gsp); + + nvkm_debug(&gsp->subdev, "created debugfs GSP-RM logging entries\n"); + return; + +error: + debugfs_remove(gsp->debugfs_logging_dir); + gsp->debugfs_logging_dir = NULL; + + kfree(gsp->blob_pmu.data); + gsp->blob_pmu.data = NULL; +} + static inline u64 r535_gsp_libos_id8(const char *name) { @@ -2029,7 +2220,11 @@ static void create_pte_array(u64 *ptes, dma_addr_t addr, size_t size) * written to directly by GSP-RM and can be any multiple of GSP_PAGE_SIZE. * * The physical address map for the log buffer is stored in the buffer - * itself, starting with offset 1. Offset 0 contains the "put" pointer. + * itself, starting with offset 1. Offset 0 contains the "put" pointer (pp). + * Initially, pp is equal to 0. If the buffer has valid logging data in it, + * then pp points to index into the buffer where the next logging entry will + * be written. Therefore, the logging data is valid if: + * 1 <= pp < sizeof(buffer)/sizeof(u64) * * The GSP only understands 4K pages (GSP_PAGE_SIZE), so even if the kernel is * configured for a larger page size (e.g. 64K pages), we need to give @@ -2100,6 +2295,9 @@ r535_gsp_libos_init(struct nvkm_gsp *gsp) args[3].size = gsp->rmargs.size; args[3].kind = LIBOS_MEMORY_REGION_CONTIGUOUS; args[3].loc = LIBOS_MEMORY_REGION_LOC_SYSMEM; + + r535_gsp_libos_debugfs_init(gsp); + return 0; } @@ -2404,9 +2602,18 @@ r535_gsp_dtor(struct nvkm_gsp *gsp) r535_gsp_dtor_fws(gsp); nvkm_gsp_mem_dtor(gsp, &gsp->shm.mem); - nvkm_gsp_mem_dtor(gsp, &gsp->loginit); - nvkm_gsp_mem_dtor(gsp, &gsp->logintr); - nvkm_gsp_mem_dtor(gsp, &gsp->logrm); + + if (keep_gsp_logging && gsp->debugfs_logging_dir) + nvkm_warn(&gsp->subdev, + "GSP-RM logging buffers retained, reboot required to recover\n"); + else { + kfree(gsp->blob_pmu.data); + gsp->blob_pmu.data = NULL; + + nvkm_gsp_mem_dtor(gsp, &gsp->loginit); + nvkm_gsp_mem_dtor(gsp, &gsp->logintr); + nvkm_gsp_mem_dtor(gsp, &gsp->logrm); + } } int