From patchwork Mon Jan 13 07:43:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 23152 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f198.google.com (mail-gg0-f198.google.com [209.85.161.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9C8C3216D9 for ; Mon, 13 Jan 2014 08:26:43 +0000 (UTC) Received: by mail-gg0-f198.google.com with SMTP id x14sf3849514ggx.9 for ; Mon, 13 Jan 2014 00:26:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=l9ZMVPcxix+PnAZ1uBxaV0T3siJRXYB59nPKkQXPbMY=; b=Yp5Nq5S+EAcYTlBxXQaP0Vr4pKr7TCgDSmFxgpc7sQONF/5CguHAWInx0/NjL6vnp+ g1zAcrdrErKxsZo6chV8tU4jMOlGkkHrW6aZ4rLpwt79bfVbQRarMjQk+FdEvVCS5pDB etsBC4osCpfGrNcE3z0Tb0xVTzKDPeAhfJS3jG+cqrTYfr6ILEg9ozuQiQBpGHc3AaEa saoE8p4s5Xs6touoqlk05/tlMjFVUktR3/67k7cmFJwCbFQFpnFseEoR2HOZkgVj2Txp /hoFQR5Q1LH1UCQZ/+FIexVnZyITY2iKOxOxtHAgIjz6Xl0Ua+LmVPVnUelUvHrAZXCM Iyng== X-Gm-Message-State: ALoCoQlFdgfa8OaulNHwz28TRLE4Ah4uhxrrPF9P3Yf1/MU9UNRDPLxpnzuKltEnYaI8WjtWt/WM X-Received: by 10.236.128.72 with SMTP id e48mr7787727yhi.20.1389601602867; Mon, 13 Jan 2014 00:26:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.128.200 with SMTP id nq8ls2411335qeb.95.gmail; Mon, 13 Jan 2014 00:26:42 -0800 (PST) X-Received: by 10.58.155.162 with SMTP id vx2mr906198veb.46.1389601602791; Mon, 13 Jan 2014 00:26:42 -0800 (PST) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by mx.google.com with ESMTPS id yt16si143225vcb.117.2014.01.13.00.26.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Jan 2014 00:26:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.44; Received: by mail-vb0-f44.google.com with SMTP id x8so4677402vbf.17 for ; Mon, 13 Jan 2014 00:26:42 -0800 (PST) X-Received: by 10.58.116.239 with SMTP id jz15mr1602694veb.26.1389601602715; Mon, 13 Jan 2014 00:26:42 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp111719ved; Mon, 13 Jan 2014 00:26:42 -0800 (PST) X-Received: by 10.224.8.72 with SMTP id g8mr36866936qag.83.1389601602126; Mon, 13 Jan 2014 00:26:42 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t5si2876344qak.80.2014.01.13.00.26.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 13 Jan 2014 00:26:42 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:40940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2cDF-0001lB-EV for patch@linaro.org; Mon, 13 Jan 2014 02:45:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2cBg-0007YT-Mz for qemu-devel@nongnu.org; Mon, 13 Jan 2014 02:44:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2cBb-00056d-Hf for qemu-devel@nongnu.org; Mon, 13 Jan 2014 02:43:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2cBb-00056W-9r for qemu-devel@nongnu.org; Mon, 13 Jan 2014 02:43:51 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0D7hneB025485 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Jan 2014 02:43:50 -0500 Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0D7hkxQ031573; Mon, 13 Jan 2014 02:43:48 -0500 From: Stefan Hajnoczi To: Date: Mon, 13 Jan 2014 15:43:18 +0800 Message-Id: <1389598998-19897-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1389598998-19897-1-git-send-email-stefanha@redhat.com> References: <1389598998-19897-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori Subject: [Qemu-devel] [PULL 3/3] Fix lan9118 buffer length handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Roy Franz The 9118 ethernet controller supports transmission of multi-buffer packets with arbitrary byte alignment of the start and end bytes. All writes to the packet fifo are 32 bits, so the controller discards bytes at the beginning and end of each buffer based on the 'Data start offset' and 'Buffer size' of the TX command 'A' format. This patch uses the provided buffer length to limit the bytes transmitted. Previously all the bytes of the last 32-bit word written to the TX fifo were added to the internal transmit buffer structure resulting in more bytes being transmitted than were submitted to the hardware in the command. This resulted in extra bytes being inserted into the middle of multi-buffer packets when the non-final buffers had non-32bit aligned ending addresses. Signed-off-by: Roy Franz Reviewed-by: Peter Crosthwaite Signed-off-by: Stefan Hajnoczi --- hw/net/lan9118.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index bb0c503..e528290 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -763,7 +763,7 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val) if (s->txp->buffer_size <= 0 && s->txp->pad != 0) { s->txp->pad--; } else { - n = 4; + n = MIN(4, s->txp->buffer_size + s->txp->offset); while (s->txp->offset) { val >>= 8; n--;