From 5df96cb690168d750ab0fafffd11fb51624374d2 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Tue, 2 Dec 2014 06:07:41 -0500 Subject: mem: Remove redundant Packet::allocate calls This patch cleans up the packet memory allocation confusion. The data is always allocated at the requesting side, when a packet is created (or copied), and there is never a need for any device to allocate any space if it is merely responding to a paket. This behaviour is in line with how SystemC and TLM works as well, thus increasing interoperability, and matching established conventions. The redundant calls to Packet::allocate are removed, and the checks in the function are tightened up to make sure data is only ever allocated once. There are still some oddities in the packet copy constructor where we copy the data pointer if it is static (without ownership), and allocate new space if the data is dynamic (with ownership). The latter is being worked on further in a follow-on patch. --- src/dev/virtio/base.cc | 2 -- src/dev/virtio/pci.cc | 4 ---- 2 files changed, 6 deletions(-) (limited to 'src/dev/virtio') diff --git a/src/dev/virtio/base.cc b/src/dev/virtio/base.cc index 44cce65c4..06c6e3452 100644 --- a/src/dev/virtio/base.cc +++ b/src/dev/virtio/base.cc @@ -422,7 +422,6 @@ void VirtIODeviceBase::readConfigBlob(PacketPtr pkt, Addr cfgOffset, const uint8_t *cfg) { const unsigned size(pkt->getSize()); - pkt->allocate(); if (cfgOffset + size > configSize) panic("Config read out of bounds.\n"); @@ -434,7 +433,6 @@ void VirtIODeviceBase::writeConfigBlob(PacketPtr pkt, Addr cfgOffset, uint8_t *cfg) { const unsigned size(pkt->getSize()); - pkt->allocate(); if (cfgOffset + size > configSize) panic("Config write out of bounds.\n"); diff --git a/src/dev/virtio/pci.cc b/src/dev/virtio/pci.cc index 1f99d7fe4..c77b61934 100644 --- a/src/dev/virtio/pci.cc +++ b/src/dev/virtio/pci.cc @@ -75,8 +75,6 @@ PciVirtIO::read(PacketPtr pkt) return 0; } - pkt->allocate(); - switch(offset) { case OFF_DEVICE_FEATURES: DPRINTF(VIOPci, " DEVICE_FEATURES request\n"); @@ -153,8 +151,6 @@ PciVirtIO::write(PacketPtr pkt) return 0; } - pkt->allocate(); - switch(offset) { case OFF_DEVICE_FEATURES: warn("Guest tried to write device features."); -- cgit v1.2.3