Received: by 2002:a05:7208:13ca:b0:7f:395a:35b6 with SMTP id r10csp5992rbe; Wed, 28 Feb 2024 08:57:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXsLgl/BpdKO5tQMYY1y2bLXn8WFlHsWvx6Cn2zxKNgM5yEBufJ43A3NM024uFjgzIsIjmaess2IWeP+X6k68Fv9PW7t9H5tdS6YSSzqg== X-Google-Smtp-Source: AGHT+IFnOZOpLmebQ8e/kODfXA/WptKOneK92HwCWqk+f6UWYXw5Al5kho72UhcBD3a70glAma7I X-Received: by 2002:a17:907:174d:b0:a43:acbd:db59 with SMTP id lf13-20020a170907174d00b00a43acbddb59mr33447ejc.3.1709139450799; Wed, 28 Feb 2024 08:57:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709139450; cv=pass; d=google.com; s=arc-20160816; b=n6f98aB9HSxPX64BvLBpVnyj2T514xEtY26iM8wzvo0ZDjHFE1NqzlkvfLLK9vKdO3 J1Owt8jiVGCz4kbkkBhP3bP7ryiNDqusn2IlerxZJxUpy6CT6cgVURqAUTzu+KeAQmH9 3kdObJzK/Jy5SEXZPi7GSEAGlXq02sLO+185oEN/SeDRDKMEBsTpyKE1+WeVs4++qaVE iTzSlhv9bGhjsRW1/e6IybmgArg14rRT3KsHCFKRROj4yA4jHppFMBCwjT8C4pnczrAE 2YlQW3OVQTLpfhubVEr/pe0YSulgeuVzex/3LHhpwRV661YMJTCXCOt1dFU/9Kn7eOKo AMbg== 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=tAGiSJn6bFaHZErU50KYPbvc1zLAZvyeXrxAUzPnmHU=; fh=/aA3ikCzdHUoND1NkELyjjOlZC31bXhfya5LgPc2Wj8=; b=J783/S9yzXVhlY+Bg2MAJ33+Z57O7HT+KP1OPEWus0SzAJM9yv6dtZn3FlpscZotoZ ApG4Sq47ogBXdh6hQrQAf57cEbzmyWIPHybDNuAdzH+C5cwf7rSzbyrokEe8zwMO0MPy 1EK7Krv2oYnFYOr24NRwYLYSRi1WwFsDeTawF/dIcJk9ZrWmxRHW5EPmhgk4tek31GXE Id9xnmP/MLTL1cDFwTTz/exM8q6PLDYYFZLdIa3URzvJwLCGziJXyrALK1yU/YQ9ShfI +4w7VOprdtRlPy6eym7QKusWoTDJiT9cyHrG/z2oL+ymyw0Dx9RzKV8Hkn2b2mRun5PI juzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bVFkPQb2; 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-85395-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85395-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k6-20020a170906680600b00a43ffa55983si749298ejr.748.2024.02.28.08.57.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:57:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85395-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bVFkPQb2; 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-85395-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85395-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 638C11F26B48 for ; Wed, 28 Feb 2024 16:57:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2DB2E3BBC6; Wed, 28 Feb 2024 16:57:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bVFkPQb2" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 099DC6EF10 for ; Wed, 28 Feb 2024 16:57:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709139442; cv=none; b=LQOgIOh7HUYaVlxzosPoZxv/6v6NfPLFRBNEgjhoVHN0GFd4iM7SbnFscf9IT4YcXpHCym0ejX38hzpoAzdmFdGgbX0xj1jL/dRpkVLsYqmxo9xhvKisV2XPAM9guILpEd2diHuDM4bNDxBzOyrkQGovMuLpnZKyUgCpSbkwHoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709139442; c=relaxed/simple; bh=phbEv7ysbvgxwpG7TOOGa4Oqlsk+ALMGgBrAccT/rds=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=PZ7hUi9SN6jLrp8rB7DOJhDZnzwabmzu4TaA518+Vh4ZGEOGktJH31xsj2E3LUER8li71l1lXHTE+acXTG40w5rbLK6unJMuHNTAIjTEYxoXDviTUUA7u3Wr/OkXHAnml3UGjQ4N1U8zJEPIsiAMA6/2EDiCBdYEFkstKlc/J3g= 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=bVFkPQb2; arc=none smtp.client-ip=192.198.163.17 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=1709139439; x=1740675439; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=phbEv7ysbvgxwpG7TOOGa4Oqlsk+ALMGgBrAccT/rds=; b=bVFkPQb2sKU2rDr1RII8TbACuq1+5jRMDbw7ubLLeOoGVa4Hgig2Om+G OeBVCHMe1I7KgZh6Yi8VkcwAJVPIllpCFyov4sSXpezwLaxhhK7K6STD1 SyOzpqJhCEw9lpRe3QdOVbyDyMW5NAMGKIuusWNR3nD9m4SuyobwP8hYz FpdnPAFRyP+j3JgXSwn/KwXTTBolQ/Im1s9cO2bdjMUYspNGkF/2FrfXq 2bgy0/hbPXEEM7wZ74XtNhZeMT5U4NvmrCcrraJOpCDw9rgYnjqLA0zK/ HWA+GVvZY9fMUXoEDCI9j6ufcHAEdDQH3U3V7svhlBmKvsj2pN9ey3iNd w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3401200" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="3401200" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:57:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12213419" Received: from josouza-mobl2.bz.intel.com ([10.87.243.88]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:57:17 -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 v2 1/4] devcoredump: Add dev_coredump_put() Date: Wed, 28 Feb 2024 08:57:06 -0800 Message-ID: <20240228165709.82089-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 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