Received: from eggs.gnu.org ([140.186.70.92]:53809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM7mw-0005oP-Nv for qemu-devel@nongnu.org; Thu, 03 Nov 2011 20:37:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RM7mu-0008Kf-DH for qemu-devel@nongnu.org; Thu, 03 Nov 2011 20:37:42 -0400 Received: from ozlabs.org ([203.10.76.45]:42471) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM7mt-0008KT-SU for qemu-devel@nongnu.org; Thu, 03 Nov 2011 20:37:40 -0400 Date: Fri, 4 Nov 2011 11:28:03 +1100 From: David Gibson Message-ID: <20111104002803.GB4713@truffala.fritz.box> References: <1320041218-30487-1-git-send-email-david@gibson.dropbear.id.au> <1320041218-30487-6-git-send-email-david@gibson.dropbear.id.au> <20111102071634.GA5613@redhat.com> <20111103051634.GQ5379@truffala.fritz.box> <20111103122544.GH18296@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111103122544.GH18296@redhat.com> Subject: Re: [Qemu-devel] [PATCH 05/14] eepro100: Use PCI DMA stub functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: joerg.roedel@amd.com, agraf@suse.de, qemu-devel@nongnu.org, avi@redhat.com, eduard.munteanu@linux360.ro, rth@twiddle.net On Thu, Nov 03, 2011 at 02:25:45PM +0200, Michael S. Tsirkin wrote: > On Thu, Nov 03, 2011 at 04:16:34PM +1100, David Gibson wrote: > > On Wed, Nov 02, 2011 at 09:16:34AM +0200, Michael S. Tsirkin wrote: > > > On Mon, Oct 31, 2011 at 05:06:49PM +1100, David Gibson wrote: > > > > From: Eduard - Gabriel Munteanu > > [snip] > > > > @@ -744,21 +713,26 @@ static void dump_statistics(EEPRO100State * s) > > > > * values which really matter. > > > > * Number of data should check configuration!!! > > > > */ > > > > - cpu_physical_memory_write(s->statsaddr, &s->statistics, s->stats_size); > > > > - e100_stl_le_phys(s->statsaddr + 0, s->statistics.tx_good_frames); > > > > - e100_stl_le_phys(s->statsaddr + 36, s->statistics.rx_good_frames); > > > > - e100_stl_le_phys(s->statsaddr + 48, s->statistics.rx_resource_errors); > > > > - e100_stl_le_phys(s->statsaddr + 60, s->statistics.rx_short_frame_errors); > > > > + pci_dma_write(&s->dev, s->statsaddr, > > > > + (uint8_t *) &s->statistics, s->stats_size); > > > > + stl_le_pci_dma(&s->dev, s->statsaddr + 0, > > > > + s->statistics.tx_good_frames); > > > > + stl_le_pci_dma(&s->dev, s->statsaddr + 36, > > > > + s->statistics.rx_good_frames); > > > > + stl_le_pci_dma(&s->dev, s->statsaddr + 48, > > > > + s->statistics.rx_resource_errors); > > > > + stl_le_pci_dma(&s->dev, s->statsaddr + 60, > > > > + s->statistics.rx_short_frame_errors); > > > > > > This might introduce a bug: stlXX APIs assume aligned addresses, > > > an address in statsaddr is user-controlled so I'm not sure > > > it's always aligned. > > > > > > Why isn't the patch simply replacing cpu_physical_memory_read > > > with pci_XXX ? Any cleanups should be done separately. > > > > Because it seemed like a good idea at the time. When I first wrote > > this, the possibility of unaligned addresses wasn't obvious to me. > > So, I'm working on fixing this now. I can take one of two approaches: > > > > - Simply revert this part of the change, reinstate the e100_stl > > functions as calling into dma_write(). > > > > - Alter the stX_dma() functions to work for unaligned addresses (by > > falling back to dma_rw() in that case). This is a little more > > involved but might make device writing safer in future. > > Yes but then we lose the atomicity guarantee. So this might > still result in subtle emulation bugs. Sorry, I should have been clearer - I was planning to fall back to dma_rw() *only* for unaligned addresses. Aligned addresses would still have the atomicity guarantee. > > Anthony, Michael, any preferred direction here? > > For 1.0 I'd go for option 1 as the simplest. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson