From patchwork Wed Nov 23 05:46:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 698065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tNrtj1rWQz9svs for ; Wed, 23 Nov 2016 16:46:37 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tNrtj13y6zDvvV for ; Wed, 23 Nov 2016 16:46:37 +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 3tNrtG2fgwzDvqn for ; Wed, 23 Nov 2016 16:46:14 +1100 (AEDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAN5i3Af068759 for ; Wed, 23 Nov 2016 00:46:12 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 26w14pryse-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 23 Nov 2016 00:46:12 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 22 Nov 2016 22:46:10 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 22 Nov 2016 22:46:07 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id BAF951FF0025 for ; Tue, 22 Nov 2016 22:45:46 -0700 (MST) Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uAN5k5D612255688; Tue, 22 Nov 2016 22:46:07 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58E0178047; Tue, 22 Nov 2016 22:46:07 -0700 (MST) Received: from birb.localdomain (unknown [9.185.16.166]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id E99E278043; Tue, 22 Nov 2016 22:46:06 -0700 (MST) Received: by birb.localdomain (Postfix, from userid 1000) id C1D65229DB46; Wed, 23 Nov 2016 16:46:03 +1100 (AEDT) From: Stewart Smith To: skiboot@lists.ozlabs.org Date: Wed, 23 Nov 2016 16:46:01 +1100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479879962-1943-1-git-send-email-stewart@linux.vnet.ibm.com> References: <1479879962-1943-1-git-send-email-stewart@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16112305-0008-0000-0000-00000625B68B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006127; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000189; SDB=6.00784202; UDB=6.00378800; IPR=6.00561819; BA=6.00004904; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013413; XFM=3.00000011; UTC=2016-11-23 05:46:09 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16112305-0009-0000-0000-00003D3FFF6A Message-Id: <1479879962-1943-3-git-send-email-stewart@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-23_01:, , 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-1611230105 Subject: [Skiboot] [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 Tested-by: Claudio Carvalho --- 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 12a4d1a..718f6db 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 = p8_i2c_get_poll_interval(max_bus_speed); + 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 97bdce7..3f7c077 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