From patchwork Mon Oct 12 02:53:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1380600 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C8jyn3pv9z9s0b for ; Mon, 12 Oct 2020 13:57:37 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=KB8ISIGU; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4C8jyn2qLTzDqjb for ; Mon, 12 Oct 2020 13:57:37 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=KB8ISIGU; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4C8jtN5h74zDqjM for ; Mon, 12 Oct 2020 13:53:48 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id q21so1693596pgi.13 for ; Sun, 11 Oct 2020 19:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gl2C/6V6kF/PwOGu592hlp+762H4oaQ7/Aw6JGhTkyc=; b=KB8ISIGU/Cfly3y6PWjrIKK50lmvPB+iXDEOheE8gsl5Hud+8VTEKDycqQJYP2DP1D G8SbRbCpA6b6M7f415mTrkeGpHArj/0PWAFExsFETKlhXhZrNswrwanFAUTrYvOoo/Fy nZBoUgT3HL8jxleoXcFnwyxJIZ64z4ocztdqWiqBLqpi3gBkoTVJcynSv6kWqYTv7w4t c1pK0sMYsQM+Q4rkzLcO23hJM2NKk32+uxX8gpi0QgoKKXrMkg5/7uW5Itnhh+htKMEr BSxL4pHaNvkeHc/a/aEsLbc0EFwH9FVb5Y7UPY7sMI+H/QzUqy2EfDAzE9G8puOFscYb GEIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gl2C/6V6kF/PwOGu592hlp+762H4oaQ7/Aw6JGhTkyc=; b=p5TDYDrZt+101fb7ceKCBjEudRVF0puhKJbMz6lflcOFYanHaQexd8R12WlkMuSVoZ FhlXjJfz58kvP1V7RlGKALYpB0PciyCju4aHdicDlfFWHQ2mtF2NdnmYulfj/7mIw/m6 BFTSb2m8dzwH2SWruBa8Jv+lAjrCtvcBjRlohyEgGqkhzY1/blQq0dyCof2IHxjZEQK6 xxI6gsVpb3ReGbcEUCPx+7WwGXuYDoeRyR8MPDafwAGBHHAE3Yc2rRwn0f2mfRNez2vu KSR+G3Q5D/rbosmmhJL8j47fdivdsZ0x5lWwrZxKwR2l4PDJiJqJDWbLeDQZxymEl8yy ndBw== X-Gm-Message-State: AOAM533vNS1Q1Qdk61IGvt9bg9Cnm/g/gvWvhii4Zs56s9rkG1RQ/v9s tAJyvxyTJg5OdLAkzsAHNfI42zZS44bbkw== X-Google-Smtp-Source: ABdhPJxjpEbKy0C9796AgIXsDrWsGrha9D0CEHZTknqsVi1cgDToDvkXC88ZsVG4ZoyaJMin/EVlTQ== X-Received: by 2002:a62:ab0e:0:b029:156:1dfe:ae74 with SMTP id p14-20020a62ab0e0000b02901561dfeae74mr2734194pff.7.1602471225560; Sun, 11 Oct 2020 19:53:45 -0700 (PDT) Received: from localhost.ibm.com (14-200-206-90.tpgi.com.au. [14.200.206.90]) by smtp.gmail.com with ESMTPSA id g4sm17909258pgg.75.2020.10.11.19.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Oct 2020 19:53:45 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Mon, 12 Oct 2020 13:53:11 +1100 Message-Id: <20201012025314.1070230-7-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012025314.1070230-1-oohall@gmail.com> References: <20201012025314.1070230-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 07/10] hw/p8-i2c: Set poll interval from the current port X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The rate at which we need to poll the master depends on the speed of the bus. Faster I2C buses will require more frequent polling so it doesn't make a whole lot of sense to set this on a per-master basis. This patch sets the master's polling interval to a per-port setting calculated from the port speed. Signed-off-by: Oliver O'Halloran --- hw/p8-i2c.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 78f1e7e32932..f01cbe8a0870 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -234,6 +234,7 @@ struct p8_i2c_master_port { uint32_t port_num; uint32_t bit_rate_div; /* Divisor to set bus speed*/ uint64_t byte_timeout; /* Timeout per byte */ + uint64_t poll_interval; /* Polling interval */ struct list_node link; }; @@ -1017,7 +1018,7 @@ static int p8_i2c_start_request(struct p8_i2c_master *master, struct i2c_request *req) { struct p8_i2c_master_port *port; - uint64_t cmd, poll_interval; + uint64_t cmd; int64_t rc; DBG("Starting req %d len=%d addr=%02x (offset=%x)\n", @@ -1152,10 +1153,10 @@ static int p8_i2c_start_request(struct p8_i2c_master *master, * cases */ if (!opal_booting() && master->irq_ok) - poll_interval = TIMER_POLL; + master->poll_interval = TIMER_POLL; else - poll_interval = master->poll_interval; - schedule_timer(&master->poller, poll_interval); + master->poll_interval = port->poll_interval; + schedule_timer(&master->poller, master->poll_interval); /* If we don't have a user-set timeout then use the master's default */ if (!req->timeout) @@ -1442,7 +1443,7 @@ static void p8_i2c_add_bus_prop(struct p8_i2c_master_port *port) static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) { struct p8_i2c_master_port *port; - uint32_t lb_freq, count, max_bus_speed; + uint32_t lb_freq, count; struct dt_node *i2cm_port; struct p8_i2c_master *master; struct list_head *chip_list; @@ -1547,7 +1548,6 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) /* Add master to chip's list */ list_add_tail(chip_list, &master->link); - max_bus_speed = 0; default_timeout = master->irq_ok ? I2C_TIMEOUT_IRQ_MS : @@ -1559,8 +1559,7 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) port->port_num = dt_prop_get_u32(i2cm_port, "reg"); port->master = master; speed = dt_prop_get_u32(i2cm_port, "bus-frequency"); - if (speed > max_bus_speed) - max_bus_speed = speed; + port->poll_interval = p8_i2c_get_poll_interval(speed); port->bit_rate_div = p8_i2c_get_bit_rate_divisor(lb_freq, speed); port->bus.dt_node = i2cm_port; @@ -1581,14 +1580,6 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) "ibm,port-name"), speed/1000); port++; } - - /* 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. - */ - master->poll_interval = (max_bus_speed) ? p8_i2c_get_poll_interval(max_bus_speed) : TIMER_POLL; } void p8_i2c_init(void)