Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2170626rbb; Tue, 27 Feb 2024 13:00:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU7o/FTwTUnzyJW/JCMOZbjDHM26GMFR6hKj25uirN8vqydTH4odeXqX3cm2s9ulNGHrhskrzMi+he5RGltPL7AGpjOKiR8+Irlx1esAw== X-Google-Smtp-Source: AGHT+IHNGFUqzpQmFjfmIAK0M8mm6rS9eHkY3tevVGcmY2iYOqIMXSKP6wyh8w1QgPmpLvNbiaX9 X-Received: by 2002:aa7:c6d2:0:b0:566:f3d:c0b6 with SMTP id b18-20020aa7c6d2000000b005660f3dc0b6mr3652117eds.8.1709067629704; Tue, 27 Feb 2024 13:00:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709067629; cv=pass; d=google.com; s=arc-20160816; b=ej8rlt/IWEHnsT05Zg6INDfQEo2G959YhQ3ng2g3Lj2p88GrenAQivJiK/Llgczp1L 98omlV8aWWyQErC187RnFZ5BLr2MmNgHIJfJkIje1pPqfPj8xI/zt8RrJmjIIbCgGhli C3QHaEt0PKpB5/SWdkukt70xFV13+bT08N9lbYcm4DGJJcey+p150rFXsxSZZk/FHTgT viH/PXmhqudZ6pfNLBAHxKV3d1mkNOSXDsBhSeytoe1jO9KdmJU3Q2LJrZwUAFXxgDyy 1ZXAh0kB+mFFOnxWbGGMXVSVd0e3hI0VlZNG7E3fwrJrd9JPhgv15Z/Vlsx9Rkk06CDc 3EbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=HBGsraC8xcfuBlVVXonM0asONE2oxZ0KqbeSqC/uLK4=; fh=/aA3ikCzdHUoND1NkELyjjOlZC31bXhfya5LgPc2Wj8=; b=H1yoV/0JQP+Ugac21BAnIrh5gIN4+Znbc4y/n3ur8Q+JCyb3gnvTASo0SwewYLrAsL vv4bviBBTHChWSCmrkVcCSfOZ39npCo0koCl5EbzNS0A7Bp5QECebSxuZsOwYTDoXVb9 kfPxVgPCaYYzKjRs+v0PNP4Z7XHBaQQx4DbiZ1KAg9xss6d11QBBr0lr2UBTElsCtvHJ Uf+ded4oCh6iib+t2fw2dAypz/SvPFZUxXrKNecc5JH9vOTGvbRrxpJpKQumVpA4Wvj3 mLtBQYub5MAhpbTvnxmPkg9dUxefJIkMId6gMUoztSet9qvjWO/mSNMkOi5XpRzb2/GX H9Qg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nhxqhSbD; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v27-20020a056402175b00b0056459db4071si958816edx.620.2024.02.27.13.00.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 13:00:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nhxqhSbD; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 741151F2414E for ; Tue, 27 Feb 2024 21:00:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1348814EFD4; Tue, 27 Feb 2024 21:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nhxqhSbD" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBE3513AA36 for ; Tue, 27 Feb 2024 21:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067620; cv=none; b=rQkU8Yj/21RogQ6xWqD9ZjfLMIHYmj7nVMiW4FpvrrYsj7xL+WvWNj+a6J4nKRXnBNqWmnSM1Gbk2OWsWIK6mkgV3B/tmnz8TXLJ4Hfpl1giQJ/STLcMMEJGpF+Njqa2Ekggf/LPQt3Ou+9qbJl7D0EsfunhvMXdYEZDJc9GBgE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067620; c=relaxed/simple; bh=RE/r0QBlJkpfsDcdAyyvBwd5gHrITMQLec9sLSeOxDo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Ta5SXgPrniOfUXMze+a5DXyQCUB8IhV3Yyzry6AhtO2VmejP0ap2FTfS/QSyvFfpShOsEhlSbVn1JmIBgCjgVi1EBOxkWwUCo0DfAY5e91dbqsD8NOQ9H3lzO9RcXb2ht1dlQBbBuYomDLbaZVooJF1iwHZjL/kCantKbqlKW8g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nhxqhSbD; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709067618; x=1740603618; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RE/r0QBlJkpfsDcdAyyvBwd5gHrITMQLec9sLSeOxDo=; b=nhxqhSbDiBp972rNAyv08Ln4t9PLnmkQgDaICHyWe3Tuye5TMSmUjS1o 6Qxr5l0faIRc18FVnVTWur+nxzsBnbXzDoOKjDZzxUvXtqo39WCg9J9GF 7TL8h2Hu5YeXD+gPErhybN/mJIsR25tXhEkz+PHrtT+bDN3JAC7p25LXi vKjXtzq+NIRshzUGUQ5NWzy5rkamGpxId/WOU1p9Vy9lS8KN+jCnE6727 20ziw6YPpQGb6BmA9sE4Dvda466O/rl3RYRe0VeeuQrsiQlpI8t8PJ8gN AUS1ttYSdneEiCeONHDRZvuKnnN8W3cZvDtIhLk8w0so9/u6aMoqCNETc w==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14858440" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="14858440" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 13:00:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="7150405" Received: from josouza-mobl2.bz.intel.com ([10.87.243.88]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 13:00:14 -0800 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= To: linux-kernel@vger.kernel.org, intel-xe@lists.freedesktop.org Cc: Rodrigo Vivi , Mukesh Ojha , Johannes Berg , Jonathan Cavitt , =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Subject: [PATCH 1/4] devcoredump: Add dev_coredump_put() Date: Tue, 27 Feb 2024 13:00:05 -0800 Message-ID: <20240227210008.182904-1-jose.souza@intel.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is useful for drivers that don't want to keep a coredump available after unloading. Otherwise, the coredump would only be removed after DEVCD_TIMEOUT seconds. Cc: Rodrigo Vivi Cc: Mukesh Ojha Cc: Johannes Berg Cc: Jonathan Cavitt Signed-off-by: José Roberto de Souza --- drivers/base/devcoredump.c | 22 ++++++++++++++++++++++ include/linux/devcoredump.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c index 7e2d1f0d903a6..e96427411b87c 100644 --- a/drivers/base/devcoredump.c +++ b/drivers/base/devcoredump.c @@ -304,6 +304,28 @@ static ssize_t devcd_read_from_sgtable(char *buffer, loff_t offset, offset); } +/** + * dev_coredump_put - remove device coredump + * @dev: the struct device for the crashed device + * + * If giving device has a coredump this removes it from file system and free + * associated data otherwise does nothing. + * This is useful for drivers that don't want to keep a coredump + * available after unloading. + */ +void dev_coredump_put(struct device *dev) +{ + struct device *existing; + + existing = class_find_device(&devcd_class, NULL, dev, + devcd_match_failing); + if (existing) { + devcd_free(existing, NULL); + put_device(existing); + } +} +EXPORT_SYMBOL_GPL(dev_coredump_put); + /** * dev_coredumpm - create device coredump with read/free methods * @dev: the struct device for the crashed device diff --git a/include/linux/devcoredump.h b/include/linux/devcoredump.h index c008169ed2c6f..c8f7eb6cc1915 100644 --- a/include/linux/devcoredump.h +++ b/include/linux/devcoredump.h @@ -63,6 +63,8 @@ void dev_coredumpm(struct device *dev, struct module *owner, void dev_coredumpsg(struct device *dev, struct scatterlist *table, size_t datalen, gfp_t gfp); + +void dev_coredump_put(struct device *dev); #else static inline void dev_coredumpv(struct device *dev, void *data, size_t datalen, gfp_t gfp) @@ -85,6 +87,9 @@ static inline void dev_coredumpsg(struct device *dev, struct scatterlist *table, { _devcd_free_sgtable(table); } +static inline void dev_coredump_put(struct device *dev) +{ +} #endif /* CONFIG_DEV_COREDUMP */ #endif /* __DEVCOREDUMP_H */ -- 2.44.0