From patchwork Thu Mar 17 07:37:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameeh Jubran X-Patchwork-Id: 8611921 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 550439F44D for ; Thu, 17 Mar 2016 14:46:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A8A7D20373 for ; Thu, 17 Mar 2016 14:46:44 +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 D76902026F for ; Thu, 17 Mar 2016 14:46:43 +0000 (UTC) Received: from localhost ([::1]:35430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agZCE-0000cW-Vx for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Mar 2016 10:46:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agSVX-0006Bx-AS for qemu-devel@nongnu.org; Thu, 17 Mar 2016 03:38:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agSVT-0001YW-EA for qemu-devel@nongnu.org; Thu, 17 Mar 2016 03:38:11 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agSVT-0001YQ-7N for qemu-devel@nongnu.org; Thu, 17 Mar 2016 03:38:07 -0400 Received: by mail-wm0-x241.google.com with SMTP id x188so5154726wmg.0 for ; Thu, 17 Mar 2016 00:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IjC4IUarLIO+RtffXmUIqUZxyqltTqnFm18G1iHY+AI=; b=P224ajCyHsgChqkk51ZYG9DMm2La1HQSnhWaMbtElOVO8KVw9HqxS1T03bqU2/1PvC iiUWgwmenx4KKwCXPxqmoZoDdM1p6zUenDU0EqBXIXWO1Ir7EUy8eDgacLs25yn6cJh6 3h/AS1FR4mc0LVirp6sVKd/yPuFSOPpngFRwbf+jk4XOgjykNf283jdCU1p/JQ6YIk2L TAlS/Ag+d48b6vYKn1TboxIDVREpkGKDTbf5AYgwQchQnZ12+3QHtowSksKuiY5gHIwX fv/z1wuX2TQ3xNYyAuuojV881oRlnxQaQ0UwLi7s3JWzLPb22EWo2lHWHw3MYC/+mhtg gsTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IjC4IUarLIO+RtffXmUIqUZxyqltTqnFm18G1iHY+AI=; b=FO4ZVmRVPiZhwo0FyW6aSuEt3+2kleLBmQLpeXDJauQLkbPQs4KmKkrF5elzKGxo5n CdZ0JXrKUxIxFqkxWLwv9CjRTpRN9qnNaK+0mA577fZRY1hEl8SaaT7XtO+frl4+bsiI zPaAFgpMwp5T3OWup0+L/dW5A4O2XUt6XfDSb9ycQsxo+Ha0ndrH4eX1zGiOimpIpKZP 5u7PjwiQeP0Syd4bI6WNzYARO4FC2+jU080I5OX8/X0SMBocvxlVURrlxtpQaaVqDd2C 26xPQS8tsfU6f2fduKpeRw+Lqnj3cdBKPsCqVRErQwkw/3BT2KO8iEf3WCQ17aK/CHlo wAZQ== X-Gm-Message-State: AD7BkJI3yMtMEvY9BdO0IWt26gSy4+1PKRetTUK6/9DcEgC9lLb7EM4AmqPxTyxBUmY/oQ== X-Received: by 10.28.238.210 with SMTP id j79mr9038237wmi.23.1458200286635; Thu, 17 Mar 2016 00:38:06 -0700 (PDT) Received: from bark.daynix ([5.102.236.99]) by smtp.gmail.com with ESMTPSA id y62sm6782431wmg.12.2016.03.17.00.38.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2016 00:38:06 -0700 (PDT) From: Sameeh Jubran To: , Jason Wang Date: Thu, 17 Mar 2016 09:37:57 +0200 Message-Id: <1458200278-11940-2-git-send-email-sameeh@daynix.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458200278-11940-1-git-send-email-sameeh@daynix.com> References: <1458200278-11940-1-git-send-email-sameeh@daynix.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 X-Mailman-Approved-At: Thu, 17 Mar 2016 10:44:16 -0400 Cc: Dmitry Fleytman , Yan Vugenfirer Subject: [Qemu-devel] [PATCH 1/2] e1000: Fixing interrupts pace. 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 This patch introduces an upper bound for number of interrupts per second. Without this bound an interrupt storm can occur as it has been observed on Windows 10 when disabling the device. According to the SPEC - Intel PCI/PCI-X Family of Gigabit Ethernet Controllers Software Developer's Manual, section 13.4.18 - the Ethernet controller guarantees a maximum observable interrupt rate of 7813 interrupts/sec. If there is no upper bound this could lead to an interrupt storm by e1000 (when mit_delay < 500) causing interrupts to fire at a very high pace. Thus if mit_delay < 500 then the delay should be set to the minimum delay possible which is 500. This can be calculated easily as follows: Interval = 10^9 / (7813 * 256) = 500. Signed-off-by: Sameeh Jubran --- hw/net/e1000.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 0387fa0..09b9ab5 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -357,6 +357,14 @@ set_interrupt_cause(E1000State *s, int index, uint32_t val) } mit_update_delay(&mit_delay, s->mac_reg[ITR]); + /* + * According to e1000 SPEC, the Ethernet controller guarantees + * a maximum observable interrupt rate of 7813 interrupts/sec. + * Thus if mit_delay < 500 then the delay should be set to the + * minimum delay possible which is 500. + */ + mit_delay = (mit_delay < 500) ? 500 : mit_delay; + if (mit_delay) { s->mit_timer_on = 1; timer_mod(s->mit_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +