From: Nikos Nikoleris Date: Mon, 4 Jun 2018 15:20:47 +0000 (+0100) Subject: mem: Use address range to find the destination port in the xbar X-Git-Tag: v19.0.0.0~2039 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6cb46ba839b2bf535e294fde9179e2aff6095814;p=gem5.git mem: Use address range to find the destination port in the xbar Previously the xbar used the start address to lookup the port map and determine the right destination of an incoming packet. This change uses the full address range to correctly determine the right master. Change-Id: I5118712c43ae65aba64e71bf030bca5c99770bdd Reviewed-on: https://gem5-review.googlesource.com/11117 Reviewed-by: Jason Lowe-Power Maintainer: Nikos Nikoleris --- diff --git a/src/mem/coherent_xbar.cc b/src/mem/coherent_xbar.cc index 872ee5c0d..d46f3893f 100644 --- a/src/mem/coherent_xbar.cc +++ b/src/mem/coherent_xbar.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 ARM Limited + * Copyright (c) 2011-2018 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -151,8 +151,9 @@ CoherentXBar::recvTimingReq(PacketPtr pkt, PortID slave_port_id) // and the cache responding flag should always be the same assert(is_express_snoop == cache_responding); - // determine the destination based on the address - PortID master_port_id = findPort(pkt->getAddr()); + // determine the destination based on the destination address range + AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize()); + PortID master_port_id = findPort(addr_range); // test if the crossbar should be considered occupied for the current // port, and exclude express snoops from the check @@ -551,7 +552,9 @@ CoherentXBar::recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id) // device responsible for the address range something is // wrong, hence there is nothing further to do as the packet // would be going back to where it came from - assert(master_port_id == findPort(pkt->getAddr())); + AddrRange addr_range M5_VAR_USED = + RangeSize(pkt->getAddr(), pkt->getSize()); + assert(findPort(addr_range) == master_port_id); } bool @@ -781,7 +784,8 @@ CoherentXBar::recvAtomic(PacketPtr pkt, PortID slave_port_id) // even if we had a snoop response, we must continue and also // perform the actual request at the destination - PortID master_port_id = findPort(pkt->getAddr()); + AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize()); + PortID master_port_id = findPort(addr_range); if (sink_packet) { DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__, @@ -1005,7 +1009,7 @@ CoherentXBar::recvFunctional(PacketPtr pkt, PortID slave_port_id) } } - PortID dest_id = findPort(pkt->getAddr()); + PortID dest_id = findPort(RangeSize(pkt->getAddr(), pkt->getSize())); masterPorts[dest_id]->sendFunctional(pkt); } diff --git a/src/mem/noncoherent_xbar.cc b/src/mem/noncoherent_xbar.cc index 3ff991fdb..7bd04cb3e 100644 --- a/src/mem/noncoherent_xbar.cc +++ b/src/mem/noncoherent_xbar.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 ARM Limited + * Copyright (c) 2011-2015, 2018 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -108,7 +108,8 @@ NoncoherentXBar::recvTimingReq(PacketPtr pkt, PortID slave_port_id) assert(!pkt->isExpressSnoop()); // determine the destination based on the address - PortID master_port_id = findPort(pkt->getAddr()); + AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize()); + PortID master_port_id = findPort(addr_range); // test if the layer should be considered occupied for the current // port @@ -253,7 +254,8 @@ NoncoherentXBar::recvAtomic(PacketPtr pkt, PortID slave_port_id) unsigned int pkt_cmd = pkt->cmdToIndex(); // determine the destination port - PortID master_port_id = findPort(pkt->getAddr()); + AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize()); + PortID master_port_id = findPort(addr_range); // stats updates for the request pktCount[slave_port_id][master_port_id]++; @@ -303,7 +305,8 @@ NoncoherentXBar::recvFunctional(PacketPtr pkt, PortID slave_port_id) } // determine the destination port - PortID dest_id = findPort(pkt->getAddr()); + AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize()); + PortID dest_id = findPort(addr_range); // forward the request to the appropriate destination masterPorts[dest_id]->sendFunctional(pkt); diff --git a/src/mem/xbar.cc b/src/mem/xbar.cc index c3a5c83fe..b139cdc9b 100644 --- a/src/mem/xbar.cc +++ b/src/mem/xbar.cc @@ -321,34 +321,34 @@ BaseXBar::Layer::recvRetry() } PortID -BaseXBar::findPort(Addr addr) +BaseXBar::findPort(AddrRange addr_range) { // we should never see any address lookups before we've got the // ranges of all connected slave modules assert(gotAllAddrRanges); // Check the address map interval tree - auto i = portMap.contains(addr); + auto i = portMap.contains(addr_range); if (i != portMap.end()) { return i->second; } // Check if this matches the default range if (useDefaultRange) { - if (defaultRange.contains(addr)) { - DPRINTF(AddrRanges, " found addr %#llx on default\n", - addr); + if (addr_range.isSubset(defaultRange)) { + DPRINTF(AddrRanges, " found addr %s on default\n", + addr_range.to_string()); return defaultPortID; } } else if (defaultPortID != InvalidPortID) { - DPRINTF(AddrRanges, "Unable to find destination for addr %#llx, " - "will use default port\n", addr); + DPRINTF(AddrRanges, "Unable to find destination for %s, " + "will use default port\n", addr_range.to_string()); return defaultPortID; } // we should use the range for the default port and it did not // match, or the default port is not set - fatal("Unable to find destination for addr %#llx on %s\n", addr, + fatal("Unable to find destination for %s on %s\n", addr_range.to_string(), name()); } diff --git a/src/mem/xbar.hh b/src/mem/xbar.hh index 2b7e7ed48..abe2a1096 100644 --- a/src/mem/xbar.hh +++ b/src/mem/xbar.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 ARM Limited + * Copyright (c) 2011-2015, 2018 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -342,13 +342,14 @@ class BaseXBar : public MemObject */ virtual void recvRangeChange(PortID master_port_id); - /** Find which port connected to this crossbar (if any) should be - * given a packet with this address. + /** + * Find which port connected to this crossbar (if any) should be + * given a packet with this address range. * - * @param addr Address to find port for. + * @param addr_range Address range to find port for. * @return id of port that the packet should be sent out of. */ - PortID findPort(Addr addr); + PortID findPort(AddrRange addr_range); /** * Return the address ranges the crossbar is responsible for.