Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp19187lqe; Tue, 9 Apr 2024 13:02:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+wIRlyMdlQ3DDM3IQ/jkeScldA94JKHC1zJDiTVBc1zrH1rzo58mPr+POwnrM5pzGEgQ7TMKUtH+3DdX0iE4mvYnXMgFy2lEmJePwew== X-Google-Smtp-Source: AGHT+IF72IxOLQdK0R0w5sgG1k8uNlEK34ep90XgdspVTStzfXw7cfRf779ABH3fDakpjVqIbHvV X-Received: by 2002:a05:6e02:1686:b0:36a:29dc:37ea with SMTP id f6-20020a056e02168600b0036a29dc37eamr1006473ila.32.1712692947407; Tue, 09 Apr 2024 13:02:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712692947; cv=pass; d=google.com; s=arc-20160816; b=i+Tlpr/EjBIG9/mr3RBuYOn0ul3RCQgmKZUZuDuOvloYs3GWB92JaUpxzkAddcU7dP ZS5GcUFYvA1I+VngrCRSh16oI5fdv2qbzOAo//LyMud+L7PWljIAv1pZyHjzHEtftABH XYsfEEPnG8kqT1J1/KgidrNxwZGB35jdBfAhTZ4y8KLLG8kj0dh8f1AAcA9kd6WJYJ+j ilky7DHoqnrvajhUn0tIdLxhzmvbPhq49dJd1PS5iByWddBBwnJcKTr8a+ce0YL5iwvt MQN9+YBGZOOsJIFTzBqsrgbROin5BDKSILsWyjOuXUPbtOKn4scjKJ+P22OToSovRPOx yh+g== 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=76s7/5x8tuBngpocFOxLg2uMjRkEz5tpMWTnLp3RjsE=; fh=/aA3ikCzdHUoND1NkELyjjOlZC31bXhfya5LgPc2Wj8=; b=yBdsCp5Yhoz4Zaoze87Gf98QIrPPinEah45REE3ScmFSTx9REuu+zb1WSr/BhEZ47j Ze2MFnfzJhp/nocFArQ+xtvPy2nKNUtWnWnfpkrg555CGwtLSH2T+wj9TM6sCJJ6qKfh kGZeNIrQYApAupkUaDtyD1QeEdVwRdgAG0UPJQ77JoD4BSVRXE6qV5nQxVMLM+/1DRge XykoPJPp06RQPU+/z6US4NbubOW6y++sdbU8qUrZKUMjq0OQT1ITJTYWwqnrh2/KuyW/ v+YTkVnQL6dGKXA4CtSNDdUZgl39QiaKrUfS9L4KoUBMrH6q9lf11fQpvDR5ajbV9uG3 78xg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GQxpZCE2; 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-137568-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137568-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e184-20020a6369c1000000b005dc8a59e303si8628430pgc.111.2024.04.09.13.02.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 13:02:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137568-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GQxpZCE2; 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-137568-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137568-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 20C7AB21D5D for ; Tue, 9 Apr 2024 20:02:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8643C1581F4; Tue, 9 Apr 2024 20:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GQxpZCE2" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 B16E3156F4E for ; Tue, 9 Apr 2024 20:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712692938; cv=none; b=ldZmGcMsgbNDWT7UUnfloMRaK6sbn5gZSW7bDfs6k2vhDp7rwDJfD9BLC+lsn+OzYTyyJFmQsUkV/ewr9DliqLp+6NYr0U1VR6G/Cpl4bF9RdVIiSHXpomDagIDHG60Rx40myvB+CfGs86CcmUExKOYv09BkRZdpU+WX2aFrL0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712692938; c=relaxed/simple; bh=BKcWmZZnN2N2645VQtJaW8isi6HlmohHD9/K4VPBE6Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=UeYW0QIl8JC6fA8+g6MNgGlhQexXF8GuIcbo3muO5pP4PG+BA7PwJMy/LIPRhFG3u8TDNVs6l45AtEiEI+ntTyjJyYlvDm+YU1wb17HxUxnUP1zP8yx+04ha6JKbg1tJPp06NAwAXzLJm3M5yiPB+v7Prcgr3c+uEI2F9ROHisQ= 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=GQxpZCE2; arc=none smtp.client-ip=192.198.163.13 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=1712692936; x=1744228936; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BKcWmZZnN2N2645VQtJaW8isi6HlmohHD9/K4VPBE6Y=; b=GQxpZCE2ICiZYhlbHny9anxbZn4352UFvqLO8u+3t5/lPdykXklWJnR+ ZxkU/F4kE847TMrsaHMLNL8REFr5ROSpBB06EB79SlogRLjV6XlFMWZia Cp0D0MAVnJ6zMP9c6bec/dTyvErk0gY71MqB6Fv9sNy6D5kqJdDoJyytP QgzU+HOk5361LaYA/HESO5m8x9MM9NvQeW7ADhyE6l+dwVpuQ93kBYFwv ye7Zs35Kxnupa11lhQ3SwfiqcbMLaywDH+XvcLEe61G4u4ZSeTIVexInu 5hk/WA6SB213GgMIcER0EEcaHMwCX8Jak0cEg0G0AkWe7JYf3lyEc1WSr Q==; X-CSE-ConnectionGUID: lam0vk6eQ+ypTB7WH69DVw== X-CSE-MsgGUID: yWB2jM10RJK2p2dcYjI8QQ== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="10996842" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="10996842" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 13:02:15 -0700 X-CSE-ConnectionGUID: RO/DTNXpSj2+XpSBF3MjmQ== X-CSE-MsgGUID: C1LbVe6RQRGEdWuPFtf0Sw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="24824245" Received: from josouza-mobl2.bz.intel.com ([10.87.243.88]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 13:02:14 -0700 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 v4 1/2] devcoredump: Add dev_coredump_put() Date: Tue, 9 Apr 2024 13:02:05 -0700 Message-ID: <20240409200206.108452-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 It is useful for modules that do not want to keep coredump available after its unload. Otherwise, the coredump would only be removed after DEVCD_TIMEOUT seconds. v2: - dev_coredump_put() documentation updated (Mukesh) Cc: Rodrigo Vivi Cc: Mukesh Ojha Cc: Johannes Berg Cc: Jonathan Cavitt Reviewed-by: Johannes Berg Acked-by: Jonathan Cavitt Signed-off-by: José Roberto de Souza --- drivers/base/devcoredump.c | 23 +++++++++++++++++++++++ include/linux/devcoredump.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c index 7e2d1f0d903a6..82aeb09b3d1b5 100644 --- a/drivers/base/devcoredump.c +++ b/drivers/base/devcoredump.c @@ -304,6 +304,29 @@ 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 + * + * dev_coredump_put() removes coredump, if exists, for a given device from + * the file system and free its associated data otherwise, does nothing. + * + * It is useful for modules that do not want to keep coredump + * available after its unload. + */ +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