From patchwork Wed Oct 31 23:08:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149901 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp100898ljp; Wed, 31 Oct 2018 16:10:11 -0700 (PDT) X-Google-Smtp-Source: AJdET5fsSEAZw1uhJD09dlYCY0Cf+vI2d/fcVjzMmLstVesd/6KQhC8NjVADQWwwKNwuD+P5aXnK X-Received: by 2002:a62:c42:: with SMTP id u63-v6mr5319799pfi.43.1541027411676; Wed, 31 Oct 2018 16:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541027411; cv=none; d=google.com; s=arc-20160816; b=Pssft2ALQMjD3yV0FPrXHq5g3CLe2cut9SbWKsIdtS7UgTkjYtG7IEAfxheEQeFN/V cYxtTjbSwYg0VqNLuXc+dAp2sytMRDw78k87usVB4fR8F1cjSCDQtKMWDwJVRS6UubTz 7WGUUCDD0QhdZUcrO1Q9MDCnmKoiEUvjlyJSQPpf8UQeF1khCwoTt/tsJBROsAhSEkI5 +TQeRy7lhJdM7QmfX0hrNrwf5z9Gie8ypWV8bWjBLDSsaBe2sDfsPRmJ/agQ4FOQye+3 oag/xQhHd+89RogPlP0HKmxKYK/XbznRwPlC+PgLGTv90JOaLC78fdmrT76m/wZJqdnm x1fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=n1PvcJ4LPyrxwvxXHv51ifMoQLQ2r2A3YE8T6BeR81Y=; b=QFfPlpLEEGdP0YZQ9tXnolNOaSeamw0FLQHiK559sRV8hPqboUqP3A+jhso885sKBC 0THDOVgeMeKg/VtuXybMNjanuY8ETWM00SE9SXzLkx2i8N5DLhbj4C8QHsev6X/3qXTL 6lxLY7f3dxcoErf2hQvagibEoGU1kE7wYcHJHkOcwvxH/uZAfm9jcG5IgcDto6P3oGHm 2TL01jNzn91XYFx3Zt0OXj/x4G3K8WPDbgpaXJu4lAZK1Z6A+3PqwH+ZfExSb85cuCMf PbfD53ZlYMPv12AE8VFXyShx7qd32C23Pb55bi8MZ3P5dhymv05G+1vbhPAcPFqQXnUP md3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XlGjw8bG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16-v6si29951413pgp.175.2018.10.31.16.10.11; Wed, 31 Oct 2018 16:10:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=XlGjw8bG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730971AbeKAIKU (ORCPT + 32 others); Thu, 1 Nov 2018 04:10:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:60954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729626AbeKAIKT (ORCPT ); Thu, 1 Nov 2018 04:10:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A8D6F20843; Wed, 31 Oct 2018 23:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027407; bh=fpzFFQYaO/o9Gy9nAlp02qd2x6D8zc9WonXtl/icoMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlGjw8bGLC5bRlM6XAU36x3t8h2YASaSQDulRaKoJvnyfcxo9f30UyBdJhVBt67ee xxwV+hVhcizilfR0KaEJPyXlTCzsFLolTQbGbU8sgenc5MOMhf4DIafEnVyQaBle3s ie12onHgX9o74TDImnJXHrkl+Ozu8uRIpF4P29bE= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Viresh Kumar , Sasha Levin Subject: [PATCH AUTOSEL 4.14 20/73] cpufreq: dt: Try freeing static OPPs only if we have added them Date: Wed, 31 Oct 2018 19:08:55 -0400 Message-Id: <20181031230948.29203-20-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230948.29203-1-sashal@kernel.org> References: <20181031230948.29203-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Viresh Kumar [ Upstream commit 51c99dd2c06b234575661fa1e0a1dea6c3ef566f ] We can not call dev_pm_opp_of_cpumask_remove_table() freely anymore since the latest OPP core updates as that uses reference counting to free resources. There are cases where no static OPPs are added (using DT) for a platform and trying to remove the OPP table may end up decrementing refcount which is already zero and hence generating warnings. Lets track if we were able to add static OPPs or not and then only remove the table based on that. Some reshuffling of code is also done to do that. Reported-by: Niklas Cassel Tested-by: Niklas Cassel Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq-dt.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index d83ab94d041a..ca6ee9f389b6 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -32,6 +32,7 @@ struct private_data { struct device *cpu_dev; struct thermal_cooling_device *cdev; const char *reg_name; + bool have_static_opps; }; static struct freq_attr *cpufreq_dt_attr[] = { @@ -196,6 +197,15 @@ static int cpufreq_init(struct cpufreq_policy *policy) } } + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) { + ret = -ENOMEM; + goto out_put_regulator; + } + + priv->reg_name = name; + priv->opp_table = opp_table; + /* * Initialize OPP tables for all policy->cpus. They will be shared by * all CPUs which have marked their CPUs shared with OPP bindings. @@ -206,7 +216,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) * * OPPs might be populated at runtime, don't check for error here */ - dev_pm_opp_of_cpumask_add_table(policy->cpus); + if (!dev_pm_opp_of_cpumask_add_table(policy->cpus)) + priv->have_static_opps = true; /* * But we need OPP table to function so if it is not there let's @@ -232,19 +243,10 @@ static int cpufreq_init(struct cpufreq_policy *policy) __func__, ret); } - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) { - ret = -ENOMEM; - goto out_free_opp; - } - - priv->reg_name = name; - priv->opp_table = opp_table; - ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); if (ret) { dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret); - goto out_free_priv; + goto out_free_opp; } priv->cpu_dev = cpu_dev; @@ -280,10 +282,11 @@ static int cpufreq_init(struct cpufreq_policy *policy) out_free_cpufreq_table: dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); -out_free_priv: - kfree(priv); out_free_opp: - dev_pm_opp_of_cpumask_remove_table(policy->cpus); + if (priv->have_static_opps) + dev_pm_opp_of_cpumask_remove_table(policy->cpus); + kfree(priv); +out_put_regulator: if (name) dev_pm_opp_put_regulators(opp_table); out_put_clk: @@ -298,7 +301,8 @@ static int cpufreq_exit(struct cpufreq_policy *policy) cpufreq_cooling_unregister(priv->cdev); dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); - dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); + if (priv->have_static_opps) + dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); if (priv->reg_name) dev_pm_opp_put_regulators(priv->opp_table); From patchwork Wed Oct 31 23:08:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149914 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp115230ljp; Wed, 31 Oct 2018 16:27:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5eFcdMUh6uif4r0Rk959dwrGKGX56kRVV+NcfehdI6dquyLgk/Tr3nMr7bzJMVKaJQNbMn2 X-Received: by 2002:a17:902:5ac9:: with SMTP id g9-v6mr5355920plm.311.1541028460893; Wed, 31 Oct 2018 16:27:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541028460; cv=none; d=google.com; s=arc-20160816; b=DCqJK0VISWVNc4LPmVrSA/MkaM1oX65aTUPEjlVTi188CX5FTXEm09igvE6xDgf9ni 91Sd4utaptnRyS+YhDaWiou1VYcAI7AHvR4Yat7P+RTbW3pqV8zOwYgVswi6sdzu1YUP dU2xUKC60SXhtZnOA9xK46e7IYHpwS+O9weVwAEUAhUCi7554H7y7a+HH2cBlVOwzXfa Hdac6LCcnPcKLJ5jdmBHSAKh2sixJg/Ak0Ffci9Zgan8zNmeispDSzZkpEb25C6hi/tM RuAZy4K8j2LzaysblfHS1+uda0Rqm4Lze3MgW+UkqKfWVNuHQN/JBtw3AMJWa6bXQ9HS nb2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=DkHASvWaQzP46fVNTllqBG+7zWgY5xyiIuvOH1yIhgI=; b=0EDX1gUn7lKGiTII3XpwGP2TCHskl8mEQgEFDyIeIfHgT9f16tDfLbEnnKTDVcGtxq vBclPkrkk9U6ghMZ2Bfbh5tJ+uibFsapKnYZ6I0YEl/aCnsSWa74wZa0ZhnrzyeAmYN6 beO0QqrZ4GhWMskXHZQn4zLi5l6JrTRt1WmeD7W/PoYLrZhJiBLr2tPKkl5thw70hh1w wG6sE2PnLBqzhIXuwvjoXZOSpPTs3hMi3vrPPYtAllwT84MmKkk5QivRuRm8uDT41s2a r0spqzEE6EDD/jR3GodcW7RyqrPie9ahqgL6pU05hQx+dNX44qM3Srqh4fIBhPEdgR+a EGXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="E27/KuR/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si3189932pgb.231.2018.10.31.16.27.40; Wed, 31 Oct 2018 16:27:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b="E27/KuR/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731180AbeKAI1u (ORCPT + 32 others); Thu, 1 Nov 2018 04:27:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:60840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730956AbeKAIKU (ORCPT ); Thu, 1 Nov 2018 04:10:20 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3DAE62081B; Wed, 31 Oct 2018 23:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027408; bh=xixfP+2xcVyJj/LcGiNejEQLYC1PYTYpBTx80WWdXr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E27/KuR/q27uZirr7KX1C/gQRH9SQSKNs3GHpL65ALv++EL5E4Y8jr0WRK50wK9uP AJhtifjEWdi6ZYqnhCG1pbO3e+i0yyCJLReMnLtOkVFLiqvaDw7biafc4mtcwKo6LW TQAeO0buaJdYWAvrQAMrf+5lwYrhl6ttQ4eyve7g= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 4.14 22/73] regulator: fixed: Default enable high on DT regulators Date: Wed, 31 Oct 2018 19:08:57 -0400 Message-Id: <20181031230948.29203-22-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230948.29203-1-sashal@kernel.org> References: <20181031230948.29203-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij [ Upstream commit 28be5f15df2ee6882b0a122693159c96a28203c7 ] commit efdfeb079cc3 ("regulator: fixed: Convert to use GPIO descriptor only") switched to use gpiod_get() to look up the regulator from the gpiolib core whether that is device tree or boardfile. This meant that we activate the code in a603a2b8d86e ("gpio: of: Add special quirk to parse regulator flags") which means the descriptors coming from the device tree already have the right inversion and open drain semantics set up from the gpiolib core. As the fixed regulator was inspected again we got the inverted inversion and things broke. Fix it by ignoring the config in the device tree for now: the later patches in the series will push all inversion handling over to the gpiolib core and set it up properly in the boardfiles for legacy devices, but I did not finish that for this kernel cycle. Fixes: commit efdfeb079cc3 ("regulator: fixed: Convert to use GPIO descriptor only") Reported-by: Leonard Crestez Reported-by: Fabio Estevam Reported-by: John Stultz Reported-by: Anders Roxell Signed-off-by: Linus Walleij Tested-by: John Stultz Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/fixed.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 988a7472c2ab..d68ff65a5adc 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -84,9 +84,14 @@ of_get_fixed_voltage_config(struct device *dev, of_property_read_u32(np, "startup-delay-us", &config->startup_delay); - config->enable_high = of_property_read_bool(np, "enable-active-high"); - config->gpio_is_open_drain = of_property_read_bool(np, - "gpio-open-drain"); + /* + * FIXME: we pulled active low/high and open drain handling into + * gpiolib so it will be handled there. Delete this in the second + * step when we also remove the custom inversion handling for all + * legacy boardfiles. + */ + config->enable_high = 1; + config->gpio_is_open_drain = 0; if (of_find_property(np, "vin-supply", NULL)) config->input_supply = "vin"; From patchwork Wed Oct 31 23:08:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149902 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp100949ljp; Wed, 31 Oct 2018 16:10:15 -0700 (PDT) X-Google-Smtp-Source: AJdET5cR4+SwwRykGKgCsMMg03Lrso7rMeJAvUIpfUNtlc5iJL4Q8/B6PJ4vabrjAen60Q2OwqsG X-Received: by 2002:a63:4d5d:: with SMTP id n29-v6mr4948197pgl.270.1541027414942; Wed, 31 Oct 2018 16:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541027414; cv=none; d=google.com; s=arc-20160816; b=sO2jlT4oM1eMp6WNcXgcOE7/GCyLjnDQmr5DH/pFtT4xAXdvKlVZd6bpDythQ/H2O7 1VRU7IauYGQNvxQ4qv4rIZK5cM8+eFkJ5hBXP8XoixZrKz5Qne7ejkDZ+wy2cxOSsitl y6HffUwpRGmLyf19ZMgHyVwwSQqAvpiXtVBE1KYDCezgIZ2SHpjp8nrvROMnm0LTe8oK u+YznpqW/zDONJb9uG3AzdaHjQMz1F6rFYvneuorZ3q2Mu8qZa8OFDYQ0bLlGE1NDiOz Ba6QP/LINdzjRL/X39SF0p0h0CE4L9eBuehKxCjUNhb/XgR8rKlJ+TyPl9pHeFB9ByP0 1p6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=J/4QRZtJ0XvrODyWLGtLcvVPl/7EoOAdDBNTbpXH4fk=; b=v93GNumAwyF2pW2kA8xMVHV4DqVYoLE1APd6kLPHq1LDubkrF6rMw8q9e2WsLXnIQR y0CazEJuGWfN5ivlDsc5wj90GZB2K7LT9v9ktJfYgtVJcOqj+irYJ+KcUsT0kAa4EZfC 1KJr0ZYaporjDSeyL1T+qbyRThkCZ37TxiXN8pb2EHDkykvaa7j52iGWOJJI6nq5D+y3 UWVibtNYimPWeTA1qYBZUEBS5oB5dHxZus2Wdiktx/m+4/yzbZURy8lS+56RlcB8xWlv jkkVh7kdQdu7A6AY1cQ6Ako9Yjr4ixJ/IYbfREEnATa1AkUEnjylvlZTA2UY8rrmUwrW 3r7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RFjKKrFQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16-v6si29951413pgp.175.2018.10.31.16.10.14; Wed, 31 Oct 2018 16:10:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=RFjKKrFQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730999AbeKAIKY (ORCPT + 32 others); Thu, 1 Nov 2018 04:10:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:32808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730972AbeKAIKW (ORCPT ); Thu, 1 Nov 2018 04:10:22 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 128F020854; Wed, 31 Oct 2018 23:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027410; bh=uWeThC8usxIRMmy2CrAE1eIn4apG7C3ambvWj+eOue4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RFjKKrFQRCi3LIunce2UzMIR08SOewM6C2UtBLOWi2Dsx07MAqwaGq7fgg5rEsKw+ VPB/XSNfV+A0gtaIfJ/6cZM3fyL3NnC5a5zcX4NGn+ApQQjEykDJK3yJ2i05fvmnAI SEATa8SyPi97q6OdwMtbVeCVqhO2+68I2EKVFGLA= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Will Deacon , Arnd Bergmann , Dominik Brodowski , "Eric W. Biederman" , Andrew Morton , Al Viro , Oleg Nesterov , Catalin Marinas , Sasha Levin Subject: [PATCH AUTOSEL 4.14 23/73] signal: Introduce COMPAT_SIGMINSTKSZ for use in compat_sys_sigaltstack Date: Wed, 31 Oct 2018 19:08:58 -0400 Message-Id: <20181031230948.29203-23-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230948.29203-1-sashal@kernel.org> References: <20181031230948.29203-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon [ Upstream commit 22839869f21ab3850fbbac9b425ccc4c0023926f ] The sigaltstack(2) system call fails with -ENOMEM if the new alternative signal stack is found to be smaller than SIGMINSTKSZ. On architectures such as arm64, where the native value for SIGMINSTKSZ is larger than the compat value, this can result in an unexpected error being reported to a compat task. See, for example: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=904385 This patch fixes the problem by extending do_sigaltstack to take the minimum signal stack size as an additional parameter, allowing the native and compat system call entry code to pass in their respective values. COMPAT_SIGMINSTKSZ is just defined as SIGMINSTKSZ if it has not been defined by the architecture. Cc: Arnd Bergmann Cc: Dominik Brodowski Cc: "Eric W. Biederman" Cc: Andrew Morton Cc: Al Viro Cc: Oleg Nesterov Reported-by: Steve McIntyre Tested-by: Steve McIntyre <93sam@debian.org> Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- include/linux/compat.h | 3 +++ kernel/signal.c | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/include/linux/compat.h b/include/linux/compat.h index 3e838a828459..23909d12f729 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -68,6 +68,9 @@ typedef struct compat_sigaltstack { compat_size_t ss_size; } compat_stack_t; #endif +#ifndef COMPAT_MINSIGSTKSZ +#define COMPAT_MINSIGSTKSZ MINSIGSTKSZ +#endif #define compat_jiffies_to_clock_t(x) \ (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) diff --git a/kernel/signal.c b/kernel/signal.c index 4439ba9dc5d9..b74acbec9876 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3215,7 +3215,8 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) } static int -do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp) +do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp, + size_t min_ss_size) { struct task_struct *t = current; @@ -3245,7 +3246,7 @@ do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp) ss_size = 0; ss_sp = NULL; } else { - if (unlikely(ss_size < MINSIGSTKSZ)) + if (unlikely(ss_size < min_ss_size)) return -ENOMEM; } @@ -3263,7 +3264,8 @@ SYSCALL_DEFINE2(sigaltstack,const stack_t __user *,uss, stack_t __user *,uoss) if (uss && copy_from_user(&new, uss, sizeof(stack_t))) return -EFAULT; err = do_sigaltstack(uss ? &new : NULL, uoss ? &old : NULL, - current_user_stack_pointer()); + current_user_stack_pointer(), + MINSIGSTKSZ); if (!err && uoss && copy_to_user(uoss, &old, sizeof(stack_t))) err = -EFAULT; return err; @@ -3274,7 +3276,8 @@ int restore_altstack(const stack_t __user *uss) stack_t new; if (copy_from_user(&new, uss, sizeof(stack_t))) return -EFAULT; - (void)do_sigaltstack(&new, NULL, current_user_stack_pointer()); + (void)do_sigaltstack(&new, NULL, current_user_stack_pointer(), + MINSIGSTKSZ); /* squash all but EFAULT for now */ return 0; } @@ -3309,7 +3312,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack, uss.ss_size = uss32.ss_size; } ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss, - compat_user_stack_pointer()); + compat_user_stack_pointer(), + COMPAT_MINSIGSTKSZ); if (ret >= 0 && uoss_ptr) { compat_stack_t old; memset(&old, 0, sizeof(old)); From patchwork Wed Oct 31 23:09:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149903 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp101033ljp; Wed, 31 Oct 2018 16:10:19 -0700 (PDT) X-Google-Smtp-Source: AJdET5dw3fexDS8aiLvCfazGHPwX0qrzWpkLnZTYbhHYRkC9v9RxgVODCB9Mdew+plkY7ThbrUBv X-Received: by 2002:a63:5102:: with SMTP id f2-v6mr4870570pgb.31.1541027419266; Wed, 31 Oct 2018 16:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541027419; cv=none; d=google.com; s=arc-20160816; b=pYYlPVcHCxDMnaqOuliGlrutbur7nt1JMa8D+CWgEMhwWWBSOXQAXtFoKFTb36BaqQ pAkiVTVyFFYPmKwediAV9XOzhZnQs0fBHeQ5OX7Uz3KMN8F6+yz1X0PIilI22a76F0PK Sq6oi6weoZJnRjwlZX0TrJ7MIRmKk2vrekAbJaaGSCbicFHC86kya65oxd3Wcazn3PA3 4q8s7S2sE7rCgY8jt+axvO0AvDuaAAcH6iyiHJHsOBjG7E0GZKNmEeFp1HpTpR7MAyck jpx3E6uIRPoloKKzYSmepNGIS8+VISExs64UxStBgpayCj7AQmYXp/pHugJ8w6N7uFVX 9X/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=eWpjtI/DnnAc3TU255pgFPllH7PpXNcJQxzN92DAXts=; b=rBtBf0e2TPd6JjBv6e/q4PYXKkjMimtNOO9RrLVMJPhvDlQu1XhDoriCso2q1KhyKP xsJIHgm+xeSTRyu6QtUTIT9+qdqtrdDgPX+LCG/z9uJFIqW5GWQ7XBmWoZQht/R6tXug KHxAPK02p+wFMI9Wrjd5vV5DDLB3+8begQ4WHn5E+bwACpcF2m7uzojyLIWwOWOJyWHF 7wCRH1edlsPyBnaJToj76AFjnq8eojzx6S7qluLnLaEO/GxbNOUUSDaeWntgkx2xEIuq QIHutcC99YCcuO15vpdCNXApjLL+47uYVWv9KQnJ+HACSWb1aZwm+GQQ/ZPUeZMwiJ96 EFOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l+cm+BRS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14-v6si25277901pge.225.2018.10.31.16.10.18; Wed, 31 Oct 2018 16:10:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=l+cm+BRS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731041AbeKAIK1 (ORCPT + 32 others); Thu, 1 Nov 2018 04:10:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:32972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731001AbeKAIK1 (ORCPT ); Thu, 1 Nov 2018 04:10:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7FEC92084A; Wed, 31 Oct 2018 23:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027415; bh=2FMjQxYq/l7GYTY6uzZ29YFm2uYqiuIcHfDB+fyomzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l+cm+BRSCAxzvidk8g8N/bZF/s2jKX6hwiEFWhEhi4A8rwhaBKi6efDJyD1ULPXGL efuhNs4bn7fWJ/AnvtlJAeVRDCsOEnB+Xp3REcHzPxcRRoalZwW6PhyFIdfovbMPp+ +8fXzZMjINRavQSm0F+F2phNKzpDfReryfQHatRY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paolo Valente , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.14 29/73] block, bfq: correctly charge and reset entity service in all cases Date: Wed, 31 Oct 2018 19:09:04 -0400 Message-Id: <20181031230948.29203-29-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230948.29203-1-sashal@kernel.org> References: <20181031230948.29203-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Valente [ Upstream commit cbeb869a3d1110450186b738199963c5e68c2a71 ] BFQ schedules entities (which represent either per-process queues or groups of queues) as a function of their timestamps. In particular, as a function of their (virtual) finish times. The finish time of an entity is computed as a function of the budget assigned to the entity, assuming, tentatively, that the entity, once in service, will receive an amount of service equal to its budget. Then, when the entity is expired because it finishes to be served, this finish time is updated as a function of the actual service received by the entity. This allows the entity to be correctly charged with only the service received, and then to be correctly re-scheduled. Yet an entity may receive service also while not being the entity in service (in the scheduling environment of its parent entity), for several reasons. If the entity remains with no backlog while receiving this 'unofficial' service, then it is expired. Also on such an expiration, the finish time of the entity should be updated to account for only the service actually received by the entity. Unfortunately, such an update is not performed for an entity expiring without being the entity in service. In a similar vein, the service counter of the entity in service is reset when the entity is expired, to be ready to be used for next service cycle. This reset too should be performed also in case an entity is expired because it remains empty after receiving service while not being the entity in service. But in this case the reset is not performed. This commit performs the above update of the finish time and reset of the service received, also for an entity expiring while not being the entity in service. Signed-off-by: Paolo Valente Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-wf2q.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 414ba686a847..c1727604ad14 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1172,10 +1172,17 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree) st = bfq_entity_service_tree(entity); is_in_service = entity == sd->in_service_entity; - if (is_in_service) { - bfq_calc_finish(entity, entity->service); + bfq_calc_finish(entity, entity->service); + + if (is_in_service) sd->in_service_entity = NULL; - } + else + /* + * Non in-service entity: nobody will take care of + * resetting its service counter on expiration. Do it + * now. + */ + entity->service = 0; if (entity->tree == &st->active) bfq_active_extract(st, entity); From patchwork Wed Oct 31 23:09:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149913 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp111795ljp; Wed, 31 Oct 2018 16:23:16 -0700 (PDT) X-Google-Smtp-Source: AJdET5cnc7s15gkqsC7qZgciLe8Xjtz6O2C59V9fMXFUDM72rMDc2alyuMWU1qAWB2wyGH1Xwj5a X-Received: by 2002:a62:9f11:: with SMTP id g17-v6mr5275640pfe.144.1541028196618; Wed, 31 Oct 2018 16:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541028196; cv=none; d=google.com; s=arc-20160816; b=Y4WOKKEX7yOQdO5LK/Fs01E0XeHkHczPqqluunVe5dZpOz7igcrjs9iEOkBSJxwFbz WK6IRnXH4N7xxl9JKTBZBIIV+0/kBMVZCR33qEcOu3LG199Icd0KbqFl6FQF43yYV3Gz XNyP9Danj1tIg2P71fTwmhDhnUtwDqlJlb7vk42ybGr0nlUDrRBC3nyIa7t/Q5/mKEJN xjuu5InLQFRXmRKH1LxUNJsRVwTW/S5OZHKaOXuROyhR5yEh0mDOXFquqGrSA/QE/yH1 rcXetv8Hv2GFm6JMTw8La/VE8cwi8V6B+kSyM3mM7A5jPj3q22dif1+4TzXX4gKzRY7L WZPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=A1rTQmK1rP5vv4JYcvZrwuri1jehBXkusafKaa1smZI=; b=IczRt9nhg7+Fg+VvdaHFJtUz/TlzVFfF+qHHvPs2PFIVokuA+CK/DWATqzRGkbRv7R szwhoZm9WDmQhMK7AE+xwpyhdCnjbIU19YnXVdp71OqGfX7uvc6wqw+7+AhzeJualQNM 1SH29Er9ip6iZP4tE7Lk0XVvdlRJlWxuMF7R3/Un2DPfPTujkgJCrZUzhjh8i4x7oq63 qgSQROK6X/y6CytsXe7wV6diKLecyGapFqe/09z88sEjNIwcjcU2JIB5FBDYzXKuqrIO gjD1UVvRlIisPGeiisVvYdByMOWonpKlZ1Aeo9b5274S0CFmh0fxmrH0kfEYm6Ba+cLH NMOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=efxYpvyf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si27762077plo.191.2018.10.31.16.23.16; Wed, 31 Oct 2018 16:23:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=efxYpvyf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731554AbeKAIXa (ORCPT + 32 others); Thu, 1 Nov 2018 04:23:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:33924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730062AbeKAIK4 (ORCPT ); Thu, 1 Nov 2018 04:10:56 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4281E20664; Wed, 31 Oct 2018 23:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027444; bh=v47CDGbxOENzAMPOKoeJKAp11j0bzEXJHNMmoo5kuG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=efxYpvyfn7QwTfskhvBOAGxai9gd95QiPJB5Y0m3yFM1S/zEQsI1mm6FhXMGbds2I /VlwJYPjmzth2IPan6TWqVlBQY3CJNeDvWbHYBKwcxA7qs4qaZoHZ7uMC6xXIGeEr9 rhLdpL5DQF5fKI3SKfuwH6D09un9GmNR1tYr8AOU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Loic Poulain , Peter Chen , Sasha Levin Subject: [PATCH AUTOSEL 4.14 63/73] usb: chipidea: Prevent unbalanced IRQ disable Date: Wed, 31 Oct 2018 19:09:38 -0400 Message-Id: <20181031230948.29203-63-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230948.29203-1-sashal@kernel.org> References: <20181031230948.29203-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Loic Poulain [ Upstream commit 8b97d73c4d72a2abf58f8e49062a7ee1e5f1334e ] The ChipIdea IRQ is disabled before scheduling the otg work and re-enabled on otg work completion. However if the job is already scheduled we have to undo the effect of disable_irq int order to balance the IRQ disable-depth value. Fixes: be6b0c1bd0be ("usb: chipidea: using one inline function to cover queue work operations") Signed-off-by: Loic Poulain Signed-off-by: Peter Chen Signed-off-by: Sasha Levin --- drivers/usb/chipidea/otg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h index 9ecb598e48f0..a5557c70034a 100644 --- a/drivers/usb/chipidea/otg.h +++ b/drivers/usb/chipidea/otg.h @@ -20,7 +20,8 @@ void ci_handle_vbus_change(struct ci_hdrc *ci); static inline void ci_otg_queue_work(struct ci_hdrc *ci) { disable_irq_nosync(ci->irq); - queue_work(ci->wq, &ci->work); + if (queue_work(ci->wq, &ci->work) == false) + enable_irq(ci->irq); } #endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */ From patchwork Wed Oct 31 23:09:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149912 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp111119ljp; Wed, 31 Oct 2018 16:22:33 -0700 (PDT) X-Google-Smtp-Source: AJdET5ePQMyTRHVDFGgRYxkFjDZb9xDHkt5tNIElmaQ8v34FtdwMVsiLnJBkUm80kd6MmYBufm6o X-Received: by 2002:a17:902:e81:: with SMTP id 1-v6mr5309057plx.48.1541028153500; Wed, 31 Oct 2018 16:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541028153; cv=none; d=google.com; s=arc-20160816; b=DdGiYIUQqds2+npiHXRT+2+Ij9ZtAtz1ypxtUqtDV3gFrr2wCzlJXQNHVcicHgqZvq UU8ul5BC5vkY12NkId/no5wzp/xQAHInRP00TAdkALB0I/icIbiA9fVvz8kbR5QT+ide y1zqoVXoZJkJTq7++O8d8UW11WQ6EbfHu5XgfmWvPJ7xIwxWYZ/PVX5JQGbwIX9WVopf bS2uAyux/50JqRAwUuFN0Q+uENG656QYd+ZzgmeM+VmDpA9/EcHr1/wNglhFIvo3G8Ym 1ZpyHJwmh7Sd9ME6YZxDga4pXyQuWOYw0N/Coo1SgcC0jW7UWSIWynwRmdoAPm0meaq6 alJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=KfwBBXUY7KPFSKuX+ysNfgSSTPRT4Us99Q3vxyTNxwE=; b=Tfrk2Eq8CBa/HTiTpX6i11hb7xbzyOU4agTZeKF6ASEsmXzrqZC/S/0dH5PNsqiJ49 13mC4KhiMemZdAUScfyOjNvzS+upHss7zg1bo5e5pVx7Zbq3Ok4h1Pz96KohiYCeu3yC z8Q1+sh7aOESJkai04hnb3Gn4gPcaBE8+KGKCjbsksi3Nq/EfkKFZ3iVXlWTc0yDDbBS itbDEjJBoxKd7SeXfvSk+FdW3zyCLeKueVWP4Mk2iYM2hgDeYVYR3KcifN21E0YVHTuY A+Le1ubyrpbdrq9OIYcoHCJ9s3JqY0US+2WpVbZb7jChfBpFGr7fFTP/RA7lI81cpHey aZiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hpp3HWVV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h37-v6si28501496pgl.370.2018.10.31.16.22.33; Wed, 31 Oct 2018 16:22:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=Hpp3HWVV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731661AbeKAIWq (ORCPT + 32 others); Thu, 1 Nov 2018 04:22:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:34080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731339AbeKAILB (ORCPT ); Thu, 1 Nov 2018 04:11:01 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B066520840; Wed, 31 Oct 2018 23:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027449; bh=o4ApQr+p81eAIktmU8Gd/ftbRsga8GY5v1fFnZ4MYn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hpp3HWVVPuVgMDnloXpVrPKivcQt5YFuNrpIZ31IqpsSCFT6FXa43KeoSVhOhqJlc mJ2+6WiwZYgUqXioXHQh4sS3KplyyU0xUIlZ7ZU1jGnLMleoO7zTeCLnPb/dnZ23Y6 Hnqcu6y65rJMUJjQIMsCS0/batqsoQty5SSK8gso= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yunlei He , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH AUTOSEL 4.14 68/73] f2fs: report error if quota off error during umount Date: Wed, 31 Oct 2018 19:09:43 -0400 Message-Id: <20181031230948.29203-68-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230948.29203-1-sashal@kernel.org> References: <20181031230948.29203-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunlei He [ Upstream commit cda9cc595f0bb6ffa51a4efc4b6533dfa4039b4c ] Now, we depend on fsck to ensure quota file data is ok, so we scan whole partition if checkpoint without umount flag. It's same for quota off error case, which may make quota file data inconsistent. generic/019 reports below error: __quota_error: 1160 callbacks suppressed Quota error (device zram1): write_blk: dquota write failed Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota Quota error (device zram1): write_blk: dquota write failed Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota Quota error (device zram1): write_blk: dquota write failed Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota Quota error (device zram1): write_blk: dquota write failed Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota Quota error (device zram1): write_blk: dquota write failed Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota VFS: Busy inodes after unmount of zram1. Self-destruct in 5 seconds. Have a nice day... If we failed in below path due to fail to write dquot block, we will miss to release quota inode, fix it. - f2fs_put_super - f2fs_quota_off_umount - f2fs_quota_off - f2fs_quota_sync <-- failed - dquot_quota_off <-- missed to call Signed-off-by: Yunlei He Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/super.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index eae35909fa51..7cda685296b2 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1488,7 +1488,9 @@ static int f2fs_quota_off(struct super_block *sb, int type) if (!inode || !igrab(inode)) return dquot_quota_off(sb, type); - f2fs_quota_sync(sb, type); + err = f2fs_quota_sync(sb, type); + if (err) + goto out_put; err = dquot_quota_off(sb, type); if (err) @@ -1507,9 +1509,20 @@ static int f2fs_quota_off(struct super_block *sb, int type) void f2fs_quota_off_umount(struct super_block *sb) { int type; + int err; - for (type = 0; type < MAXQUOTAS; type++) - f2fs_quota_off(sb, type); + for (type = 0; type < MAXQUOTAS; type++) { + err = f2fs_quota_off(sb, type); + if (err) { + int ret = dquot_quota_off(sb, type); + + f2fs_msg(sb, KERN_ERR, + "Fail to turn off disk quota " + "(type: %d, err: %d, ret:%d), Please " + "run fsck to fix it.", type, err, ret); + set_sbi_flag(F2FS_SB(sb), SBI_NEED_FSCK); + } + } } int f2fs_get_projid(struct inode *inode, kprojid_t *projid)