From nobody Mon Jan 23 12:37:23 2023 X-Original-To: dev-commits-src-branches@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 4P0qPJ1tK8z3bStj; Mon, 23 Jan 2023 12:37:24 +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 4P0qPJ1MBLz4QTg; Mon, 23 Jan 2023 12:37:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674477444; 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=rPBRkXOlTI+BztxLDL7YXfS7w8IeSa0OoiFscirxrf4=; b=Jc8E02uCLFVTJTGj93Fx0xPWVKVZShX4gh5EdZt3/LsIHKRXt8TfCrhkNL4EWExUsrS9eo Y5lzByj/a71GDDVfDY9q2+j1L0SAALoakgNy7LBGY3+yXaZZGuyry100BUCcf+MsiSRW1u aIeqa5/XJY8TXEntNmZDdhflbThbufB5kz8S3c4Wj6WUuG5o8zQ51FulMMR8o3ZHDY1uwD Rrw440Cp2YUVTjJPNOjDtR0N+D2SrXofzGclrUQz2moCP2PB54AlefsWPJu0rL2PEBQro6 wdFsSByj6YCbLRLzdch70rvytATncCzhHNuSPLyZFTeqcjdoV+WKrg8CWHUeqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674477444; 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=rPBRkXOlTI+BztxLDL7YXfS7w8IeSa0OoiFscirxrf4=; b=M9GssVv/A7HEV1+NL0+ltt4MRAf+JSX9kUUU3fraVD6oN6207dSYUBrUGXblLMKOz0eNAs VAriZ6VyOz1nM7c6GPDmc+L8TVxcqcCcmDhr3PD5eMcvXQPHF1P2aBz2MSGm+oixLVJgfO COl5iOuyOV/46hYJdycdlz8ig5LxjwSH9gHLXba3vkeG5Q3X8MDKAnszlb9NUWyyJ1dCEL w/0t36bYBOznGGXB8zzs9sAHtmRdyPLT8SAHRFqB6JLxy7iOCPr+16DDeD7po1P7xEDczd 28qOw8iQx1Ezby+iMgB3SbkiBdMDNPPNpZtIMv/VncDszT47B6SKx+h/+Nf1BQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674477444; a=rsa-sha256; cv=none; b=pJXnZ3066S0tbUK0skXh1R9c01Rb69WJP721p9hIPhCGhs6jLuWS38wWmAiyHlDQ0jXk24 eg7Lb8IKkcLyOHLv5srPJVNvQV6Sq4qHdzHVX6Hq74igt9MiaJVzL/cWGinsx9Stzr+clo LZ7tdVYEfrzz9goGv0CT5aiVHpBcvWFnvReVNkUbKVrZH8SWM/g5cPCqECkrw93kNWsGcz SiO0DWjKroE58Vdob+nlHe+K+WJGEwFCcLPFa9VzWqZPI0um/Homld69x1BWV+xharg32L UAeg5lTi1R/lpPDmaASLOTLOcJEIPcbtWVMrnNJBrjMJOU9JaVfAzBO5EQ3Zow== 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 4P0qPJ05TmzV3Y; Mon, 23 Jan 2023 12:37:24 +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 30NCbNhf085031; Mon, 23 Jan 2023 12:37:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30NCbNRR085030; Mon, 23 Jan 2023 12:37:23 GMT (envelope-from git) Date: Mon, 23 Jan 2023 12:37:23 GMT Message-Id: <202301231237.30NCbNRR085030@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: ef2dd0213cb7 - stable/13 - Add bus_get_resource_list functions to the GICv3 driver List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ef2dd0213cb7b4fc4832f157db2403a469c4baa2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=ef2dd0213cb7b4fc4832f157db2403a469c4baa2 commit ef2dd0213cb7b4fc4832f157db2403a469c4baa2 Author: Andrew Turner AuthorDate: 2022-09-22 10:17:45 +0000 Commit: Andrew Turner CommitDate: 2023-01-23 12:36:27 +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 (cherry picked from commit 6fc6896c474483b3cf34b83fb85f8e9f8cabc8a1) --- sys/arm64/arm64/gic_v3_acpi.c | 20 +++++++++++++++++--- sys/arm64/arm64/gic_v3_fdt.c | 31 ++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/sys/arm64/arm64/gic_v3_acpi.c b/sys/arm64/arm64/gic_v3_acpi.c index 6a090baffacf..9aaf9a783868 100644 --- a/sys/arm64/arm64/gic_v3_acpi.c +++ b/sys/arm64/arm64/gic_v3_acpi.c @@ -57,6 +57,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); @@ -69,6 +70,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 @@ -417,19 +419,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); @@ -441,3 +444,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 6aa8018de56e..16539b50fd09 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), @@ -213,10 +215,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 = &di->di_rl; + struct resource_list *rl; int retval = 0; + 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); @@ -237,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); @@ -356,3 +362,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); +}