From patchwork Wed Jan 16 16:11:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 155724 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp835987jaa; Wed, 16 Jan 2019 08:11:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN5vbjN5dB1mpwsHZ1w6QqGcgS8mOWCS7ZUJnr4iCiA4snCBMTt1v6BkUP74HZS+qHbogbg4 X-Received: by 2002:a17:902:b118:: with SMTP id q24mr10726243plr.209.1547655091940; Wed, 16 Jan 2019 08:11:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547655091; cv=none; d=google.com; s=arc-20160816; b=O3Zsg6jUQ/1mob6ZcDjYWovWUxfho1D/uv0L+XHBzw74sJK42fdOHIUU9TexjiYle8 cXUYUb6GyjFLfSlVYeI91L4ci4XGLO5EELJFQQuqDzS6oorWQPLhfDW07Ns7Qpi4J7jf nPJZCItroeTdZc7DOjagS+uF58agttmTqMjG+ioCGnA2vYRHiLfjnj8s30TmZVptLopS dLTgEZRiljfXLevECWRnQrQXJiJd38CLMou9dz00ekkXmew1WwoQxbSb1NYatXpFL+F9 uOky3B4D/OzOQeNmkTld6mCgDE7a2Zz6NstTv0E8FMdXf48Qv6+M4jOKFFwxjI0xzNlj HkQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JgRm2aO2Ij1KQwzH5NiF8dvBkSLnMrQ8RcNVlPauU/8=; b=0nU+yRRCtRlYKMMmDwvgZe66XsPAnh710hDNaG228GI6yaVuHaJtTm8byHMHwEaYkV hLp1k5vH+ZCHNvXk+UDpovCNwgrHWYh8B9FgxjwZ0qaHQAgiEkicAuBK/gFg16dZzkd1 0L/UfUdWqdMO8viObqHc1cxAXKgkcokScJHiKJM1kSUPeN/Fxr3PVmIngLfNcp3Mw76o xzQvMTmA4gxmsyczOCThRTwqhzDR9FxLTB2B6i9zuFAdmuEX4GbjApTKExapAMR32YU/ lqnNrshgtxZhZnzlaP+IM+FyVoJj8z0IXR2eDp8BaV3cseHce9fauB0ZQ8mGQp1MulUr HrkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eng73Q+r; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si3259005pgm.508.2019.01.16.08.11.30; Wed, 16 Jan 2019 08:11:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eng73Q+r; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405257AbfAPQL2 (ORCPT + 11 others); Wed, 16 Jan 2019 11:11:28 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39145 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405229AbfAPQL1 (ORCPT ); Wed, 16 Jan 2019 11:11:27 -0500 Received: by mail-wr1-f65.google.com with SMTP id t27so7576955wra.6 for ; Wed, 16 Jan 2019 08:11:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JgRm2aO2Ij1KQwzH5NiF8dvBkSLnMrQ8RcNVlPauU/8=; b=eng73Q+rXVdfvwKcoCIxc2D2TnbLST3DbvtVZT8/wMBHycQWUXcjrQVVYynjYN/eNf VonNHpkhw1c7lT6ZkVMUAofI3642MqI0OXWXKd32g4ZlYaDCKlGeEL2s8PpN9ptmiyT0 xqsUXzokZRLa+SpQMOVnOyL4vTE3MoqtorQrs= 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=JgRm2aO2Ij1KQwzH5NiF8dvBkSLnMrQ8RcNVlPauU/8=; b=dE1XjFSWsXi3nqT8PQyi5gswv52QreYK1d7ksqgtkIY72+ZcA38sVMd4ZgvMrMG9lJ 0EHFdNYPZabcztSujfvG1NFWxL4U8UOp/lwnwD4+/0aXFp1rwOvbGhEEhsU0ALG5A/oU ReW7LlcneMo0BolN8rHxolPf/Ik56NA2HkPP/VPCCk703a67TIBuH2D06kRb5EZpwmIw iaVsI3tWi9iQ+J9dIebH3EJwvmIY4wZuhc6G/BOzoLokXpnyequ7P2tBpj2Nhz8qzu9r KVAyp+340R/gP4PtlV/A/2WCyUAfNh86qImoctXLynrF2BjyT6aSlYlyAOmakWwCC28h 8poQ== X-Gm-Message-State: AJcUukdtuYYgR4kLGo0+1QsZBIAHXfrEuai9VkOcG2MPOmt39SLaW0mA o1zOkc5HFYvtsWUOkr9pRbA+Mg== X-Received: by 2002:adf:b3c3:: with SMTP id x3mr8262877wrd.294.1547655085306; Wed, 16 Jan 2019 08:11:25 -0800 (PST) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id a17sm78193407wrs.58.2019.01.16.08.11.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Jan 2019 08:11:24 -0800 (PST) From: Georgi Djakov To: gregkh@linuxfoundation.org Cc: andy.gross@linaro.org, olof@lixom.net, arnd@arndb.de, rjw@rjwysocki.net, robh+dt@kernel.org, mturquette@baylibre.com, khilman@baylibre.com, vincent.guittot@linaro.org, skannan@codeaurora.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, dianders@chromium.org, abailon@baylibre.com, maxime.ripard@bootlin.com, thierry.reding@gmail.com, ksitaraman@nvidia.com, sanjayc@nvidia.com, henryc.chen@mediatek.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, georgi.djakov@linaro.org Subject: [PATCH v13 8/8] interconnect: Revert to previous config if any request fails Date: Wed, 16 Jan 2019 18:11:03 +0200 Message-Id: <20190116161103.6937-9-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190116161103.6937-1-georgi.djakov@linaro.org> References: <20190116161103.6937-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org When consumers report their bandwidth needs with icc_set_bw(), it's possible that the requested amount of bandwidth is not available or just the new configuration fails to apply on some path. In this case revert to the previous configuration and propagate the error back to the consumers to let them know that bandwidth is not available, hardware is busy or whatever error is returned by the interconnect platform driver. Signed-off-by: Georgi Djakov --- drivers/interconnect/core.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 8091d998549a..6005a1c189f6 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -414,14 +414,18 @@ EXPORT_SYMBOL_GPL(of_icc_get); int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) { struct icc_node *node; + u32 old_avg, old_peak; size_t i; int ret; - if (!path) + if (!path || !path->num_nodes) return 0; mutex_lock(&icc_lock); + old_avg = path->reqs[0].avg_bw; + old_peak = path->reqs[0].peak_bw; + for (i = 0; i < path->num_nodes; i++) { node = path->reqs[i].node; @@ -434,10 +438,19 @@ int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) } ret = apply_constraints(path); - if (ret) + if (ret) { pr_debug("interconnect: error applying constraints (%d)\n", ret); + for (i = 0; i < path->num_nodes; i++) { + node = path->reqs[i].node; + path->reqs[i].avg_bw = old_avg; + path->reqs[i].peak_bw = old_peak; + aggregate_requests(node); + } + apply_constraints(path); + } + mutex_unlock(&icc_lock); return ret;