From patchwork Thu Jan 10 12:03:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 210983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 40F4C2C0328 for ; Thu, 10 Jan 2013 23:00:06 +1100 (EST) Received: from localhost ([::1]:53820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtGnh-0006KG-Pm for incoming@patchwork.ozlabs.org; Thu, 10 Jan 2013 07:00:01 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtGnZ-0006KB-Ip for qemu-devel@nongnu.org; Thu, 10 Jan 2013 06:59:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtGnW-0002gH-V7 for qemu-devel@nongnu.org; Thu, 10 Jan 2013 06:59:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtGnW-0002g9-Nk for qemu-devel@nongnu.org; Thu, 10 Jan 2013 06:59:50 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0ABxmJs002102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Jan 2013 06:59:48 -0500 Received: from redhat.com (vpn1-5-222.ams2.redhat.com [10.36.5.222]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r0ABxju2030440; Thu, 10 Jan 2013 06:59:46 -0500 Date: Thu, 10 Jan 2013 14:03:39 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Bill Paul Message-ID: <20130110120339.GA21794@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Anthony Liguori , Jason Wang , Stefan Hajnoczi , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] e1000: document ICS read behaviour 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add code comment to clarify the reason we set ICS with ICR: the reason was previously undocumented and git log (commit b1332393cdd7d023de8f1f8aa136ee7866a18968) confused rather than clarified the comments. Digging in the mailing list archives gives the real reason https://lists.gnu.org/archive/html/qemu-devel/2009-06/msg00401.html Add code comment with an explanation supplied by Bill Paul. Signed-off-by: Michael S. Tsirkin --- hw/e1000.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/e1000.c b/hw/e1000.c index 92fb00a..d10119c 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -230,7 +230,17 @@ set_interrupt_cause(E1000State *s, int index, uint32_t val) val |= E1000_ICR_INT_ASSERTED; } s->mac_reg[ICR] = val; + + /* + * Make sure ICR and ICS registers have the same value. + * The spec says that the ICS register is write-only. However in practice, + * on real hardware ICS is readable, and for reads it has the same value as + * ICR (except that ICS does not have the clear on read behaviour of ICR). + * + * The VxWorks PRO/1000 driver uses this behaviour. + */ s->mac_reg[ICS] = val; + qemu_set_irq(s->dev.irq[0], (s->mac_reg[IMS] & s->mac_reg[ICR]) != 0); }