From nobody Mon Sep 15 19:11:21 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cQZQ14hskz67sqB; Mon, 15 Sep 2025 19:11:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cQZQ12rJJz4FbG; Mon, 15 Sep 2025 19:11:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757963481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lkEXNkEHS1H3I8jWOmq6kF765VaAihA9HImV1/S4mlc=; b=AM06WdTnZjWkG82bnVHkG2x36ew+kns1AjuRnn3Fl4F4thUtbAVzv0LSxlIVJaLa66p1/+ ofeg/SYZPqmNz4s9whIhj41OV4hrOLduApX2A1EFN1VHabKBBx4UQL8tTjlw2w+Mf40XgM gRTY4U4i2rX0ONzqJIhMMEzem9fZ5eQtZlYYiemvi97V9ByAY8wE9iLw2R/KQuRuRKChwU KxhteNh6f+rtx7ZFkTtWGmgXLeDTFGbrJDiXtY/qpaUIY7CXutl+ZNObL356A+Z1XdRyTY lnZDaqCR9pl8YFdFQIN8x9+OXCzASCF3spUjjG781Va8jqEPlzQND/VMK5h5zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757963481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lkEXNkEHS1H3I8jWOmq6kF765VaAihA9HImV1/S4mlc=; b=kuecUgPlDDHU585uTmJgoafypug9C8wJbjsImJHsYdFiMq40lcCzntQHqloDYtmS/dQzBt j0/i6gNxMMUcazXYek47KKUyui7WvsLuWfPlMxVj0SV4Tn8Sdts3yMjmvPQNs1sC/aqqBI Tfbp30cm7Mr0EmxYd1w73kUSC6yEW28sUutL1dP2iKLSXOe66j35elLKUuLQZL+uTNBF4o og+nIBHkXuGnt2isY+xWFaPKvsp2ntThPHuHKj4vdIMUb2OvfRngQelXqEJ6U/JEr/OUhu 50oYfXU5rm5RPCPGQOPG9U70XFNGvrbdB9GQAv5XniY2S5GBakZETfY3iECA/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757963481; a=rsa-sha256; cv=none; b=IFvmnmOFRzA/5l1254594+Iu6GxM6LZ64320E8jUyfyqK7RcwE8QVQMPbKo+xgRLwNY74Y +/hKsx3wPBcfJkfDcipx6SMwvehj0r27ian6iqakoZbEIfVkfj6uvjb0u1ASJuAHRlwTO5 QanKaYyduMPjpgL03N8QAsnkaJqh2Gx6PH2sVhqNELeGpM2KMVRjHMxlowZaWUl5QSwQql H5zs4/ZRIAlPVS6P+4drHOopfcXq6DjAyR8dKmVmJhiSfKk3zbu+Mnmc7h/MKPds7x1W+/ /krBoZWXGL5RrZQTiNeuBl9EFFKy54hFORrXGhFyy8CH/tcf+2YYLQE8eSZZ4g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cQZQ12GbHz16gc; Mon, 15 Sep 2025 19:11:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58FJBLh1051158; Mon, 15 Sep 2025 19:11:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58FJBLsA051155; Mon, 15 Sep 2025 19:11:21 GMT (envelope-from git) Date: Mon, 15 Sep 2025 19:11:21 GMT Message-Id: <202509151911.58FJBLsA051155@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: f20a09e161f0 - stable/15 - LinuxKPI: devres: divorce dem_kfree from lkpi_devm_kmalloc_release List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: f20a09e161f07874c3a01b1579e8a5d2356df8ce Auto-Submitted: auto-generated The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=f20a09e161f07874c3a01b1579e8a5d2356df8ce commit f20a09e161f07874c3a01b1579e8a5d2356df8ce Author: Bjoern A. Zeeb AuthorDate: 2025-09-04 20:28:18 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-09-15 14:53:01 +0000 LinuxKPI: devres: divorce dem_kfree from lkpi_devm_kmalloc_release dem_kfree() is called from all over the place and should actually do something; contrary to lkpi_devm_kmalloc_release() it can also take a const void *. We have to __DECONST() that though as the entire devres framework does otherwise not take a const argument. This was discovered during the rtw89 upadte to 6.16. Sponsored by: The FreeBSD Foundation (initially) Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52082 (cherry picked from commit 4ab64e34911ab06e567caaf07ed18f7770a61cc8) --- sys/compat/linuxkpi/common/include/linux/device.h | 5 +++-- sys/compat/linuxkpi/common/src/linux_devres.c | 26 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h index 2556b0c45e49..7dd6340746d2 100644 --- a/sys/compat/linuxkpi/common/include/linux/device.h +++ b/sys/compat/linuxkpi/common/include/linux/device.h @@ -4,7 +4,7 @@ * Copyright (c) 2010 Panasas, Inc. * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. - * Copyright (c) 2021-2022 The FreeBSD Foundation + * Copyright (c) 2021-2025 The FreeBSD Foundation * * Portions of this software were developed by Björn Zeeb * under sponsorship from the FreeBSD Foundation. @@ -284,7 +284,8 @@ int lkpi_devres_destroy(struct device *, void(*release)(struct device *, void *) void lkpi_devres_release_free_list(struct device *); void lkpi_devres_unlink(struct device *, void *); void lkpi_devm_kmalloc_release(struct device *, void *); -#define devm_kfree(_d, _p) lkpi_devm_kmalloc_release(_d, _p) +void lkpi_devm_kfree(struct device *, const void *); +#define devm_kfree(_d, _p) lkpi_devm_kfree(_d, _p) static inline const char * dev_driver_string(const struct device *dev) diff --git a/sys/compat/linuxkpi/common/src/linux_devres.c b/sys/compat/linuxkpi/common/src/linux_devres.c index 84f03ba0dd7d..23c91cb5ab2f 100644 --- a/sys/compat/linuxkpi/common/src/linux_devres.c +++ b/sys/compat/linuxkpi/common/src/linux_devres.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2020-2021 The FreeBSD Foundation + * Copyright (c) 2020-2025 The FreeBSD Foundation * * This software was developed by Bj\xc3\xb6rn Zeeb under sponsorship from * the FreeBSD Foundation. @@ -223,6 +223,30 @@ lkpi_devm_kmalloc_release(struct device *dev __unused, void *p __unused) /* Nothing to do. Freed with the devres. */ } +static int +lkpi_devm_kmalloc_match(struct device *dev __unused, void *p, void *mp) +{ + return (p == mp); +} + +void +lkpi_devm_kfree(struct device *dev, const void *p) +{ + void *mp; + int error; + + if (p == NULL) + return; + + /* I assume Linux simply casts the const away... */ + mp = __DECONST(void *, p); + error = lkpi_devres_destroy(dev, lkpi_devm_kmalloc_release, + lkpi_devm_kmalloc_match, mp); + if (error != 0) + dev_warn(dev, "%s: lkpi_devres_destroy failed with %d\n", + __func__, error); +} + struct devres_action { void *data; void (*action)(void *);