From patchwork Sat Nov 3 21:41:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 196954 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id F23E02C00C8 for ; Sun, 4 Nov 2012 08:46:17 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C4F5F4A393; Sat, 3 Nov 2012 22:44:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gLhBAY3Q3eOQ; Sat, 3 Nov 2012 22:44:36 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2AA374A1BE; Sat, 3 Nov 2012 22:42:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D68984A180 for ; Sat, 3 Nov 2012 22:42:27 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YTds9YWB5woy for ; Sat, 3 Nov 2012 22:42:25 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-qc0-f202.google.com (mail-qc0-f202.google.com [209.85.216.202]) by theia.denx.de (Postfix) with ESMTPS id D09154A162 for ; Sat, 3 Nov 2012 22:42:06 +0100 (CET) Received: by mail-qc0-f202.google.com with SMTP id s25so238864qcq.3 for ; Sat, 03 Nov 2012 14:42:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=rqlmYIMmIIG372dbpFW+L51IM5PQZlKQ5hNCXRjKrxE=; b=k7pTuzo7A9KPk5LEXh8BZH/T+ronl0yG7+efqR9oL1a41W/PA47VLTvhxXLoHA+/q6 SWHShXWHw4BnaxfduDtUQegnI0nMdZYztqE4CAJ1k/c4B8EF+qyLHTx8C8dKqNKBKdHE LE3Qw4/f5nEfF79065l6NIZK4cuZ5hdDAhtJH3QGEVYgyGm4AG5zMliltzWkO6WKYBIg CzHbr4eQD9vtEZrNgCwBqOeZhJ3x0q4J9Upn/dt4N0N4n+sCAoyEWoGYXnA2hU64AcxX NGmbATaCKBmOt/J6Yl/mBAz6HEvjvOGhpl8egRRC/DQgV1t82mukTTSJiKvIK5W74zW9 6UkQ== Received: by 10.236.82.9 with SMTP id n9mr3984899yhe.24.1351978923873; Sat, 03 Nov 2012 14:42:03 -0700 (PDT) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id h50si821117yhi.3.2012.11.03.14.42.03 (version=TLSv1/SSLv3 cipher=AES128-SHA); Sat, 03 Nov 2012 14:42:03 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id 9CA4810006E; Sat, 3 Nov 2012 14:42:03 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 7BA13161954; Sat, 3 Nov 2012 14:42:03 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 3 Nov 2012 14:41:37 -0700 Message-Id: <1351978902-23719-16-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1351978902-23719-1-git-send-email-sjg@chromium.org> References: <1351978902-23719-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQn+zImLj8Ck6PjyIn556jHthnjusYUezUw2fz9GZ/ariBT+XjsmI60BZwk890dvE78kmZk0YODFLl23W+6X08QomqCMyHizD58VugGGxauX4umIvY/V4qDHo6j6YS2MhO1sQYgalcvPMo5WmKjhNYsRZbLMgYCju2KPKLp9xkJeeGx3j9mJm2r2kLSidMi0PZDbSi8U Cc: Vadim Bendebury Subject: [U-Boot] [PATCH 15/20] x86: Provide a way to throttle port80 accesses X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Vadim Bendebury Some systems (like Google Link device) provide the ability to keep a history of the target CPU port80 accesses, which is extremely handy for debugging. The problem is that the EC handling port 80 access is orders of magnitude slower than the AP. This causes random loss of trace data. This change allows to throttle port 80 accesses such that in case the AP is trying to post faster than the EC can handle, a delay is introduced to make sure that the post rate is throttled. Experiments have shown that on Link the delay should be at least 350,000 of tsc clocks. Throttling is not being enabled by default: to enable it one would have to set MIN_PORT80_KCLOCKS_DELAY to something like 400 and rebuild the u-boot image. With upcoming EC code optimizations this number could be decreased (new new value should be established experimentally). Signed-off-by: Vadim Bendebury Signed-off-by: Simon Glass --- arch/x86/cpu/coreboot/coreboot.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/arch/x86/cpu/coreboot/coreboot.c b/arch/x86/cpu/coreboot/coreboot.c index 59d730e..da722e9 100644 --- a/arch/x86/cpu/coreboot/coreboot.c +++ b/arch/x86/cpu/coreboot/coreboot.c @@ -69,6 +69,27 @@ int board_early_init_r(void) void show_boot_progress(int val) { +#if MIN_PORT80_KCLOCKS_DELAY + static uint32_t prev_stamp; + static uint32_t base; + + /* + * Scale the time counter reading to avoid using 64 bit arithmetics. + * Can't use get_timer() here becuase it could be not yet + * initialized or even implemented. + */ + if (!prev_stamp) { + base = rdtsc() / 1000; + prev_stamp = 0; + } else { + uint32_t now; + + do { + now = rdtsc() / 1000 - base; + } while (now < (prev_stamp + MIN_PORT80_KCLOCKS_DELAY)); + prev_stamp = now; + } +#endif outb(val, 0x80); }