From nobody Fri Sep 23 14:47:09 2022 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 4MYw3K4bbJz4d9Kv; Fri, 23 Sep 2022 14:47:09 +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 4MYw3K3gHDz4CN2; Fri, 23 Sep 2022 14:47:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663944429; 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=Bo1ii7E6kM8WX87THl5e3dRNrmYpEW1c3tR7Qn/WAeY=; b=yZE9gjvapH/+GCpTJyWFhc/bRPoECv4ltc/nsX8GCNic6fkeOa6qp+skJPw22vQGagXryi cYEC62eNKsjoHs/18QKQ/WAC+Gz05ywDbUhYQ8vRA7DC1FGgEvagEJRP61Wc7RpeHURqMp HXkLYBbR6YorAwEIQxm1oybeBUO5DyNplWO+3AS2JLVA4kiLERFvCq1j6QTGzeYUk79RYu F+3YBPkH88zcem0KmcfQroz9Z8Z6cRclHMZ/uzutbTrEfowz6BAeq9YD4iEqSLOu9KjGd6 bdEaCMpT6atNodeD7myFSTdRRU/IngZutDhzijehK3IsMHANhAqZ3Bb2HV8QgQ== 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 4MYw3K2h7xzmZw; Fri, 23 Sep 2022 14:47:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28NEl9lP022401; Fri, 23 Sep 2022 14:47:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28NEl9Zc022400; Fri, 23 Sep 2022 14:47:09 GMT (envelope-from git) Date: Fri, 23 Sep 2022 14:47:09 GMT Message-Id: <202209231447.28NEl9Zc022400@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 6fc6896c4744 - main - Add bus_get_resource_list functions to the GICv3 driver 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6fc6896c474483b3cf34b83fb85f8e9f8cabc8a1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663944429; 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=Bo1ii7E6kM8WX87THl5e3dRNrmYpEW1c3tR7Qn/WAeY=; b=uB99qy6X8Xd0tW9I9BmJC52yqnxRyDaJMsNRCf5l2t02aCjho6AYDCjKhskSBjfVBVDlmG Qv65oglPIJJyJgo5Ori+OeqaypAPvdvJDMB38HBDkRBiRyOse61wt2uB3PYj3M89sIdvaq t78DKcxwZpYfti9w1kBfmghS0YMusEoJloMMl7kx3iB668SNY8XcUxCgNmAvHX2ngvmgay DGkFPsZL8aiRkGiWD8YOSlPHpPbH4J5tpHLNMLwTODSdLlcCbrdI4dyFjUIvA7GazBO4zT 0XS+W/N6MNfG+IwaHIamXgc2+03EJhqcHm7IE5vXhCd3sMTd2hZt5RiidLpXsQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663944429; a=rsa-sha256; cv=none; b=bKVgJUUNH/NqkHpECqsMp8zZrvjezgMy2aTM28jeafqFZFtRHvDpWjtobGULVoRh+za2Br BT2HcSONqUvlDZ40tJ8H1UJwdYSQkyHhH9TwKC8Wbt2vQ+WaSWXH2p3Q6X5rF5pL1FHIb/ 9HZyxLN6m9x3yjS0MiIdTWrua9QSZVEk2/gp4l2PTs/8C2Bs0l0DAvggfzTtV2yfZK3RyX yeHZedUpipoFkFz7A20Hh8r0UzgTbI1U63YU7rjquZq/wc8CVx46b4dTi5Kr0HuTxoy27h +xYIUtS3nqjcm8MnIOXoU20295fkRC5miWC7yf6Wjbg1Tx8t2qxvgySg6Avz/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=6fc6896c474483b3cf34b83fb85f8e9f8cabc8a1 commit 6fc6896c474483b3cf34b83fb85f8e9f8cabc8a1 Author: Andrew Turner AuthorDate: 2022-09-22 10:17:45 +0000 Commit: Andrew Turner CommitDate: 2022-09-23 14:28:45 +0000 Add bus_get_resource_list functions to the GICv3 driver This will be used to reduce code duplication between the ACPI and FDT attachments. Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/gic_v3_acpi.c | 20 +++++++++++++++++--- sys/arm64/arm64/gic_v3_fdt.c | 30 +++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/sys/arm64/arm64/gic_v3_acpi.c b/sys/arm64/arm64/gic_v3_acpi.c index cc24b7824ff1..f24662750da7 100644 --- a/sys/arm64/arm64/gic_v3_acpi.c +++ b/sys/arm64/arm64/gic_v3_acpi.c @@ -60,6 +60,7 @@ static device_identify_t gic_v3_acpi_identify; static device_probe_t gic_v3_acpi_probe; static device_attach_t gic_v3_acpi_attach; static bus_alloc_resource_t gic_v3_acpi_bus_alloc_res; +static bus_get_resource_list_t gic_v3_acpi_get_resource_list; static void gic_v3_acpi_bus_attach(device_t); @@ -72,6 +73,7 @@ static device_method_t gic_v3_acpi_methods[] = { /* Bus interface */ DEVMETHOD(bus_alloc_resource, gic_v3_acpi_bus_alloc_res), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_get_resource_list, gic_v3_acpi_get_resource_list), /* End */ DEVMETHOD_END @@ -447,19 +449,20 @@ static struct resource * gic_v3_acpi_bus_alloc_res(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) { - struct gic_v3_acpi_devinfo *di; struct resource_list_entry *rle; + struct resource_list *rl; /* We only allocate memory */ if (type != SYS_RES_MEMORY) return (NULL); if (RMAN_IS_DEFAULT_RANGE(start, end)) { - if ((di = device_get_ivars(child)) == NULL) + rl = BUS_GET_RESOURCE_LIST(bus, child); + if (rl == NULL) return (NULL); /* Find defaults for this rid */ - rle = resource_list_find(&di->di_rl, type, *rid); + rle = resource_list_find(rl, type, *rid); if (rle == NULL) return (NULL); @@ -471,3 +474,14 @@ gic_v3_acpi_bus_alloc_res(device_t bus, device_t child, int type, int *rid, return (bus_generic_alloc_resource(bus, child, type, rid, start, end, count, flags)); } + +static struct resource_list * +gic_v3_acpi_get_resource_list(device_t bus, device_t child) +{ + struct gic_v3_acpi_devinfo *di; + + di = device_get_ivars(child); + KASSERT(di != NULL, ("%s: No devinfo", __func__)); + + return (&di->di_rl); +} diff --git a/sys/arm64/arm64/gic_v3_fdt.c b/sys/arm64/arm64/gic_v3_fdt.c index 0ca362dc4aea..b0b532a56dec 100644 --- a/sys/arm64/arm64/gic_v3_fdt.c +++ b/sys/arm64/arm64/gic_v3_fdt.c @@ -58,6 +58,7 @@ static int gic_v3_fdt_print_child(device_t, device_t); static struct resource *gic_v3_ofw_bus_alloc_res(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); static const struct ofw_bus_devinfo *gic_v3_ofw_get_devinfo(device_t, device_t); +static bus_get_resource_list_t gic_v3_fdt_get_resource_list; static device_method_t gic_v3_fdt_methods[] = { /* Device interface */ @@ -68,6 +69,7 @@ static device_method_t gic_v3_fdt_methods[] = { DEVMETHOD(bus_print_child, gic_v3_fdt_print_child), DEVMETHOD(bus_alloc_resource, gic_v3_ofw_bus_alloc_res), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_get_resource_list, gic_v3_fdt_get_resource_list), /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_devinfo, gic_v3_ofw_get_devinfo), @@ -211,11 +213,11 @@ struct gic_v3_ofw_devinfo { static int gic_v3_fdt_print_child(device_t bus, device_t child) { - struct gic_v3_ofw_devinfo *di = device_get_ivars(child); struct resource_list *rl; int retval = 0; - rl = &di->di_rl; + rl = BUS_GET_RESOURCE_LIST(bus, child); + KASSERT(rl != NULL, ("%s: No resource list", __func__)); retval += bus_print_child_header(bus, child); retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#jx"); retval += bus_print_child_footer(bus, child); @@ -238,18 +240,21 @@ static struct resource * gic_v3_ofw_bus_alloc_res(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) { - struct gic_v3_ofw_devinfo *di; struct resource_list_entry *rle; + struct resource_list *rl; int ranges_len; + /* We only allocate memory */ + if (type != SYS_RES_MEMORY) + return (NULL); + if (RMAN_IS_DEFAULT_RANGE(start, end)) { - if ((di = device_get_ivars(child)) == NULL) - return (NULL); - if (type != SYS_RES_MEMORY) + rl = BUS_GET_RESOURCE_LIST(bus, child); + if (rl == NULL) return (NULL); /* Find defaults for this rid */ - rle = resource_list_find(&di->di_rl, type, *rid); + rle = resource_list_find(rl, type, *rid); if (rle == NULL) return (NULL); @@ -375,3 +380,14 @@ gic_v3_ofw_bus_attach(device_t dev) return (bus_generic_attach(dev)); } + +static struct resource_list * +gic_v3_fdt_get_resource_list(device_t bus, device_t child) +{ + struct gic_v3_ofw_devinfo *di; + + di = device_get_ivars(child); + KASSERT(di != NULL, ("%s: No devinfo", __func__)); + + return (&di->di_rl); +}