From patchwork Wed Jan 12 11:20:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 78579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8B086B6F14 for ; Thu, 13 Jan 2011 00:46:50 +1100 (EST) Received: from localhost ([127.0.0.1]:48466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PczkY-0004Ph-OW for incoming@patchwork.ozlabs.org; Wed, 12 Jan 2011 07:24:26 -0500 Received: from [140.186.70.92] (port=56172 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pcyl7-0006DX-Hm for qemu-devel@nongnu.org; Wed, 12 Jan 2011 06:21:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pcyl5-0001cG-7q for qemu-devel@nongnu.org; Wed, 12 Jan 2011 06:20:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pcyl4-0001bq-VB for qemu-devel@nongnu.org; Wed, 12 Jan 2011 06:20:55 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0CBKsfC009275 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 Jan 2011 06:20:54 -0500 Received: from rincewind.home.kraxel.org (vpn2-8-125.ams2.redhat.com [10.36.8.125]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0CBKPcM029855; Wed, 12 Jan 2011 06:20:53 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 5A22C4162E; Wed, 12 Jan 2011 12:20:16 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 12 Jan 2011 12:20:10 +0100 Message-Id: <1294831214-4499-29-git-send-email-kraxel@redhat.com> In-Reply-To: <1294831214-4499-1-git-send-email-kraxel@redhat.com> References: <1294831214-4499-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v4 28/32] usb storage: handle long responses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The scsi layer may return us more data than the guests wants to have. Handle this by just ignoring the extra bytes and calling the {read,write}_data callback to finish the request. Seen happening in real life with some extended inquiry command. With this patch applied the linux kernel stops reseting the device once at boot. Signed-off-by: Gerd Hoffmann --- hw/usb-msd.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 28c12dd..729d96c 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -187,7 +187,7 @@ static void usb_msd_copy_data(MSDState *s) s->usb_buf += len; s->scsi_buf += len; s->data_len -= len; - if (s->scsi_len == 0) { + if (s->scsi_len == 0 || s->data_len == 0) { if (s->mode == USB_MSDM_DATAIN) { s->scsi_dev->info->read_data(s->scsi_dev, s->tag); } else if (s->mode == USB_MSDM_DATAOUT) { @@ -434,7 +434,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) break; case USB_MSDM_DATAIN: - DPRINTF("Data in %d/%d\n", len, s->data_len); + DPRINTF("Data in %d/%d, scsi_len %d\n", len, s->data_len, s->scsi_len); if (len > s->data_len) len = s->data_len; s->usb_buf = data;