From patchwork Mon Mar 4 14:39:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 209560 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp1462745dyc; Mon, 4 Mar 2024 06:39:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVhQV3IOZwPsMo1E+GkFXUey/k6Wp8NZHn4rAKf4f4n+reLt1KjLLgOgq6YjQ3TsK4+ENpXpEhsTUAONqrVIyRX3QNuog== X-Google-Smtp-Source: AGHT+IHtH4wclCkplXdL3jFElB52p5KPE+dbYCwjra4HBQTWYNnpbCGRRTuyWkOVkhT61HeLFMoo X-Received: by 2002:a05:6a20:6703:b0:1a1:4fc0:a55e with SMTP id q3-20020a056a20670300b001a14fc0a55emr2033202pzh.55.1709563181441; Mon, 04 Mar 2024 06:39:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709563181; cv=pass; d=google.com; s=arc-20160816; b=bCNupie2f4AGJQrTN0YE4q/GPpmGQiTECz8ofEEbIO6E6bkr6oUZrBcy8M7LtZ0NIx 4AZCVDZUM5434xwCNObX8X01iyZa+F64MpISYowJMLpiiGB1lA0xGWIEv5eWHUJFcMjP OyuKbX87bF7NQ9zL9h6K6HjhLdiV3Iu/hJOpCb17L9n0aOP5d+KNBDDpiNzOM+4C2Sba f+jdUO9cwfWMcncSn2LoSXwQaKaHPIZ3IMLXUWLgqheeyOPZk/8yPlI4S3t623GQy5mr lQFxpxTeF7MLoEQyCj5QTi2JeCtrihIVCeuUPjEc0pCyfC1teeNIDGVKEt+c7gqnOIsl /Tbg== 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=cq8zRIuJWm+liYpoIrwTRtRNMZ8bKr8RBoakSIyGtFw=; fh=/aA3ikCzdHUoND1NkELyjjOlZC31bXhfya5LgPc2Wj8=; b=MUXSzcock7PK8qx72FrGCDCpcrtvAt/x5+i1LI5g9U4787q0o16yLQK1Oiqrliy2HH gQLzz+Vnx9En6VQ+U0hLeHwJSULBN/34mbcN50IbNkRyBh+aknwuR2tKmb2OqdePLqWh kpzskgxiBiFXKLFwirAdgnoP2Z3A76PB4oVha4nJfNzATRXYZrfSVyQIXrq7Pz6KBLif SeKwgCy9mJwhKZqOYvxiPxQzyZHNfYC1gfR/Xc2AlpD0fbVCaTQ6ARAdbroZ00ubvBG2 7GEqQYwaZ43jM8LUhGv/rJ1o6XzBPC9ay3MxweniZg6Q2bxzvfr3UKJP9JRlwnRN6POv D1Fw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ji2JuPx1; 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-90743-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90743-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g17-20020a635211000000b005e428bef548si8531477pgb.649.2024.03.04.06.39.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 06:39:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90743-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ji2JuPx1; 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-90743-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90743-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 40131282559 for ; Mon, 4 Mar 2024 14:39:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66EFB45C14; Mon, 4 Mar 2024 14:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ji2JuPx1" 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 BB56726AE7 for ; Mon, 4 Mar 2024 14:39:14 +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=1709563156; cv=none; b=oW0HLrNtsmTsNEJT8LSW/O4ey8wF54s/CPDyUFcsn4mGSB2cUKOQiAGZ0aHQT+VKdViwX6H/6EjhoplEHkoNchoL9MId0NU7BhfMo4w265hmf7reA9pqhbD+e5uPA+8vPp8m/0ctB0IysoHyGkeTUpvQRxesWfegFVDcFan9+Cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709563156; c=relaxed/simple; bh=+MRf5Lm7FcBWGyRnw6HSAym7eF960AjwB9H891dwqBg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=MehSEmGdXip2iUcxFI2TL2f0EwcGzJdgGFHoKTBO29hqNMgWG62WOxp2T9Iot4gnvXqdpB1a4JBXjkafUxiTre6y1XoNmwDm6WvC/5jAFYkruzqMOHSyxmCgyYI2LViFHmE63A3MqlGuFesy1mIgsluQNkk08JFKrKRSVbf5lZQ= 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=ji2JuPx1; 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=1709563155; x=1741099155; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+MRf5Lm7FcBWGyRnw6HSAym7eF960AjwB9H891dwqBg=; b=ji2JuPx1crnRorsQ4wb1oF1A0XRZ4uZTAZ1NhAewnrXt0fcSbYzNRTuN ne1yohJvL0YCCupG2KwxilBJ2TLdYVB6qiKpPM3ASAJ3Tzs3b/x02PfFJ l6ZGREZG3JLgNITeTC1UUECSdNFOT76XUu0SqT2Non18LXqSE2+UTnVBk 0idfv1HjE7a6vifswqqnR+KnmepCJw/Qu4ismswCTFJ+WwRZpcRZXa/p/ 8E6kHv0g5NuWvuNTjpAn5hlz966xM9nsFWCk4fGzWN4ypaRJig7pKKMBQ Dk93BIJqyycVqAZJ5Uk1q9NwxRxSLxXFlpuR9Qblkk5RvLqB8CSVJK7kE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11002"; a="15464629" X-IronPort-AV: E=Sophos;i="6.06,203,1705392000"; d="scan'208";a="15464629" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2024 06:39:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,203,1705392000"; d="scan'208";a="9162521" Received: from josouza-mobl2.bz.intel.com ([10.87.243.88]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2024 06:39:12 -0800 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= 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_Roberto_de?= =?utf-8?q?_Souza?= Subject: [PATCH v3 1/4] devcoredump: Add dev_coredump_put() Date: Mon, 4 Mar 2024 06:39:02 -0800 Message-ID: <20240304143905.52740-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792606922456050078 X-GMAIL-MSGID: 1792606922456050078 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 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 */