From nobody Thu Feb 27 14:17:19 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 4Z3YM36J3Jz5qFY1; Thu, 27 Feb 2025 14:17:19 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z3YM35cH3z3xPg; Thu, 27 Feb 2025 14:17:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740665839; 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=ZTTwMC19pYLW6+Yj9n3SYb9PTjDdsreiaykl3kxWv2Y=; b=Jf2M7ZtG9e/ru5P/NlzmyqkvaACuEGX6ObiLt0xyfhpacH9/rZcRkJkVAv3gj4gdmGX+I5 4JpLGp5CO0SntxId4VDfaFUsY+WU/pYoC0P5TjX0zae6pfSpQKVup+rqPP7pWAIMx6pMTB qd48vW9jLaUHjxcASoZbQ4WQHwwhIUQ9GIvedwVvwtbwdHcwMRgBOrRC6NsFnIodlinp2D yPUDob2YrQ8njYun8xdGJH7NODKVZmZQjv8ReXlIisnLywxYpcdwUR63a3Y0dJhRNHo4S1 OoK7Oqyot+TZVP07MWM+QZdfNw+RWegKlO30w0+A15oe9qEkVx6pzyqonRJREQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740665839; a=rsa-sha256; cv=none; b=e1yyT+r4Jz7DMwUC7cEfi2J7zpiDQhHwHRkjq18Qy1JUPp94SfT3dyjdYar12VE1AdT+cm BGo/AXFk14nODT3O6VyCZfiDuJPB9vqpMeg/ABcYwPoXWzEc5YCuMrL4cXK6y5J7XtWejy 4xztERwNZ8a96tSdy7Mrxo3kw9/0ZdqrduRitq3Izi0LuNPKl6TZYuhwfGN4AQ/twJCWZU 9z7FCtLMIjhLTqb86fPO4XwkQzOVoG2+56RIfqiC4EFGGlzknszxv8CM2VrsU/2QVcSLIs DwHPNN+Go9KZRgHSKKFHw6R/GSXXPdJbTSWUCiuikF7tBkO1MzYYhVszj/FKyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740665839; 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=ZTTwMC19pYLW6+Yj9n3SYb9PTjDdsreiaykl3kxWv2Y=; b=L5SkaXOnOyWP1k948hqKb+Cu8J5V0PJFGYTn9YW8ntuX5KIMicXOd5QFyBpzEPR42F/23d FztYnBgdxUnrDUvqLbtirQHEBWLHZb5+45w1Br0YgFGLQaskur+u4zyviBTYHzUtGM389q WdJmMTPlWRIlYZBoBw5z4F7EuQ4neOgNUCzdWt3dzagieuVsjeFZLcPkcnjYBFgcvz8AKI vwJ+drU4Wz2ex6om3VKs18hiilvZqyIKXgHcZxM7tU5Z3qlmQ4mR+iqSm3AUsRpyeXx5YC RBu3mTpGoWRZDyjB4h59EQGVsB48Ly8uQZW2ZIBEK2apRmQ9N3lcWcwI4rsNmw== 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 4Z3YM34rwCzm7R; Thu, 27 Feb 2025 14:17:19 +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 51REHJwd017156; Thu, 27 Feb 2025 14:17:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51REHJCl017153; Thu, 27 Feb 2025 14:17:19 GMT (envelope-from git) Date: Thu, 27 Feb 2025 14:17:19 GMT Message-Id: <202502271417.51REHJCl017153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: e14fd50dd810 - stable/14 - new-bus: Introduce a simpler bus API for managing resources 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e14fd50dd810a0b5fcdda002755a1942e202aaeb Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e14fd50dd810a0b5fcdda002755a1942e202aaeb commit e14fd50dd810a0b5fcdda002755a1942e202aaeb Author: John Baldwin AuthorDate: 2024-03-13 22:05:53 +0000 Commit: John Baldwin CommitDate: 2025-02-27 13:09:23 +0000 new-bus: Introduce a simpler bus API for managing resources Remove the 'type' and 'rid' arguments from the wrapper bus API functions (e.g. bus_release_resource) that accept a struct resource. The "new" versions extract the 'type' and/or 'rid' from the passed in resource object via rman_get_type and rman_get_rid. This commit adds the new API as functions with a _new suffix. Wrapper macros choose between the old and new functions based on the number of arguments provided to the macro. This commit does not change the ABI but can be safely MFCd to older branches so long as older kernels use rman_set_type when allocating resources. Future commits will push the removal of these extraneous arguments through the bus implementation. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44124 (cherry picked from commit 9edb8d0aedef2f1e13ed1f8134deb3f8291d2fe9) --- sys/kern/subr_bus.c | 42 ++++++++++++++++++++++++++++++++++++++++++ sys/sys/bus.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index ffad54c34925..5d1a13c08892 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -4618,6 +4618,13 @@ bus_adjust_resource(device_t dev, int type, struct resource *r, rman_res_t start return (BUS_ADJUST_RESOURCE(dev->parent, dev, type, r, start, end)); } +int +bus_adjust_resource_new(device_t dev, struct resource *r, rman_res_t start, + rman_res_t end) +{ + return (bus_adjust_resource(dev, rman_get_type(r), r, start, end)); +} + /** * @brief Wrapper function for BUS_TRANSLATE_RESOURCE(). * @@ -4647,6 +4654,13 @@ bus_activate_resource(device_t dev, int type, int rid, struct resource *r) return (BUS_ACTIVATE_RESOURCE(dev->parent, dev, type, rid, r)); } +int +bus_activate_resource_new(device_t dev, struct resource *r) +{ + return (bus_activate_resource(dev, rman_get_type(r), rman_get_rid(r), + r)); +} + /** * @brief Wrapper function for BUS_DEACTIVATE_RESOURCE(). * @@ -4661,6 +4675,13 @@ bus_deactivate_resource(device_t dev, int type, int rid, struct resource *r) return (BUS_DEACTIVATE_RESOURCE(dev->parent, dev, type, rid, r)); } +int +bus_deactivate_resource_new(device_t dev, struct resource *r) +{ + return (bus_deactivate_resource(dev, rman_get_type(r), rman_get_rid(r), + r)); +} + /** * @brief Wrapper function for BUS_MAP_RESOURCE(). * @@ -4676,6 +4697,13 @@ bus_map_resource(device_t dev, int type, struct resource *r, return (BUS_MAP_RESOURCE(dev->parent, dev, type, r, args, map)); } +int +bus_map_resource_new(device_t dev, struct resource *r, + struct resource_map_request *args, struct resource_map *map) +{ + return (bus_map_resource(dev, rman_get_type(r), r, args, map)); +} + /** * @brief Wrapper function for BUS_UNMAP_RESOURCE(). * @@ -4691,6 +4719,13 @@ bus_unmap_resource(device_t dev, int type, struct resource *r, return (BUS_UNMAP_RESOURCE(dev->parent, dev, type, r, map)); } +int +bus_unmap_resource_new(device_t dev, struct resource *r, + struct resource_map *map) +{ + return (bus_unmap_resource(dev, rman_get_type(r), r, map)); +} + /** * @brief Wrapper function for BUS_RELEASE_RESOURCE(). * @@ -4708,6 +4743,13 @@ bus_release_resource(device_t dev, int type, int rid, struct resource *r) return (rv); } +int +bus_release_resource_new(device_t dev, struct resource *r) +{ + return (bus_release_resource(dev, rman_get_type(r), rman_get_rid(r), + r)); +} + /** * @brief Wrapper function for BUS_SETUP_INTR(). * diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 5d5336591ea6..c1391c4a7284 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -613,6 +613,43 @@ bus_alloc_resource_anywhere(device_t dev, int type, int *rid, return (bus_alloc_resource(dev, type, rid, 0, ~0, count, flags)); } +/* Compat shims for simpler bus resource API. */ +int bus_adjust_resource_new(device_t child, struct resource *r, + rman_res_t start, rman_res_t end); +int bus_activate_resource_new(device_t dev, struct resource *r); +int bus_deactivate_resource_new(device_t dev, struct resource *r); +int bus_map_resource_new(device_t dev, struct resource *r, + struct resource_map_request *args, struct resource_map *map); +int bus_unmap_resource_new(device_t dev, struct resource *r, + struct resource_map *map); +int bus_release_resource_new(device_t dev, struct resource *r); + +#define _BUS_API_MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME + +#define bus_adjust_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, bus_adjust_resource, \ + bus_adjust_resource_new)(__VA_ARGS__) + +#define bus_activate_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_activate_resource, \ + INVALID, bus_activate_resource_new)(__VA_ARGS__) + +#define bus_deactivate_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_deactivate_resource, \ + INVALID, bus_deactivate_resource_new)(__VA_ARGS__) + +#define bus_map_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, bus_map_resource, \ + bus_map_resource_new)(__VA_ARGS__) + +#define bus_unmap_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_unmap_resource, \ + bus_unmap_resource_new)(__VA_ARGS__) + +#define bus_release_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_release_resource, \ + INVALID, bus_release_resource_new)(__VA_ARGS__) + /* * Access functions for device. */