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: 10766343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66502186E for ; Wed, 16 Jan 2019 16:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57D9D2EEA8 for ; Wed, 16 Jan 2019 16:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5587D2EED2; Wed, 16 Jan 2019 16:11:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F27652EEE0 for ; Wed, 16 Jan 2019 16:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405258AbfAPQL2 (ORCPT ); Wed, 16 Jan 2019 11:11:28 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45239 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405249AbfAPQL1 (ORCPT ); Wed, 16 Jan 2019 11:11:27 -0500 Received: by mail-wr1-f68.google.com with SMTP id t6so7515433wrr.12 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=qW5/kQ7WaO0FCVPJDNtLl0R2oWhW/ZoU1g8/+uxg3R0HL+XILI1SYdRjDvYPCd+56P QYOAcX6rfH/5SRsOX2tCmj20RQ2vnOxtuN0JyX8d8Rowhohrft9irTjzT4pCh4PZF1wr JSfNDxDdI4uJg3R15/B2qi5mDldAcnUzU6PoIMynn4f16cwT6WxOaGp5tswJ4VD04A00 XTL0S7feq6qPEn8yf64xDkcK06r+1flxMeE5noKX2OZXJUepWRpWAhDC+sfIoiCTb7Uk ZiH07jt4IkFDpOwyJpNXx75e7+AqysDydx5Szwt+aa/gjfo1eJ7PcupPCV8NXRmHfwWn lMVw== X-Gm-Message-State: AJcUukeVuKYHAHKAhpyKSdmcC2OlQ+Fxv2JHW94zNRkIppfzt24TOP1I 0j32BTqQGoEkx5UaFR7BuQTU5A== X-Google-Smtp-Source: ALg8bN5vTpTdgFrNsBazJWOvWRE+OuJSwyAUdPF+54h9gkihY+LCJgCaEB709+03Af7ay7801ioi0Q== 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;