From patchwork Fri Feb 15 04:51:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 220626 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 36BD52C0085 for ; Fri, 15 Feb 2013 15:52:53 +1100 (EST) Received: from localhost ([::1]:58225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6DI3-00065g-Ai for incoming@patchwork.ozlabs.org; Thu, 14 Feb 2013 23:52:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6DHi-0005nS-KG for qemu-devel@nongnu.org; Thu, 14 Feb 2013 23:52:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6DHe-0004XR-6B for qemu-devel@nongnu.org; Thu, 14 Feb 2013 23:52:30 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:64640) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6DHd-0004XE-Pu for qemu-devel@nongnu.org; Thu, 14 Feb 2013 23:52:26 -0500 Received: by mail-pa0-f44.google.com with SMTP id kp1so1629967pab.17 for ; Thu, 14 Feb 2013 20:52:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references:x-gm-message-state; bh=CI77zP/fyMusFkwxm7x95ufp+cwVBEMkRctW3D3APno=; b=CFwKw0iSN+uHIfOplryP0TGv1OoEaS/8anols8ZMPLW/fR/YpP4GQMqE9pBOieqwpn Rs30NnuB66T1f4FTN+qKpO99pXgye636oF3078AAPCrBp9znQMO+SSoYqCID2PmCnEoR o+y+nxRCAr84EEn43DL+lb7UUg4qJjf4R4JdW0PNJ0pS272q0U65k7Tou2SJUfhonLeS g2Jc2RAeKrWKx8KYnYqSABs24+BMKuZ+/y9i9vjxZgOQMcvI1C+Kl9T6uo+FxSxbMXsl VKNwXw5MYZUMMHlQaUW+oAH3wmbz3IaUXAYDRE6PIxEMsLduWPijqk8jZfcaW64khK5f +8ng== X-Received: by 10.68.244.162 with SMTP id xh2mr3009869pbc.55.1360903945019; Thu, 14 Feb 2013 20:52:25 -0800 (PST) Received: from localhost ([101.169.162.247]) by mx.google.com with ESMTPS id b9sm3468067pba.6.2013.02.14.20.52.20 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Thu, 14 Feb 2013 20:52:23 -0800 (PST) From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Fri, 15 Feb 2013 14:51:38 +1000 Message-Id: X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQn6BjbgwDJhjclEh3TTNqZw6xb779ZLgkRk39VESavsRNOiudwXCE0c+1EhCXzkOUFg45y5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.44 Cc: edgar.iglesias@gmail.com, Peter Crosthwaite , peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH v1 3/5] cadence_gem: fix interrupt events 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 Bits in the ISR were continually mirroring their corresponding TX/RX SR bits. This is incorrect. The ISR bits are only every set at the time their corresponding event occurs. Signed-off-by: Peter Crosthwaite --- hw/cadence_gem.c | 27 ++++----------------------- 1 files changed, 4 insertions(+), 23 deletions(-) diff --git a/hw/cadence_gem.c b/hw/cadence_gem.c index 966ab4f..a1ac069 100644 --- a/hw/cadence_gem.c +++ b/hw/cadence_gem.c @@ -427,32 +427,9 @@ static int gem_can_receive(NetClientState *nc) */ static void gem_update_int_status(GemState *s) { - uint32_t new_interrupts = 0; - /* Packet transmitted ? */ - if (s->regs[GEM_TXSTATUS] & GEM_TXSTATUS_TXCMPL) { - new_interrupts |= GEM_INT_TXCMPL; - } - /* End of TX ring ? */ - if (s->regs[GEM_TXSTATUS] & GEM_TXSTATUS_USED) { - new_interrupts |= GEM_INT_TXUSED; - } - - /* Frame received ? */ - if (s->regs[GEM_RXSTATUS] & GEM_RXSTATUS_FRMRCVD) { - new_interrupts |= GEM_INT_RXCMPL; - } - /* RX ring full ? */ - if (s->regs[GEM_RXSTATUS] & GEM_RXSTATUS_NOBUF) { - new_interrupts |= GEM_INT_RXUSED; - } - - s->regs[GEM_ISR] |= new_interrupts & ~(s->regs[GEM_IMR]); - if (s->regs[GEM_ISR]) { DB_PRINT("asserting int. (0x%08x)\n", s->regs[GEM_ISR]); qemu_set_irq(s->irq, 1); - } else { - qemu_set_irq(s->irq, 0); } } @@ -697,6 +674,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) DB_PRINT("descriptor 0x%x owned by sw.\n", (unsigned)packet_desc_addr); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF; + s->regs[GEM_ISR] |= GEM_INT_RXUSED & ~(s->regs[GEM_IMR]); /* Handle interrupt consequences */ gem_update_int_status(s); return -1; @@ -765,6 +743,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) (uint8_t *)&desc[0], sizeof(desc)); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD; + s->regs[GEM_ISR] |= GEM_INT_RXCMPL & ~(s->regs[GEM_IMR]); /* Handle interrupt consequences */ gem_update_int_status(s); @@ -894,6 +873,7 @@ static void gem_transmit(GemState *s) DB_PRINT("TX descriptor next: 0x%08x\n", s->tx_desc_addr); s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_TXCMPL; + s->regs[GEM_ISR] |= GEM_INT_TXCMPL & ~(s->regs[GEM_IMR]); /* Handle interrupt consequences */ gem_update_int_status(s); @@ -931,6 +911,7 @@ static void gem_transmit(GemState *s) if (tx_desc_get_used(desc)) { s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_USED; + s->regs[GEM_ISR] |= GEM_INT_TXUSED & ~(s->regs[GEM_IMR]); gem_update_int_status(s); } }