From patchwork Fri Jan 29 22:35:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 8167791 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 095CE9F96D for ; Fri, 29 Jan 2016 22:35:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 739E92038E for ; Fri, 29 Jan 2016 22:35:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9E3020396 for ; Fri, 29 Jan 2016 22:35:51 +0000 (UTC) Received: from localhost ([::1]:36732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPHdu-0002nM-V8 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Jan 2016 17:35:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPHdk-0002mF-Si for qemu-devel@nongnu.org; Fri, 29 Jan 2016 17:35:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPHdk-0002qC-1V for qemu-devel@nongnu.org; Fri, 29 Jan 2016 17:35:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPHde-0002mZ-OX; Fri, 29 Jan 2016 17:35:34 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 19E64C0B89E7; Fri, 29 Jan 2016 22:35:34 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0TMZWfE027860; Fri, 29 Jan 2016 17:35:33 -0500 From: John Snow To: qemu-block@nongnu.org Date: Fri, 29 Jan 2016 17:35:32 -0500 Message-Id: <1454106932-17236-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: John Snow , pbonzini@redhat.com, hpoussin@reactos.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] fdc: fix detection under Linux 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Accidentally, I removed a "feature" where empty drives had geometry values applied to them, which allows seek on empty drives to work "by accident," as QEMU actually tries to disallow that. Seeks on empty drives should work, though, but the easiest thing is to restore the misfeature where empty drives have non-zero geometries applied. Document the hack accordingly. Signed-off-by: John Snow Reviewed-by: Eric Blake Tested-by: Hervé Poussineau --- hw/block/fdc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index e3b0e1e..36dd23b 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -180,6 +180,21 @@ typedef struct FDrive { static FloppyDriveType get_fallback_drive_type(FDrive *drv); +/* Hack: FD_SEEK is expected to work on empty drives. However, QEMU + * currently goes through some pains to keep seeks within the bounds + * established by last_sect and max_track. Correcting this is difficult, + * as refactoring FDC code tends to expose nasty bugs in the Linux kernel. + * + * For now: allow empty drives to have large bounds so we can seek around, + * with the understanding that when a diskette is inserted, the bounds will + * properly tighten to match the geometry of that inserted medium. + */ +static void fd_empty_seek_hack(FDrive *drv) +{ + drv->last_sect = 0xFF; + drv->max_track = 0xFF; +} + static void fd_init(FDrive *drv) { /* Drive */ @@ -393,6 +408,7 @@ static void fd_revalidate(FDrive *drv) if (!drv->media_inserted) { FLOPPY_DPRINTF("No disk in drive\n"); drv->disk = FLOPPY_DRIVE_TYPE_NONE; + fd_empty_seek_hack(drv); } else if (!drv->media_validated) { rc = pick_geometry(drv); if (rc) {