From nobody Mon Apr 24 11:34:15 2023 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 4Q4jhV0lR9z46j8q; Mon, 24 Apr 2023 11:34:18 +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 4Q4jhS2WBpz4TWS; Mon, 24 Apr 2023 11:34:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682336056; 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=5PmfJpCMCB70V8B3T68+siaq+LEJC4in7nOk/LXAEy8=; b=hM4iwR47S2mhxJMccuq+zDEmR3Henm7V8g4AhdeA7tHgBGC0M1PwExTNeENdAVB1VKC2zy L8ikETA08mb52ztPtRI9m3y9gJcYce9797H4fVVH7AOWcA9tUhGkyXdbh+NmRTKf/5ZZ2W MIYkYr2o+kAuS8SOK2kGyOOzdeYMv7fTT0/W6d6rfytzt0siq8chT+U2biHY3EVp4bBCz8 8M7nBEbKoqFY3GtvTXJp9mU3ZwA8JsJB42YbABLKZCoOLG2T1vhYaFON+/6uG+F8yimZ0z cc94tkeyhtDR546sqkK0TqvJL/2TQt05yP9d5C+6WOStUqlnEjjojbtBp9Xt/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682336057; 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=5PmfJpCMCB70V8B3T68+siaq+LEJC4in7nOk/LXAEy8=; b=RfLrXGDYo6FOcBlfgt4JJHaqfWBj5tLOgM92micop2TnXe/eWuu7BrL4V1WWMT37QfRDb2 KIZHz6yTBYIojereIBJHDyvuLnwJ199IQJpV9vwQcjkQWqKPpFr6cijoCuYjCSzsY8A+Zj jYdjcMCixzauWY2N/9LvcbWqxPhlSnjPCDsc+M6x/pL9Hrgng48Z0WV2uOS9ymsTeibqZ2 gUlVqdV7BfjMkOS2qsnLKjFumKDIMdJGDNNn4XGKE3NcEk5j5jzTOICv53VG4dlj6aq6MX mf38wvDPWiq1xLUfIMGK2spmcoXWSBCbq6vPrDW3ll3dm8xilKWgXor1LBuYkA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682336057; a=rsa-sha256; cv=none; b=t2P63bMbJPj6wiznvthTpgJnw3FsMkBQtHCGb3eDAI9LxpJZLg/W3NUMpbwdPJ11pLDQDT 9rb1kO/rxOaeB1R3iyMyiBUS5jzR/yg0+bzg2fYVLsG+uu4I+xOA6wkf2JAsAfko/2DF77 pWZ7dtFVcVQNElPhD3tOMqlMNvl2W55s21PhUIG/UfCt+lDRwQlwabpSzWyPeRHHk/4Iux FyPo8krfwM290xfFjvsYdl7/+56S73wjkZ5b4SgacIkoLs7rMfzo/v6DPA1LSe8IFIaVwu GW1+QZZ8krGofDMX2NlkVT9h4UsfgUiv87FY1iXKH+dTjI+m2QDZ8ZR0WQJLEg== 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 4Q4jhR5HVDzNpp; Mon, 24 Apr 2023 11:34:15 +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 33OBYFjV071188; Mon, 24 Apr 2023 11:34:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33OBYFkk071187; Mon, 24 Apr 2023 11:34:15 GMT (envelope-from git) Date: Mon, 24 Apr 2023 11:34:15 GMT Message-Id: <202304241134.33OBYFkk071187@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: 8bc94f256e17 - main - Remove redundant data from pci host generic 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: 8bc94f256e171bbd69e828ee587298348af82cdd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=8bc94f256e171bbd69e828ee587298348af82cdd commit 8bc94f256e171bbd69e828ee587298348af82cdd Author: Andrew Turner AuthorDate: 2023-04-24 11:11:29 +0000 Commit: Andrew Turner CommitDate: 2023-04-24 11:33:50 +0000 Remove redundant data from pci host generic The bus tag and handle fields are already stored in the resource. Use this with the bus_read/bus_write helper macros. Sponsored by: Arm Ltd --- sys/arm/broadcom/bcm2835/bcm2838_pci.c | 28 ++++++++-------------------- sys/dev/pci/controller/pci_n1sdp.c | 8 ++++---- sys/dev/pci/pci_host_generic.c | 24 ++++++------------------ sys/dev/pci/pci_host_generic.h | 2 -- 4 files changed, 18 insertions(+), 44 deletions(-) diff --git a/sys/arm/broadcom/bcm2835/bcm2838_pci.c b/sys/arm/broadcom/bcm2835/bcm2838_pci.c index c30eb73fc1b0..c8bcc76bd8a3 100644 --- a/sys/arm/broadcom/bcm2835/bcm2838_pci.c +++ b/sys/arm/broadcom/bcm2835/bcm2838_pci.c @@ -168,16 +168,14 @@ static void bcm_pcib_set_reg(struct bcm_pcib_softc *sc, uint32_t reg, uint32_t val) { - bus_space_write_4(sc->base.base.bst, sc->base.base.bsh, reg, - htole32(val)); + bus_write_4(sc->base.base.res, reg, htole32(val)); } static uint32_t bcm_pcib_read_reg(struct bcm_pcib_softc *sc, uint32_t reg) { - return (le32toh(bus_space_read_4(sc->base.base.bst, sc->base.base.bsh, - reg))); + return (le32toh(bus_read_4(sc->base.base.res, reg))); } static void @@ -318,8 +316,6 @@ bcm_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, int bytes) { struct bcm_pcib_softc *sc; - bus_space_handle_t h; - bus_space_tag_t t; bus_addr_t offset; uint32_t data; @@ -330,18 +326,15 @@ bcm_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, mtx_lock(&sc->config_mtx); offset = bcm_get_offset_and_prepare_config(sc, bus, slot, func, reg); - t = sc->base.base.bst; - h = sc->base.base.bsh; - switch (bytes) { case 1: - data = bus_space_read_1(t, h, offset); + data = bus_read_1(sc->base.base.res, offset); break; case 2: - data = le16toh(bus_space_read_2(t, h, offset)); + data = le16toh(bus_read_2(sc->base.base.res, offset)); break; case 4: - data = le32toh(bus_space_read_4(t, h, offset)); + data = le32toh(bus_read_4(sc->base.base.res, offset)); break; default: data = ~0U; @@ -357,8 +350,6 @@ bcm_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, uint32_t val, int bytes) { struct bcm_pcib_softc *sc; - bus_space_handle_t h; - bus_space_tag_t t; uint32_t offset; sc = device_get_softc(dev); @@ -368,18 +359,15 @@ bcm_pcib_write_config(device_t dev, u_int bus, u_int slot, mtx_lock(&sc->config_mtx); offset = bcm_get_offset_and_prepare_config(sc, bus, slot, func, reg); - t = sc->base.base.bst; - h = sc->base.base.bsh; - switch (bytes) { case 1: - bus_space_write_1(t, h, offset, val); + bus_write_1(sc->base.base.res, offset, val); break; case 2: - bus_space_write_2(t, h, offset, htole16(val)); + bus_write_2(sc->base.base.res, offset, htole16(val)); break; case 4: - bus_space_write_4(t, h, offset, htole32(val)); + bus_write_4(sc->base.base.res, offset, htole32(val)); break; default: break; diff --git a/sys/dev/pci/controller/pci_n1sdp.c b/sys/dev/pci/controller/pci_n1sdp.c index b153ebe4ee4c..9e6ceb572c45 100644 --- a/sys/dev/pci/controller/pci_n1sdp.c +++ b/sys/dev/pci/controller/pci_n1sdp.c @@ -113,8 +113,8 @@ n1sdp_init(struct generic_pcie_n1sdp_softc *sc) shared_data = (struct pcie_discovery_data *)vaddr; paddr_rc = (vm_offset_t)shared_data->rc_base_addr; - error = bus_space_map(sc->acpi.base.bst, paddr_rc, PCI_CFG_SPACE_SIZE, - 0, &sc->n1_bsh); + error = bus_space_map(sc->acpi.base.res->r_bustag, paddr_rc, + PCI_CFG_SPACE_SIZE, 0, &sc->n1_bsh); if (error != 0) goto out_pmap; @@ -245,10 +245,10 @@ n1sdp_get_bus_space(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, return (EINVAL); *bsh = sc->n1_bsh; } else { - *bsh = sc->acpi.base.bsh; + *bsh = rman_get_bushandle(sc->acpi.base.res); } - *bst = sc->acpi.base.bst; + *bst = rman_get_bustag(sc->acpi.base.res); *offset = PCIE_ADDR_OFFSET(bus - sc->acpi.base.bus_start, slot, func, reg); diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index ca74b0c650c3..7480d02b6b5d 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -126,9 +126,6 @@ pci_host_generic_core_attach(device_t dev) } rman_set_mapping(sc->res, &map); #endif - - sc->bst = rman_get_bustag(sc->res); - sc->bsh = rman_get_bushandle(sc->res); } sc->has_pmem = false; @@ -233,8 +230,6 @@ generic_pcie_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, int bytes) { struct generic_pcie_core_softc *sc; - bus_space_handle_t h; - bus_space_tag_t t; uint64_t offset; uint32_t data; @@ -248,18 +243,16 @@ generic_pcie_read_config(device_t dev, u_int bus, u_int slot, return (~0U); offset = PCIE_ADDR_OFFSET(bus - sc->bus_start, slot, func, reg); - t = sc->bst; - h = sc->bsh; switch (bytes) { case 1: - data = bus_space_read_1(t, h, offset); + data = bus_read_1(sc->res, offset); break; case 2: - data = le16toh(bus_space_read_2(t, h, offset)); + data = le16toh(bus_read_2(sc->res, offset)); break; case 4: - data = le32toh(bus_space_read_4(t, h, offset)); + data = le32toh(bus_read_4(sc->res, offset)); break; default: return (~0U); @@ -273,8 +266,6 @@ generic_pcie_write_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, uint32_t val, int bytes) { struct generic_pcie_core_softc *sc; - bus_space_handle_t h; - bus_space_tag_t t; uint64_t offset; sc = device_get_softc(dev); @@ -286,18 +277,15 @@ generic_pcie_write_config(device_t dev, u_int bus, u_int slot, offset = PCIE_ADDR_OFFSET(bus - sc->bus_start, slot, func, reg); - t = sc->bst; - h = sc->bsh; - switch (bytes) { case 1: - bus_space_write_1(t, h, offset, val); + bus_write_1(sc->res, offset, val); break; case 2: - bus_space_write_2(t, h, offset, htole16(val)); + bus_write_2(sc->res, offset, htole16(val)); break; case 4: - bus_space_write_4(t, h, offset, htole32(val)); + bus_write_4(sc->res, offset, htole32(val)); break; default: return; diff --git a/sys/dev/pci/pci_host_generic.h b/sys/dev/pci/pci_host_generic.h index b3242c8bdaf5..f8c321799f08 100644 --- a/sys/dev/pci/pci_host_generic.h +++ b/sys/dev/pci/pci_host_generic.h @@ -80,8 +80,6 @@ struct generic_pcie_core_softc { int bus_start; int bus_end; int ecam; - bus_space_tag_t bst; - bus_space_handle_t bsh; device_t dev; bus_space_handle_t ioh; bus_dma_tag_t dmat;