From patchwork Thu Nov 24 05:06:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 698612 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tPRym5k2Cz9rxv for ; Thu, 24 Nov 2016 16:07:12 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tPRym2xHxzDwBT for ; Thu, 24 Nov 2016 16:07:12 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tPRyY1HW3zDt1j for ; Thu, 24 Nov 2016 16:07:00 +1100 (AEDT) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAO53suO089728 for ; Thu, 24 Nov 2016 00:06:59 -0500 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 26ws3nksx1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 24 Nov 2016 00:06:58 -0500 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 23 Nov 2016 22:06:58 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 23 Nov 2016 22:06:56 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 9A5211FF001F for ; Wed, 23 Nov 2016 22:06:35 -0700 (MST) Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uAO56uEN10945002; Wed, 23 Nov 2016 22:06:56 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3CE4B6A041; Wed, 23 Nov 2016 22:06:56 -0700 (MST) Received: from birb.localdomain (unknown [9.185.16.166]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id C2FE16A03C; Wed, 23 Nov 2016 22:06:55 -0700 (MST) Received: from ka1.ozlabs.ibm.com (localhost.localdomain [127.0.0.1]) by birb.localdomain (Postfix) with ESMTP id E0997229DB44; Thu, 24 Nov 2016 16:06:51 +1100 (AEDT) From: Stewart Smith To: skiboot@lists.ozlabs.org Date: Thu, 24 Nov 2016 16:06:51 +1100 X-Mailer: git-send-email 2.1.4 In-Reply-To: <1479879962-1943-3-git-send-email-stewart@linux.vnet.ibm.com> References: <1479879962-1943-3-git-send-email-stewart@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16112405-0028-0000-0000-0000061D9A86 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006131; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000191; SDB=6.00784665; UDB=6.00379080; IPR=6.00562275; BA=6.00004908; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013424; XFM=3.00000011; UTC=2016-11-24 05:06:57 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16112405-0029-0000-0000-0000311C13BA Message-Id: <1479964011-31186-1-git-send-email-stewart@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-24_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611240087 Subject: [Skiboot] [v2 PATCH 3/4] p8i2c: Use calculated poll_interval when booting OPAL X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Otherwise we'd default to 2seconds (TIMER_POLL) during boot on chips with a functional i2c interrupt, leading to slow i2c during boot (or hitting timeouts instead). Signed-off-by: Stewart Smith --- change in v2: don't set poll_interval = 0 when no children (this would hit an assert on booting on garrison, possibly others) --- hw/p8-i2c.c | 23 +++++++++++++---------- include/skiboot.h | 5 +++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 12a4d1aabfeb..faaf6ede3373 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -870,7 +870,7 @@ static int p8_i2c_start_request(struct p8_i2c_master *master, struct p8_i2c_master_port *port; struct p8_i2c_request *request = container_of(req, struct p8_i2c_request, req); - uint64_t cmd, now; + uint64_t cmd, now, poll_interval; int64_t rc, tbytes; DBG("Starting req %d len=%d addr=%02x (offset=%x)\n", @@ -975,7 +975,11 @@ static int p8_i2c_start_request(struct p8_i2c_master *master, /* Run a poll timer for boot cases or non-working interrupts * cases */ - now = schedule_timer(&master->poller, master->poll_interval); + if (!opal_booting() && master->irq_ok) + poll_interval = TIMER_POLL; + else + poll_interval = master->poll_interval; + now = schedule_timer(&master->poller, poll_interval); /* Calculate and start timeout */ if (request->timeout) { @@ -1428,15 +1432,14 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) port++; } - /* If we have no interrupt, calculate a poll interval, - * otherwise just use a TIMER_POLL timer which will tick - * on OPAL pollers only (which allows us to operate - * during boot before interrupts are functional etc... + /* When at runtime and we have the i2c irq, we just use it + * (see p8_i2c_start_request), but in the situation where + * one of those isn't the case (e.g. during boot), we need + * a better poll interval to efficiently crank the i2c machine. + * poll_interval is that interval. */ - if (master->irq_ok) - master->poll_interval = TIMER_POLL; - else - master->poll_interval = p8_i2c_get_poll_interval(max_bus_speed); + master->poll_interval = (max_bus_speed) ? p8_i2c_get_poll_interval(max_bus_speed) : TIMER_POLL; + master->byte_timeout = master->irq_ok ? msecs_to_tb(I2C_TIMEOUT_IRQ_MS) : msecs_to_tb(I2C_TIMEOUT_POLL_MS); diff --git a/include/skiboot.h b/include/skiboot.h index 97bdce784eaf..3f7c077812ed 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -86,6 +86,11 @@ struct debug_descriptor { }; extern struct debug_descriptor debug_descriptor; +static inline bool opal_booting(void) +{ + return !(debug_descriptor.state_flags & OPAL_BOOT_COMPLETE); +} + /* Console logging */ #define PR_EMERG 0 #define PR_ALERT 1