From nobody Wed Mar 13 22:13:35 2024 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 4Tw4Xb5Wxhz5DXRx; Wed, 13 Mar 2024 22:13:35 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tw4Xb3cr9z4qfr; Wed, 13 Mar 2024 22:13:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710368015; 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=ryWXNt0z4fSnsZeW/Xp2o1uiZ2+sHgrwabHe/MPvx0s=; b=fRnkkXLfdzbEAhG+Mj3MOIQqCFubLZ0xfIK2lGtQX2zI62MUgGXVqRtrrSfBoYQjeIQ6f2 +LaXWg3X5Bd2R+dK0snoYvU0EPOZ9dqHfr3hWSto8RBLwyfvF/wYm6Q8F1ZQiCFEawPCeT X1DGRjMM2kMZ8f4Iy6SHsDKg27N3P3lKotXvo1chwawVEumKA/mv/yL944bkg472UuWkFm Y2JXRTJ4Pu7n6v5SHqVriErlQHU5YNJlIJTK/1VBbHTwU7nr0aAER2d7BLkmPROMJQ4ts1 ETxgEPzNZSGZPyYTZ7+jTvy5fUI7rRbw+cQKFBwrdE7TvHslZ3xYDAA06jJiiw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710368015; a=rsa-sha256; cv=none; b=Ibk81bWOWBJZyDPLiSiYd4yf45F1R/XNPQybERfxQN3ltdWauPvrn3sLyceJFJ/JZyrFKB 6O+ovd8t5pIxNNUauEfs7WOLLjvzHubV39f1pEx50zxamAThdowoMPNatIz6Y3LIiBd7hM fRaDmWmBSxPHXDkSRcEkWzw+UdJOzlcJt9d/cwnfkEa0lJXEQvoIvthi+92ONVvDZz9iNY n4LPQm1gPJwzWW/KNq7tVHAHD6P30NajF5xX1LcHe3UV5M3wiMz9coiHOQlPHOffIuGS8z sYwoI35NJTU/nX5AbU6d5SHZfjYNEPOJJEgHYhxsLl0tOTsMF3Kki8szF5X4fA== 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=1710368015; 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=ryWXNt0z4fSnsZeW/Xp2o1uiZ2+sHgrwabHe/MPvx0s=; b=wKIU7Z0KY+Ve0eRJ4foUDe1a3bjfg6/a8mLiNB13CP5qrAHZl3jlNgxtSTl9DCvelUdJB3 OBpmD5x9LodE9WNCdCxvYidBeu2ckTVMlauJB1sbpEEFcVcqX2Cb7iIWHBHdlDyxef5vQ9 YPxkOXRIEmym7j4EyXzT9sk7C6DQPAh8HR4Ka9j7ZmCba/lrJXGBVfumqVk/FDYxr6tqp6 Zgty2vQF1DJJLOZc8+VUNp1hmKd7+u2rkA/D8JFIHFylxC1MNRaj9EGqmT8QIODrdJc+0T CgqzI7mmEZmZvgf5JOiJZB3rCpN2SxusG9mRfTOVED9gAtvPn0Z2lcFzRYtXtA== 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 4Tw4Xb3BW7z11hl; Wed, 13 Mar 2024 22:13:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42DMDZMP074849; Wed, 13 Mar 2024 22:13:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42DMDZ6A074846; Wed, 13 Mar 2024 22:13:35 GMT (envelope-from git) Date: Wed, 13 Mar 2024 22:13:35 GMT Message-Id: <202403132213.42DMDZ6A074846@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 9edb8d0aedef - main - 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: 9edb8d0aedef2f1e13ed1f8134deb3f8291d2fe9 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9edb8d0aedef2f1e13ed1f8134deb3f8291d2fe9 commit 9edb8d0aedef2f1e13ed1f8134deb3f8291d2fe9 Author: John Baldwin AuthorDate: 2024-03-13 22:05:53 +0000 Commit: John Baldwin CommitDate: 2024-03-13 22:05:53 +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 --- 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 ecd5ad44959d..25cb5fba2108 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -4545,6 +4545,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(). * @@ -4574,6 +4581,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(). * @@ -4588,6 +4602,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(). * @@ -4603,6 +4624,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(). * @@ -4618,6 +4646,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(). * @@ -4635,6 +4670,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 581e81352be4..6fcd414dc7be 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. */