From patchwork Wed Nov 27 20:29:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180331 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6644476ilf; Wed, 27 Nov 2019 12:59:00 -0800 (PST) X-Google-Smtp-Source: APXvYqyFTTxjRe3GB+MAJDokBht7HNbgL04eRIAJU2fmckRNGp3H12cJUzo3prLe3xExJ9Eo3zKa X-Received: by 2002:a17:906:1611:: with SMTP id m17mr52349645ejd.281.1574888340667; Wed, 27 Nov 2019 12:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888340; cv=none; d=google.com; s=arc-20160816; b=M0H2351yr+9CxX7uwBUqmxc+9DwGT4JKWOz4sk+MaZM44QizpVbh8qg9Jem0xekuGF A3aQwbvb36VZniRmlK7VBBtDrv8xKK3zBrwmbYACtsH7UVPBxxCJynbr3N2uRdRGKdNq 9SG3nGeKhLQHmxafukWDt/HFSAFc6O1IeReph+qDcLh0+hAuydxfEABE2CC9XdTUnu2j SyWu1paArQRSicgyM34LjQ1rLkO7ZUXS/olR4M006sPKUUMe88NVQqo+lEKU+1c1uMyy QCEiva804PJhOsk5nkoS1XV+2VwraKgD4XuO0FydxGUAx4ZmYkBZgKlIMvDWDfCYlrDd md2A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=83uXGCc5E2l5ebIxSQOTeerrjmH4Hd0k0R3Hk29rlWg=; b=cuPKUUC31FtbI81r5aI60APybr8rYN0XQLWYUzoLhfBoWfvI1HdnzUZkVWMcGkgeFB ZhIh8OTgLAbpuD2zfJh2N3/4eXrBkXJ5Rnd2WNMQ5vfxYFhnXFcmDKtukByqovHRqc3+ 3r28uvbK0r2S/EJwjcOVF+X7CvvgKWbWHFvSrmF9n4nai9wLv1Tl8j/Pr00NW27zzmHy 2RFqQqpBAo52swJneMuYsVB8PZcC/lc3VTrXM3JAznuHhpuodayih9Zdcq1mkYHUOCPv sc58g0/Rskc3PwkpEB4HxhWWHBn7wmYgTpB6QlGjkJ4RVUZUOwhCcPRy6S6vsuZU40E4 5AzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=es1JX6w1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cz19si1597201edb.109.2019.11.27.12.59.00; Wed, 27 Nov 2019 12:59:00 -0800 (PST) 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=es1JX6w1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731365AbfK0U66 (ORCPT + 26 others); Wed, 27 Nov 2019 15:58:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:50316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730816AbfK0U6z (ORCPT ); Wed, 27 Nov 2019 15:58:55 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A192E20678; Wed, 27 Nov 2019 20:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888334; bh=d5aN0u3+tlQOnw6rz7zLvdGW+WvOSXR1GFhj+QuTke8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=es1JX6w1lCWDxeW1v6EK3tIeSOfa5dGxBUKCzhbTCon/bg81KWwe3EC/5WuE9A7R7 Q//F4SSz2HaMUAeIsw1b8FeN4nW9JhXbeSO6VxEGzvpGvvVH79J6la7F+cgCmLNeIy 0mskWH7uLRm/y9H5Fm47dYidQu2m8c0WEl7dTfPo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ulf Hansson , Lina Iyer , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.19 092/306] PM / Domains: Deal with multiple states but no governor in genpd Date: Wed, 27 Nov 2019 21:29:02 +0100 Message-Id: <20191127203121.631580626@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ulf Hansson [ Upstream commit 2c9b7f8772033cc8bafbd4eefe2ca605bf3eb094 ] A caller of pm_genpd_init() that provides some states for the genpd via the ->states pointer in the struct generic_pm_domain, should also provide a governor. This because it's the job of the governor to pick a state that satisfies the constraints. Therefore, let's print a warning to inform the user about such bogus configuration and avoid to bail out, by instead picking the shallowest state before genpd invokes the ->power_off() callback. Signed-off-by: Ulf Hansson Reviewed-by: Lina Iyer Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/base/power/domain.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index bf5be0bfaf773..52c292d0908a2 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -467,6 +467,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, return -EAGAIN; } + /* Default to shallowest state. */ + if (!genpd->gov) + genpd->state_idx = 0; + if (genpd->power_off) { int ret; @@ -1686,6 +1690,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd, ret = genpd_set_default_power_state(genpd); if (ret) return ret; + } else if (!gov) { + pr_warn("%s : no governor for states\n", genpd->name); } device_initialize(&genpd->dev); From patchwork Wed Nov 27 20:29:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180349 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6674439ilf; Wed, 27 Nov 2019 13:26:38 -0800 (PST) X-Google-Smtp-Source: APXvYqyPDs58gxhd6Ca9rY/mU0EdI/C6hJmpmYGx1k30hxf3wuPUNpQRCXm1+MKMurcvAe579V/F X-Received: by 2002:a05:6402:1a50:: with SMTP id bf16mr34488420edb.116.1574889998735; Wed, 27 Nov 2019 13:26:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889998; cv=none; d=google.com; s=arc-20160816; b=u7FTUushkTho27/Qfk1dQSDmbp2WKpMHgvZIHo3STcpW4nkIyhoxnmlDSpm9EPT+9Y VbsFkXQZg3Ek7+kuye4AjXOiPCP9bpNqfDXzSF4wsuzoxron+nbzT09KwynLHaHNJCU7 ln3Vc43IMgvDh/Xhu30ztoqtJDwdELmfISCrmbGFs99sa4c6SngDEjfJa96+qNmk8ksn FlScfhoChzaIKLQYrM7+nklXwz15kfHy0QY+orNMD9BXbWLHdvgEViajYSkfgTu0pUNH 8GjSj0OyOXP6GUfokCAnsxIRzh5pJFlWxShhSsptjluJU332VMj1qEGuuMJOVuyEMeGN nu/g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xAqNQXpz/EEtJlT/73j2b1RDG10dlxV0ojHxBZ5B6Mo=; b=BfVQnoC/ZINQdOStacG0KGV2KCYDSvL9dfMtoc71DhY0V93fXflM0QZDToke8lJ4S6 1E5v9ErxbTa8mv/3rJx23MaKWd7jaDWO/HgDGqo8Bkz+uCi2YW5IlmBJxeoHp41Lb70m TZ8OIGHAnJRG5jB/RXl6yJO/52cC9V5+XEOS757va9zIt0+8NqRcnEto0ghKe9KABX+m j8Loc3WU9VVnYFbJHmICVs6hjaJddBAxS8XjqW67ri7Nk0vpks2pDv9c9j1yw/o/cn8z CMHZJ2FERm2Ww54UZiXumVATIyB4R1+EZ00CtsLYLsAOZLcTG/rdSpj04XFj8bR3C1L8 Jvlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yRn21wEu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si11357004edq.409.2019.11.27.13.26.38; Wed, 27 Nov 2019 13:26:38 -0800 (PST) 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=yRn21wEu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731562AbfK0VA1 (ORCPT + 26 others); Wed, 27 Nov 2019 16:00:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:52222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731540AbfK0VAU (ORCPT ); Wed, 27 Nov 2019 16:00:20 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE8242084B; Wed, 27 Nov 2019 21:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888420; bh=WeEIEc584qKbnLnJJjfQHq4AJ1PlgR0ZnvgFb83cxXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yRn21wEuZjCKYOWHsS5eXreXHBCupVOKiq39HpHNtIRro+dfg7kqSJ9QLfNQ+5FU5 d3AFDJeXg+xxQ6IdO2TlmkT4lmEBdRhXFjhS1LbQu/z53yjH7pp2TwnIhkaDirhZ9A zW5AnqBrlGegrkxEDkIJD9R9n/0/8Y9CUIgMQTmc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ivan Khoronzhuk , Grygorii Strashko , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 126/306] net: ethernet: ti: cpsw: unsync mcast entries while switch promisc mode Date: Wed, 27 Nov 2019 21:29:36 +0100 Message-Id: <20191127203124.320663717@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ivan Khoronzhuk [ Upstream commit 9737cc99dd14b5b8b9d267618a6061feade8ea68 ] After flushing all mcast entries from the table, the ones contained in mc list of ndev are not restored when promisc mode is toggled off, because they are considered as synched with ALE, thus, in order to restore them after promisc mode - reset syncing info. This fix touches only switch mode devices, including single port boards like Beagle Bone. Fixes: commit 5da1948969bc ("net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update") Signed-off-by: Ivan Khoronzhuk Reviewed-by: Grygorii Strashko Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/ti/cpsw.c | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 1afed85550c0a..8417d4c178447 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -642,6 +642,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable) /* Clear all mcast from ALE */ cpsw_ale_flush_multicast(ale, ALE_ALL_PORTS, -1); + __dev_mc_unsync(ndev, NULL); /* Flood All Unicast Packets to Host port */ cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1); From patchwork Wed Nov 27 20:29:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180332 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6646153ilf; Wed, 27 Nov 2019 13:00:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxJ8v80dOaTNqQa+g45j95aqjTjRdITYME8MCFM3qLqs7+sfyAs58LVpqAzm8mrtKm8NCL8 X-Received: by 2002:a17:906:bb03:: with SMTP id jz3mr28052415ejb.314.1574888436725; Wed, 27 Nov 2019 13:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888436; cv=none; d=google.com; s=arc-20160816; b=F1LiDtZ/rGRJLVAqOZiuvmu21U1hLqd4RC7x/7ofHks0eXetFntFUKUqsS46mU2fiN EMd8ShUVz2/GmHU1I5ZAdGw8I407MvNn3h9J9xKyO25X2xwwvbrf2Wsw0cGNZW9HMVv0 0+3HVoqA9iXeLHy+8ZewUxAAFt+YrXCqb8hu8Jye3fjN0XlsyqHK2Q3Z/Q1RGPxesQQi s/5KdQ2lJ7zxXK0bemWe2KLSaUDSg+ry4bVH7dGCa/V10rnCCaLHSYXYZguD1dbYSYzc IJnuFQCa2/xigGWn0Ram6XkA5jtjBYDc9CVx+9vf7B6irkO7PziFZpx+y9EnO0hie4DB Tm4A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f2LyFBNTq0/ASJIFRkSwESDb/8lyB3wt0LBLTpBMUTo=; b=K99pGCrwRSHd/es6tcXk8tz1kIOXcVr4iLn0rLNhOiYN4IV6YzspX6wJd0GmSru0w+ uYv7tsw6Z6/KD2COCWB64yBxl2Bm9+l8bg1dsbiCckHLeVD9/e+1rli/nT39EnP+jznW iIvD+DzaWH/IjwtTkv4cIH6ulTxAVCam/Ukf6Rw+GpIpWQsduB1H81w3KugCQgF2tLKE g3LinNASOm+hBMPW5r76jNTYOUE1+j3Uh6Axns1sm8W5QyMVDwSl7Ksyciw1rcl8j/uw ACzb6yDcdIHWfvt0ZVBVpS2tfBQZ6DSDSNqthaSPoll7DY+jgKK/oys0EjlT9a9Vakgy /7ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xlfTblkX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jx9si10518258ejb.32.2019.11.27.13.00.36; Wed, 27 Nov 2019 13:00:36 -0800 (PST) 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=xlfTblkX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731012AbfK0VAf (ORCPT + 26 others); Wed, 27 Nov 2019 16:00:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:52426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729481AbfK0VAb (ORCPT ); Wed, 27 Nov 2019 16:00:31 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 50AF82084B; Wed, 27 Nov 2019 21:00:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888430; bh=Wux2/6xePSbFE+QWcjf/7uQCjFGCFXhh9IaB2o/078A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xlfTblkXM8+sUZwRAhUtlW4LMTk39yeALtC7zwmDL7GGw0G7LQdC4Zw733oWDeH5I vBTSCWVk7ATkMbvsYQIJarAfWVWMSsbFU7vyQdbVyHCUzqNkPAVi6wlPsvbIZZoaAJ +J+Lde6aVK9nttZs26xY8Sx/L2l61EmR/im42FhM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Szyprowski , Krzysztof Kozlowski , Lee Jones , Sasha Levin Subject: [PATCH 4.19 130/306] mfd: max8997: Enale irq-wakeup unconditionally Date: Wed, 27 Nov 2019 21:29:40 +0100 Message-Id: <20191127203124.588678023@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marek Szyprowski [ Upstream commit efddff27c886e729a7f84a7205bd84d7d4af7336 ] IRQ wake up support for MAX8997 driver was initially configured by respective property in pdata. However, after the driver conversion to device-tree, setting it was left as 'todo'. Nowadays most of other PMIC MFD drivers initialized from device-tree assume that they can be an irq wakeup source, so enable it also for MAX8997. This fixes support for wakeup from MAX8997 RTC alarm. Signed-off-by: Marek Szyprowski Reviewed-by: Krzysztof Kozlowski Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/max8997.c | 8 +------- include/linux/mfd/max8997.h | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c index 3f554c4475218..d1495d76bf2c3 100644 --- a/drivers/mfd/max8997.c +++ b/drivers/mfd/max8997.c @@ -153,12 +153,6 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata( pd->ono = irq_of_parse_and_map(dev->of_node, 1); - /* - * ToDo: the 'wakeup' member in the platform data is more of a linux - * specfic information. Hence, there is no binding for that yet and - * not parsed here. - */ - return pd; } @@ -246,7 +240,7 @@ static int max8997_i2c_probe(struct i2c_client *i2c, */ /* MAX8997 has a power button input. */ - device_init_wakeup(max8997->dev, pdata->wakeup); + device_init_wakeup(max8997->dev, true); return ret; diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h index cf815577bd686..3ae1fe743bc34 100644 --- a/include/linux/mfd/max8997.h +++ b/include/linux/mfd/max8997.h @@ -178,7 +178,6 @@ struct max8997_led_platform_data { struct max8997_platform_data { /* IRQ */ int ono; - int wakeup; /* ---- PMIC ---- */ struct max8997_regulator_data *regulators; From patchwork Wed Nov 27 20:29:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180348 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6674382ilf; Wed, 27 Nov 2019 13:26:35 -0800 (PST) X-Google-Smtp-Source: APXvYqxgTafvfHC3aXx8y8Onkfzy9N2jr2ATpn3qRb8QIoS0HVcyF622qUKahXpwO1efjmUHUInN X-Received: by 2002:a17:906:13d5:: with SMTP id g21mr50722112ejc.72.1574889995524; Wed, 27 Nov 2019 13:26:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889995; cv=none; d=google.com; s=arc-20160816; b=Y0Sw1KhNN+o/tLO9keyyAQ2PCQ/yZ18b0IQiVWs2CW49+/yVIQ4j5MOt3x4M/qeloU gWa/JyUJIMjkDqiSkoFpLBpwu5LPex+k75bjbppmEBING5KGAyqAKCfTxJ/OBTVjMPZ6 dJm2O58yLfuuEJyrgUK7a/99BjaQ1tL53bc38As49mLcZHcf3Uk5KbUJIHWjSutNmWZh 0F+1oZ3DFbiL6/pjeHo5g69/1uLDLpLGCc5VZ17bTAlnQMKAeLWRLDARswJ/TQQR0Ycl BYcFnPEWi0EJTo94g1VDM6q5GEI+jHmw/UrperSBFfwMDoCXTTuAjr/DqPD4PyQU9EeD y4/g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rgofReuTMJmLMNbS4Y8UWZeD4v5WQJea56Z/SoPUYC8=; b=VZU02TRSfazSHz8ahlINwSQMAfnH98Vh64JNDaZKgrdOb0L43Iflkq3k7Vi/8fR17f jN7jUukrlHEq30oOwtbp7UQra50msQSoC822KDX/RXU//uIi1cM0ARmyOTD1PrWjPjiS 3rIh0teBktDr/oIXahjSI/vw1QSbmNJGWED4AB+8QCla5LaPJaT7Mopa9BaJFEI6FsmU 2U0S5VAp4TDNUgicqFxRMYLuAnGh7zHLRu0MxYgI8MMIrxdfkrXe+nB4fhtZgxfIzQf3 huByyj40iLMyFxw2uYycf6VqhdYoibTXqUfU+qA4pyWQ4NJcIcOXzudStw9PxDarlXYm BpNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y4UHGNKB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si10528459ejo.243.2019.11.27.13.26.35; Wed, 27 Nov 2019 13:26:35 -0800 (PST) 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=y4UHGNKB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731611AbfK0V0c (ORCPT + 26 others); Wed, 27 Nov 2019 16:26:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:52480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731578AbfK0VAe (ORCPT ); Wed, 27 Nov 2019 16:00:34 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE1952154A; Wed, 27 Nov 2019 21:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888433; bh=9bch6VTDVZgwC2rRZU7Zqnz8hEruZA8tajpvcVynNb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y4UHGNKBYN4QSNLXnAu+9ngxiJPHhJDwP9ZXxGQBJ0s02I9lQGUYQ5KAghiKDPLW9 M2ARi9PzKmYroTGfbsExF1FLbPwGnRE/dNDA3qYoGlILbL2iOn7GKtIWgenFxXkua8 3AoygjX2MktIE3RcrtITSa+orKl53JfjSfKVbWqY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahisa Kojima , Yoshitoyo Osaki , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 131/306] net: socionext: Stop PHY before resetting netsec Date: Wed, 27 Nov 2019 21:29:41 +0100 Message-Id: <20191127203124.655538998@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahisa Kojima [ Upstream commit 8e850f25b5812aefedec6732732eb10e7b47cb5c ] In ndo_stop, driver resets the netsec ethernet controller IP. When the netsec IP is reset, HW running mode turns to NRM mode and driver has to wait until this mode transition completes. But mode transition to NRM will not complete if the PHY is in normal operation state. Netsec IP requires PHY is in power down state when it is reset. This modification stops the PHY before resetting netsec. Together with this modification, phy_addr is stored in netsec_priv structure because ndev->phydev is not yet ready in ndo_init. Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver") Signed-off-by: Masahisa Kojima Signed-off-by: Yoshitoyo Osaki Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/socionext/netsec.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index d2caeb9edc044..28d582c18afb9 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -274,6 +274,7 @@ struct netsec_priv { struct clk *clk; u32 msg_enable; u32 freq; + u32 phy_addr; bool rx_cksum_offload_flag; }; @@ -1346,11 +1347,11 @@ static int netsec_netdev_stop(struct net_device *ndev) netsec_uninit_pkt_dring(priv, NETSEC_RING_TX); netsec_uninit_pkt_dring(priv, NETSEC_RING_RX); - ret = netsec_reset_hardware(priv, false); - phy_stop(ndev->phydev); phy_disconnect(ndev->phydev); + ret = netsec_reset_hardware(priv, false); + pm_runtime_put_sync(priv->dev); return ret; @@ -1360,6 +1361,7 @@ static int netsec_netdev_init(struct net_device *ndev) { struct netsec_priv *priv = netdev_priv(ndev); int ret; + u16 data; ret = netsec_alloc_dring(priv, NETSEC_RING_TX); if (ret) @@ -1369,6 +1371,11 @@ static int netsec_netdev_init(struct net_device *ndev) if (ret) goto err1; + /* set phy power down */ + data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR) | + BMCR_PDOWN; + netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data); + ret = netsec_reset_hardware(priv, true); if (ret) goto err2; @@ -1418,7 +1425,7 @@ static const struct net_device_ops netsec_netdev_ops = { }; static int netsec_of_probe(struct platform_device *pdev, - struct netsec_priv *priv) + struct netsec_priv *priv, u32 *phy_addr) { priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); if (!priv->phy_np) { @@ -1426,6 +1433,8 @@ static int netsec_of_probe(struct platform_device *pdev, return -EINVAL; } + *phy_addr = of_mdio_parse_addr(&pdev->dev, priv->phy_np); + priv->clk = devm_clk_get(&pdev->dev, NULL); /* get by 'phy_ref_clk' */ if (IS_ERR(priv->clk)) { dev_err(&pdev->dev, "phy_ref_clk not found\n"); @@ -1626,12 +1635,14 @@ static int netsec_probe(struct platform_device *pdev) } if (dev_of_node(&pdev->dev)) - ret = netsec_of_probe(pdev, priv); + ret = netsec_of_probe(pdev, priv, &phy_addr); else ret = netsec_acpi_probe(pdev, priv, &phy_addr); if (ret) goto free_ndev; + priv->phy_addr = phy_addr; + if (!priv->freq) { dev_err(&pdev->dev, "missing PHY reference clock frequency\n"); ret = -ENODEV; From patchwork Wed Nov 27 20:30:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180335 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6647301ilf; Wed, 27 Nov 2019 13:01:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwknw7bglsE7mwD7hnt9dd17dVg8/MPaseOvXQr4P+u+FM0oL2OUXyrLu9BxOihTGBy3te0 X-Received: by 2002:aa7:c883:: with SMTP id p3mr994833eds.130.1574888493400; Wed, 27 Nov 2019 13:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888493; cv=none; d=google.com; s=arc-20160816; b=IJiw7xqRjEDbuL5AmedWIIFj1inLJmZj0pHAnoaDXUIRodFaJJ2h2orVIhyoD5AXBx tKaUPd72dn6sglB3jS+s+Nw36kPsKD6MouThofpfxq4sMcJfV8mVA30NKEKIvYpn7qds QJ8pwMx021Bs2THoAsvHvczWMyodVJKPD3jKeia2gWwkusuQnnkuI5c/P4U14t5Qgtem 6EixfFJk8+T7d0uU/cp7gn9z++k21Bkwx88mXuH0zRPNsCNoj3d2pqVAEa5VYHhD2fMM biaKIpdw+LFOzuAtlX8eHaOQ6WhweBsd3ARoyfqsuAl+9Y33I2cxKB6Q9HAdQ3QGR6r8 MueA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jz//2/zmF1uLNex+dP9eVNW00/XTGI0+qNVcAIq846Y=; b=0XhdcTR8oZWODL84c/+1AjfXx50VeHuvUcFIJeUkcElactoD56TSe39+Mdq9cbqUd3 9A1XZaXdvDNyRarjWJ6f2T6nsxfGgtbRBwEYoVwSb4djJcaDCle3CfRdQke4Ii+xJUI4 bADjv7UMpOpGojc+RhQomk1iue02rK6HrcTaOyFLYohNoDhKKD/4EFUWfDdzIrB17BmO olWl0s2EP8/A6bLLAp1jixF4HQUBIVhxQb4wfS+BZxKFBbwpdkAER+v4T2T29nqhFzWb RiGmICzR8lFfUjgacxQcow2H+D2aN+cNcRts/hF9bSY5SuZEbXGF91HwWRruYFrcTVCm fXuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BgI5xlUh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si13023330ede.45.2019.11.27.13.01.33; Wed, 27 Nov 2019 13:01:33 -0800 (PST) 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=BgI5xlUh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731740AbfK0VBb (ORCPT + 26 others); Wed, 27 Nov 2019 16:01:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:53666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731720AbfK0VB1 (ORCPT ); Wed, 27 Nov 2019 16:01:27 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 173122158C; Wed, 27 Nov 2019 21:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888486; bh=NjWy5znEkoWXqsJzxRB5cmvhQBP3xr8ifrgF/0d3lR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgI5xlUhpFI3In54M94lMGY2Q+WMzYJCcAlp4sGvn7eeTBSwX3574wU5F3MLMStA/ 57IPHlbDxJ1PPylM/Q8dIi76LbEE9PBFXIQL/2aRF2xNBFnNv8+YQ8dxZV4pIDjheU C28VL6kbk/2kV4Bp6+8hvuK83E/uDRt90l3B4aUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Wolfram Sang , Sasha Levin Subject: [PATCH 4.19 154/306] i2c: uniphier-f: make driver robust against concurrency Date: Wed, 27 Nov 2019 21:30:04 +0100 Message-Id: <20191127203126.897078772@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit f1fdcbbdf45d9609f3d4063b67e9ea941ba3a58f ] This is unlikely to happen, but it is possible for a CPU to enter the interrupt handler just after wait_for_completion_timeout() has expired. If this happens, the hardware is accessed from multiple contexts concurrently. Disable the IRQ after wait_for_completion_timeout(), and do nothing from the handler when the IRQ is disabled. Fixes: 6a62974b667f ("i2c: uniphier_f: add UniPhier FIFO-builtin I2C driver") Signed-off-by: Masahiro Yamada Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-uniphier-f.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index bc26ec822e268..b9a0690b4fd73 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -98,6 +98,7 @@ struct uniphier_fi2c_priv { unsigned int flags; unsigned int busy_cnt; unsigned int clk_cycle; + spinlock_t lock; /* IRQ synchronization */ }; static void uniphier_fi2c_fill_txfifo(struct uniphier_fi2c_priv *priv, @@ -162,7 +163,10 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) struct uniphier_fi2c_priv *priv = dev_id; u32 irq_status; + spin_lock(&priv->lock); + irq_status = readl(priv->membase + UNIPHIER_FI2C_INT); + irq_status &= priv->enabled_irqs; dev_dbg(&priv->adap.dev, "interrupt: enabled_irqs=%04x, irq_status=%04x\n", @@ -230,6 +234,8 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) goto handled; } + spin_unlock(&priv->lock); + return IRQ_NONE; data_done: @@ -246,6 +252,8 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) handled: uniphier_fi2c_clear_irqs(priv); + spin_unlock(&priv->lock); + return IRQ_HANDLED; } @@ -311,7 +319,7 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, { struct uniphier_fi2c_priv *priv = i2c_get_adapdata(adap); bool is_read = msg->flags & I2C_M_RD; - unsigned long time_left; + unsigned long time_left, flags; dev_dbg(&adap->dev, "%s: addr=0x%02x, len=%d, stop=%d\n", is_read ? "receive" : "transmit", msg->addr, msg->len, stop); @@ -342,6 +350,12 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, priv->membase + UNIPHIER_FI2C_CR); time_left = wait_for_completion_timeout(&priv->comp, adap->timeout); + + spin_lock_irqsave(&priv->lock, flags); + priv->enabled_irqs = 0; + uniphier_fi2c_set_irqs(priv); + spin_unlock_irqrestore(&priv->lock, flags); + if (!time_left) { dev_err(&adap->dev, "transaction timeout.\n"); uniphier_fi2c_recover(priv); @@ -546,6 +560,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev) priv->clk_cycle = clk_rate / bus_speed; init_completion(&priv->comp); + spin_lock_init(&priv->lock); priv->adap.owner = THIS_MODULE; priv->adap.algo = &uniphier_fi2c_algo; priv->adap.dev.parent = dev; From patchwork Wed Nov 27 20:30:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180347 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6673538ilf; Wed, 27 Nov 2019 13:25:41 -0800 (PST) X-Google-Smtp-Source: APXvYqz29x57vVfZFb71SFWpvz1kovuJ/+SRDrXN+xG4I/s3OsdRZPzVeOD3r0pAxE42n+8cEzY8 X-Received: by 2002:aa7:c990:: with SMTP id c16mr34667298edt.91.1574889941559; Wed, 27 Nov 2019 13:25:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889941; cv=none; d=google.com; s=arc-20160816; b=fds28mvTeEcBhMpG0GU7zk7hHCEoA6Gi4mfUC8Kstldsts3pyGlAaLS/4mX2UER+/H RSZVJzxBjbXzULQQQdPcifLgPXJLv4zHOIarkpOh+UrnsyH4J9y4C4b5FmnpTfM1B44F HiG+7nB52N7S7fs4mI82eO7330LK7uFuAC5qIbVEDdHgeQhroI0daUufNq0/ObZWWqtE myASYK7L76F8kNR/12QWelvxMVq4alaWho/tLQ48wHUeYf+EdiOUHdiJ8uE200s3qWOi XqrQP7SBhCMC8mkd5Zi3lVo1IUukueaxHqN0sY5FRI2Oaxn0i+Jc+Mq+SuVYROZqeN6P 2xyw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yv/x3n3oH1IlsHslfuGw9kEP/V8UNUAWY6fS4jVFbLY=; b=dy9jeJ+fvPCojDZg2oOirsIWHccK1J6d51O3FgzQfsItMhNq5ZrS4qfQGjETytkq+g GD/6aNFcEy7LX+sLwiNH3jY0I4c89yQQbcXHl2MFefTTrlrYlay3DDCu/DxeuGCDG96J +wWk+8w7DS1GBN326/N3Nd2Q4Os2M/axy6YHP+8gM6GQrSnul7kCkQ3XdDez2AJwj2sE FA8onkKfOwM4hyG/Ov6BfaikQ1Iouze74FE+9m7DSPwIDcR/OZfGVMKR4veqaJMvBopb QtAdQiwTsQBadLFJ7NvHx0TPr158SWh3pXJZEyehLljKLBcPv/HYxtceKI07rAJZvGZI JQ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sYgAxl0I; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si12036572edy.92.2019.11.27.13.25.41; Wed, 27 Nov 2019 13:25:41 -0800 (PST) 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=sYgAxl0I; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731755AbfK0VBh (ORCPT + 26 others); Wed, 27 Nov 2019 16:01:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:53864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731741AbfK0VBc (ORCPT ); Wed, 27 Nov 2019 16:01:32 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0215E2086A; Wed, 27 Nov 2019 21:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888491; bh=by66fafWIkFfkatStvHYRKlIhFEru2T56686wGJEHj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sYgAxl0Io5qISfuhwSbxXlIDwF0tOnz1ZMuQ6xFX5YAiUBJA/51dCWngDsIRn7LRI M8OpiJ8un+pgljsOUUXVcaDe+F4txJNitqwMf2MJvT774cPrEcXWHKw9+93h4CmVnc lQQetkVPjTGrKD7XpbSY9b112B6BooJA2K78nH2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Wolfram Sang , Sasha Levin Subject: [PATCH 4.19 156/306] i2c: uniphier-f: fix race condition when IRQ is cleared Date: Wed, 27 Nov 2019 21:30:06 +0100 Message-Id: <20191127203126.999886239@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit eaba68785c2d24ebf1f0d46c24e11b79cc2f94c7 ] The current IRQ handler clears all the IRQ status bits when it bails out. This is dangerous because it might clear away the status bits that have just been set while processing the current handler. If this happens, the IRQ event for the latest transfer is lost forever. The IRQ status bits must be cleared *before* the next transfer is kicked. Fixes: 6a62974b667f ("i2c: uniphier_f: add UniPhier FIFO-builtin I2C driver") Signed-off-by: Masahiro Yamada Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-uniphier-f.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index bbd5b137aa216..928ea9930d17e 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -143,9 +143,10 @@ static void uniphier_fi2c_set_irqs(struct uniphier_fi2c_priv *priv) writel(priv->enabled_irqs, priv->membase + UNIPHIER_FI2C_IE); } -static void uniphier_fi2c_clear_irqs(struct uniphier_fi2c_priv *priv) +static void uniphier_fi2c_clear_irqs(struct uniphier_fi2c_priv *priv, + u32 mask) { - writel(-1, priv->membase + UNIPHIER_FI2C_IC); + writel(mask, priv->membase + UNIPHIER_FI2C_IC); } static void uniphier_fi2c_stop(struct uniphier_fi2c_priv *priv) @@ -172,6 +173,8 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) "interrupt: enabled_irqs=%04x, irq_status=%04x\n", priv->enabled_irqs, irq_status); + uniphier_fi2c_clear_irqs(priv, irq_status); + if (irq_status & UNIPHIER_FI2C_INT_STOP) goto complete; @@ -250,8 +253,6 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) } handled: - uniphier_fi2c_clear_irqs(priv); - spin_unlock(&priv->lock); return IRQ_HANDLED; @@ -340,7 +341,7 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, priv->flags |= UNIPHIER_FI2C_STOP; reinit_completion(&priv->comp); - uniphier_fi2c_clear_irqs(priv); + uniphier_fi2c_clear_irqs(priv, U32_MAX); writel(UNIPHIER_FI2C_RST_TBRST | UNIPHIER_FI2C_RST_RBRST, priv->membase + UNIPHIER_FI2C_RST); /* reset TX/RX FIFO */ From patchwork Wed Nov 27 20:30:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180336 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6647600ilf; Wed, 27 Nov 2019 13:01:48 -0800 (PST) X-Google-Smtp-Source: APXvYqw28fnbIXpt8gvG+kGaZYB3Oh0wLk3JeTmAes/HEoY3bZps51siBH75ZZAKFANhvG0hy0g6 X-Received: by 2002:a17:906:1d59:: with SMTP id o25mr50672802ejh.17.1574888508828; Wed, 27 Nov 2019 13:01:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888508; cv=none; d=google.com; s=arc-20160816; b=0SKXVhTP+Km8Cu71saGDf7m2XWNfRRj8F1wzGzVMG3q3TfV6oWF9Of4ntcBYFOhbAt CoLGZneQhXf4x0E9rEaXsl0/vLLW8MYDCeD/ebEwAif4nbrOrkjg1s0+fn5IteDhD8II FcIGObCH7lwvHehdjBlTgwzWMnqZf9AnV2wBaMvDH9OTi9VAY99JBrNMQcXMuLVCOLSQ BiEFJ4gsJhC/gGew9xKz+HPYiIN3VgcSB6UADbtuxSflzFmsbPQC8sOLaLzsvKWVXJuC mxyBEG3Asl2MoiUANe6vF8lSFGY8Tqr0wxhH997g5BDb8z4xfsEXaSBC0Rej9x6n8U69 P8TQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gb7coRBSB/H0dD3lzrlODgehlowbwQauj3Jkst49lvM=; b=wOVLwnCTyDOz00/iKuu6+g1E26I5lDxlyRtS4k5qA5HiBLM1Hfz2vitg6qQKSUNG75 cILYLJIIwc0eE65TIV1w2dVONniH701oqFVpXZcrMK145uHvn6BEbo2uKk6Hqa7KVAgy w3z7U+/POehNSVepua9m+RuUTUOMpi1vOG9DhTVCb9OGr05pr9UuVhJA0GA7nDu/pVNu mSHepTafvX9IoyAwkX8n8ej8qh6SL8fEPVRldMfJmi9qtn3HDlsbYKTo8IARzCL65GMn Pt+qd1/T0MyFBcSKD7FGR5RJX0Ml/W/0XszMQGyhksmchywW3k2SLIWFCZSIjEPi4Ozq 45+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xZz7WJVX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p24si9939798eja.385.2019.11.27.13.01.48; Wed, 27 Nov 2019 13:01:48 -0800 (PST) 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=xZz7WJVX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731783AbfK0VBq (ORCPT + 26 others); Wed, 27 Nov 2019 16:01:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:54092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731741AbfK0VBm (ORCPT ); Wed, 27 Nov 2019 16:01:42 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DA08A2158C; Wed, 27 Nov 2019 21:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888502; bh=mjEAf4IZiaoy69szyp+z+zduvvrVkJ634Pi2kNlx0nY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xZz7WJVXDS2bU0v7Sv8a0XSH7ngT2HGYxaZtko+VPeoQfbPoZKRwj3p+3gAbd5B9g q1WxZXKpXfjgUGCjkjj7ltjZHiWEa90PM6Mm/0wzAVFpo7o5YsZj47m72RXEnA3fV5 EmfkMtl6tNIsF8pgtW5hBS3hgDrWllD9q4l+e6HI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joel Stanley , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 160/306] powerpc/xmon: Relax frame size for clang Date: Wed, 27 Nov 2019 21:30:10 +0100 Message-Id: <20191127203127.204172470@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joel Stanley [ Upstream commit 9c87156cce5a63735d1218f0096a65c50a7a32aa ] When building with clang (8 trunk, 7.0 release) the frame size limit is hit: arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576 bytes in function 'xmon_core' [-Wframe-larger-than=] Some investigation by Naveen indicates this is due to clang saving the addresses to printf format strings on the stack. While this issue is investigated, bump up the frame size limit for xmon when building with clang. Link: https://github.com/ClangBuiltLinux/linux/issues/252 Signed-off-by: Joel Stanley Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/xmon/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile index 9d7d8e6d705c4..9ba44e190e5e4 100644 --- a/arch/powerpc/xmon/Makefile +++ b/arch/powerpc/xmon/Makefile @@ -13,6 +13,12 @@ UBSAN_SANITIZE := n ORIG_CFLAGS := $(KBUILD_CFLAGS) KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) +ifdef CONFIG_CC_IS_CLANG +# clang stores addresses on the stack causing the frame size to blow +# out. See https://github.com/ClangBuiltLinux/linux/issues/252 +KBUILD_CFLAGS += -Wframe-larger-than=4096 +endif + ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC) obj-y += xmon.o nonstdio.o spr_access.o From patchwork Wed Nov 27 20:30:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180337 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6647721ilf; Wed, 27 Nov 2019 13:01:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwEPf2k6jAdliWQHCEqY6nIwdvkN+Wr2VvpfKjFxmEE6D3sTIe5EWBUNpTuzOpbc9lrYOfC X-Received: by 2002:aa7:d517:: with SMTP id y23mr3571357edq.213.1574888514651; Wed, 27 Nov 2019 13:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888514; cv=none; d=google.com; s=arc-20160816; b=w8D2Y1RcOoKAiiWSUdhjdNium0M1Ego0cPQTZ7u93YX3orguTIXEzcE9LJMqmxFDuX AJXL+/Ls+s9a8biB6v7RnibZ8j2s89xrLJRo+eTAk2mVyUzlI4/ZtE0P5MI5cSaEgvHX A/9pfENDAxnrfVgMWVoOaoBuHJIw7rCfp8OtM2j1q483y+iR5D2Sh965GBglwTF8fzgX nW7Om2rTia3CrjsqT0X/Jn0khRDWLDT7CZXpIbRhxRSTM3ATcpF/9+kpkbYVb5cREzmV 18WS30zQcS6kvOquhdLZAI9DhgrqshYQpXL3JsNhJdlzIDdHGT/qLWFOMV85krGCMLp2 x/0g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vDDnXObKDUq1/ulsx9a7TBALNaYAZltxaJ1rrQ5pFaQ=; b=nUUN6GEyOvsQde559p/gyuCbiHBJzzUhcKEvoMdsLncCyaXhbFf5ZSCKfOfR8RTcgN tsgoJL5inTF+ss4GGsn6gMKpLqf7ZxxuuPcLVSD+CLVUTskcG4ujUu25OQ5HR5NsOmCO RKkSjL42rghi1yVoWZ/IThoZEhC74AnMk4k4C6ZJag4pYDGtC/tFdClcjKlFNN4l7VP/ Bhu3irdr76ifgMy+I4EG2STCYPY36BWx9riEcuvL5eBJRSdkMeOKhVZo8nRu5HaxYC8C pCTIknnsCcsfCvY6tFWMaXRoG2U0LcRO6+sUvGk7XydK3KFcYpm4CLod24z+zBEgj/dq Y7IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UvCQkH5S; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hh22si10213674ejb.275.2019.11.27.13.01.54; Wed, 27 Nov 2019 13:01:54 -0800 (PST) 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=UvCQkH5S; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729742AbfK0VBx (ORCPT + 26 others); Wed, 27 Nov 2019 16:01:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:54292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731787AbfK0VBu (ORCPT ); Wed, 27 Nov 2019 16:01:50 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 65A402084B; Wed, 27 Nov 2019 21:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888509; bh=nJ49gYhEL/vKBChnulon0sgeTedMmKmQ57sKJFu4eRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UvCQkH5SvXH19lUU65qs1+te24qMEQlKqcfLmtGVXt/XT+5USDWIjkiAWClSCZi4C 1pfC/8olllZOR9kWumy9QWbCAYmFUFhTlZT8j1ipinEFrTQRGyT0+kPHCP/5bN8+dH kZz8jwpDEqhMGroOV7uTohB1fk6ZC4TwAR6u+kTk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joel Stanley , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 162/306] selftests/powerpc/signal: Fix out-of-tree build Date: Wed, 27 Nov 2019 21:30:12 +0100 Message-Id: <20191127203127.315873242@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joel Stanley [ Upstream commit 27825349d7b238533a47e3d98b8bb0efd886b752 ] We should use TEST_GEN_PROGS, not TEST_PROGS. That tells the selftests makefile (lib.mk) that those tests are generated (built), and so it adds the $(OUTPUT) prefix for us, making the out-of-tree build work correctly. It also means we don't need our own clean rule, lib.mk does it. We also have to update the signal_tm rule to use $(OUTPUT). Signed-off-by: Joel Stanley Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- tools/testing/selftests/powerpc/signal/Makefile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/tools/testing/selftests/powerpc/signal/Makefile b/tools/testing/selftests/powerpc/signal/Makefile index 1fca25c6ace06..209a958dca127 100644 --- a/tools/testing/selftests/powerpc/signal/Makefile +++ b/tools/testing/selftests/powerpc/signal/Makefile @@ -1,15 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_PROGS := signal signal_tm - -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c ../utils.c signal.S +TEST_GEN_PROGS := signal signal_tm CFLAGS += -maltivec -signal_tm: CFLAGS += -mhtm +$(OUTPUT)/signal_tm: CFLAGS += -mhtm top_srcdir = ../../../../.. include ../../lib.mk -clean: - rm -f $(TEST_PROGS) *.o +$(TEST_GEN_PROGS): ../harness.c ../utils.c signal.S From patchwork Wed Nov 27 20:30:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180338 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6649907ilf; Wed, 27 Nov 2019 13:03:43 -0800 (PST) X-Google-Smtp-Source: APXvYqw4ECIWKkKnGHJKCFAMH0tqjJCemzhasKxc4sSs7373YmrF6IsaOWzVPHmKrY3jtXEGFsEA X-Received: by 2002:a7b:c10c:: with SMTP id w12mr6532442wmi.114.1574888623567; Wed, 27 Nov 2019 13:03:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888623; cv=none; d=google.com; s=arc-20160816; b=cW9kkHfbND6jic9Kog8EdEOVoPdRK5BQnZtOMc6xtBNuaYa91UKdU2RFqnLSz4C0dv BgJKGqGJcW+uaonFmSFuke7VPDucEHaPXH5DSeveuZc2ofN7bhdvqJrwwuJNSPO+W2qd N0W2OLnJRBt7KKbWrbXd3y+sB/qF0fafygCZdL5P/NGv1bEqwsyxvL1T19nZWMJTeQvf N0SU3J7n42W+ETVmKYJ2TR625nytdwLDk7zW425hxf2eGl0vcFOZwyqBK7M+IacXmLSC EyjO+Nw4iF4rr16gf8to8Lzsu0AGfMnh2HZKFCHoqzTFZAO1n4QB9eO2mc5+0mL+fzZo 1EBA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gaTR9CsJDVP8VLdRCG2F6SHKtz2MuPQde36wj2YWsrI=; b=bUbQXz+IUPW3qZL9gNwL9ftDDlycMNdglS7Cr1/X1Vn1xZzvdyU65jP6rxLBRpe6tt o3FvV7ZAc2oux9RV6pUBioCabiZSqLuo82cPmmbpk7nFZq2pRq8PF1n7k4xrRcWMfTce 1FUjOlTxbGS2yGfX6qsjpvqp42gbYS8RmtFaWlNK7wzOMFYe9qiKmqz+ImVffRULuhOq u+OsxEUjLMoRKI34tACtUzkKX9ELwzGUgywbCDyWDCj97mg2Lmfvd9Re2uCKaiicXLXT VQTBuFoVsPwbBbDLcVqj1dBl7sUQ2MFQHko+lZkJW7DL95m6ROiIvVy+s25usKLV+lK7 CJNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LAFR1FyI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dd6si1087018edb.186.2019.11.27.13.03.43; Wed, 27 Nov 2019 13:03:43 -0800 (PST) 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=LAFR1FyI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732063AbfK0VDl (ORCPT + 26 others); Wed, 27 Nov 2019 16:03:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:56784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732049AbfK0VDd (ORCPT ); Wed, 27 Nov 2019 16:03:33 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6FCBA2176D; Wed, 27 Nov 2019 21:03:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888612; bh=KG7jFFleSrAXnKXJdxb/7eBupZkKjYHi6r78Y7FcSD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LAFR1FyI24ayXK2G5VsI4a0qXsJtgK7AwkO/KBZtu7YgL2l407m2lZRkzsz+w4lT8 Gz2m0G5Ae8i+9U6K+rfP3/hPJ6hr3Y2OSlukT5FVfaL+eDTYpuB5iwRPqWsUHOuPrI i7kDy1DQjJG6KBSjZlQPbVI6yJVsUATVrU2gRWdQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 203/306] openvswitch: fix linking without CONFIG_NF_CONNTRACK_LABELS Date: Wed, 27 Nov 2019 21:30:53 +0100 Message-Id: <20191127203129.984214265@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit a277d516de5f498c91d91189717ef7e01102ad27 ] When CONFIG_CC_OPTIMIZE_FOR_DEBUGGING is enabled, the compiler fails to optimize out a dead code path, which leads to a link failure: net/openvswitch/conntrack.o: In function `ovs_ct_set_labels': conntrack.c:(.text+0x2e60): undefined reference to `nf_connlabels_replace' In this configuration, we can take a shortcut, and completely remove the contrack label code. This may also help the regular optimization. Signed-off-by: Arnd Bergmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/openvswitch/conntrack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 35ae64cbef33f..46aa1aa51db41 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -1199,7 +1199,8 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key, &info->labels.mask); if (err) return err; - } else if (labels_nonzero(&info->labels.mask)) { + } else if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && + labels_nonzero(&info->labels.mask)) { err = ovs_ct_set_labels(ct, key, &info->labels.value, &info->labels.mask); if (err) From patchwork Wed Nov 27 20:31:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180341 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6652548ilf; Wed, 27 Nov 2019 13:05:46 -0800 (PST) X-Google-Smtp-Source: APXvYqyLbjWqgI0+5ACu4z2OkJXndxUyC03nZZnlYBd8J/wg8V1P3pu+1DVW+0VjnutQ1oiqz7kw X-Received: by 2002:a1c:6a14:: with SMTP id f20mr5896072wmc.110.1574888746540; Wed, 27 Nov 2019 13:05:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888746; cv=none; d=google.com; s=arc-20160816; b=ma1ngfylkKWqFnF7RDcd1I6qbY7oEaYDcpvTVZPbVkpe+PenLQ/SC1xULWz723iz9A LnUlOTaPzpgZ9h6uXrdVXPBk35pjvSxcPq13DaPDzCb5t8sHrtBGMOBm9BrvZIbSKgL2 YRk/DpdZ4hTZf8KznWLHsC6+GDLe16DKXI3bapNwoaJ5QLvkpQeIeYRUYdEIhR5+oLGf fq5FjFx+0+0HZc3DrwysiGDLAuINM3crckxiRIVvr9XE5GRY0gQ14QKIhEzUOD9XIUb/ 6YViGbzZP4h57s1xRHrFySHwkleBF8EzrNN7BW6Ilu+jKPPgpKXsuEkPUHlaXX24t0dv wVGA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v05T8Yfkuc5Ze2QCTQxn82KYSE8WQXq6zr0YLbmohBM=; b=kxLE5vMIhft+Yht1/5s0Av+9WIYK2S7emrQX+Wlzxzw9iMNt9aIr/l6YoOwN1C1nxk mVw12diNBaC5nMtyeTaupqBi0JkxLcxBk3BlNSViPxkiyHekksDBunD/8/w775JWnOlK 24oillenuMjUtlygdhmLY2CZPRW1O3fAiixE0FmvImphOQ8cPTL+G5PEsdpYBbI3KXg/ 15X2Rw0osQ41m2zuaeJjwqjN1+Xt/D4XkmVgNGxBB5C7hYYW8qa8WK1G0QU7xPUmDHw3 0tKo5xb3dEq5Y8vj8ou9OnaE6sLwkwrk5ABcsSvu3KdpDphpfaaju3O8u51uHNcOF/UQ AVPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DAGe0ZKb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si11388434edg.23.2019.11.27.13.05.44; Wed, 27 Nov 2019 13:05:46 -0800 (PST) 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=DAGe0ZKb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730655AbfK0VFm (ORCPT + 26 others); Wed, 27 Nov 2019 16:05:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:59432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732310AbfK0VFi (ORCPT ); Wed, 27 Nov 2019 16:05:38 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 321BA21741; Wed, 27 Nov 2019 21:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888737; bh=vBFYOrfj1IE1io4Th6lrRDVblv4ioYm1LhZ/3QjbwXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DAGe0ZKbvahieeA1+txguNiL76LQHlgOLlKEs08/2dUKsRYNdpwo7bSIazhRcPhQw 26oj+oWn8nB26lbHNPtLmeTcZSeVZ83hC5ZqfTjNZRqewQ5JV0TEd89g90HWgJXcyM eXIIoDXOasfeocdpTFXiTh90/a/9BjhBW+MBJjxQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Wolfram Sang , Sasha Levin Subject: [PATCH 4.19 251/306] i2c: uniphier-f: fix timeout error after reading 8 bytes Date: Wed, 27 Nov 2019 21:31:41 +0100 Message-Id: <20191127203133.235034415@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit c2a653deaa81f5a750c0dfcbaf9f8e5195cbe4a5 ] I was totally screwed up in commit eaba68785c2d ("i2c: uniphier-f: fix race condition when IRQ is cleared"). Since that commit, if the number of read bytes is multiple of the FIFO size (8, 16, 24... bytes), the STOP condition could be issued twice, depending on the timing. If this happens, the controller will go wrong, resulting in the timeout error. It was more than 3 years ago when I wrote this driver, so my memory about this hardware was vague. Please let me correct the description in the commit log of eaba68785c2d. Clearing the IRQ status on exiting the IRQ handler is absolutely fine. This controller makes a pause while any IRQ status is asserted. If the IRQ status is cleared first, the hardware may start the next transaction before the IRQ handler finishes what it supposed to do. This partially reverts the bad commit with clear comments so that I will never repeat this mistake. I also investigated what is happening at the last moment of the read mode. The UNIPHIER_FI2C_INT_RF interrupt is asserted a bit earlier (by half a period of the clock cycle) than UNIPHIER_FI2C_INT_RB. I consulted a hardware engineer, and I got the following information: UNIPHIER_FI2C_INT_RF asserted at the falling edge of SCL at the 8th bit. UNIPHIER_FI2C_INT_RB asserted at the rising edge of SCL at the 9th (ACK) bit. In order to avoid calling uniphier_fi2c_stop() twice, check the latter interrupt. I also commented this because it is obscure hardware internal. Fixes: eaba68785c2d ("i2c: uniphier-f: fix race condition when IRQ is cleared") Signed-off-by: Masahiro Yamada Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-uniphier-f.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index 928ea9930d17e..dd0687e36a47b 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -173,8 +173,6 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) "interrupt: enabled_irqs=%04x, irq_status=%04x\n", priv->enabled_irqs, irq_status); - uniphier_fi2c_clear_irqs(priv, irq_status); - if (irq_status & UNIPHIER_FI2C_INT_STOP) goto complete; @@ -214,7 +212,13 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) if (irq_status & (UNIPHIER_FI2C_INT_RF | UNIPHIER_FI2C_INT_RB)) { uniphier_fi2c_drain_rxfifo(priv); - if (!priv->len) + /* + * If the number of bytes to read is multiple of the FIFO size + * (msg->len == 8, 16, 24, ...), the INT_RF bit is set a little + * earlier than INT_RB. We wait for INT_RB to confirm the + * completion of the current message. + */ + if (!priv->len && (irq_status & UNIPHIER_FI2C_INT_RB)) goto data_done; if (unlikely(priv->flags & UNIPHIER_FI2C_MANUAL_NACK)) { @@ -253,6 +257,13 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) } handled: + /* + * This controller makes a pause while any bit of the IRQ status is + * asserted. Clear the asserted bit to kick the controller just before + * exiting the handler. + */ + uniphier_fi2c_clear_irqs(priv, irq_status); + spin_unlock(&priv->lock); return IRQ_HANDLED; From patchwork Wed Nov 27 20:32:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180345 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6670691ilf; Wed, 27 Nov 2019 13:22:39 -0800 (PST) X-Google-Smtp-Source: APXvYqyRAjq7jDeCD8qHotXWAiC3BA4FhiyObHssWfyZQ+r4UyzmFrmKMqh9ltH8Vu39DcMcjTZ0 X-Received: by 2002:a50:fb85:: with SMTP id e5mr34418179edq.274.1574889652710; Wed, 27 Nov 2019 13:20:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889652; cv=none; d=google.com; s=arc-20160816; b=HHkyqojjq33uz4jUkpasABgIgDtp7+JvOPrdougk3f2kbO9MjTBx5sstExvmIcrn2j CCGwOVQ3FL5CsZPDjbV1fVwY4R1WePFFl3ArnzZaSEM/SbuRZUzvUvbomN9ileWRykhb VLajsvJoVoYh7BfgsPQV9hHxC0VTqNFfBa/yt4qyUBUzQNFVd49l9TILdKNzrAeVjiB4 NfNw6+YNn6OMHcFQTd4y4RY/OCLs+etCtmR2g8+NBGYdWgwzlUZb8cE5ckZAAYBDZ+42 rL2HPC0pRIKaL33J7SonV+NO23ffMgCc89eBoAJ7/FeesZtt/IKQHQARdwQe6eO1gRyJ dHHg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k41HibHRQ+t3IoeGWBb13mRee+X8I62EcWeopTK3QHA=; b=SkgLnf00kil75m5fJ4e3Fu6/XBVnfAnQp6EzNlSfJ9Zg4Mob/f6+Rm0dtNn7RpyFys hf4q3OaiDjiq3DjWZ7WO5CrEBMjWD6rDi4QiexJ+Uj2hZg+WM5eomPHQweJKhGxPEvHo UNINMzL91fvtT6aqe7crTx28mBEYXbq9fz9CVXFmKZ9T6APxhc5Y12M9bCLc+UKi8XGn XY8kzh91+gInHcybcS83tKFLTNttcWxJnrXUndlYdOs7DyoneC20/MypQYfzgCTsR7vC fyMcbX6409yG3lsnLE3Blqk8SMzESZ7lTU4GqeCyYOpIWjAQLUJQNxILAfbj/LV/AZtg wCGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d1t1eqb9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bs14si9821087ejb.292.2019.11.27.13.20.51; Wed, 27 Nov 2019 13:20:52 -0800 (PST) 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=d1t1eqb9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733036AbfK0VUt (ORCPT + 26 others); Wed, 27 Nov 2019 16:20:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:34844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732739AbfK0VIX (ORCPT ); Wed, 27 Nov 2019 16:08:23 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B4F9F215F1; Wed, 27 Nov 2019 21:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888902; bh=rwVidz6XXXoz+KHdhTWgIVkEZXInT2cKkzZxqvWz0KQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1t1eqb9wzn1ZkbzGu+lwGZP55abw0RZIacVJXflICJqKZRtHkT9NFSA4BO27q71f NYM3sXpf2JZbBkLR+RBz0uzQERV9mcvcx3ECMWAyvi0PVjNeqdXGfLV2IZhoHTui3t 9+0qc3lQpFv8B6naCSXcch7C1+y74nPlJNpMb6rE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann Subject: [PATCH 4.19 278/306] y2038: futex: Move compat implementation into futex.c Date: Wed, 27 Nov 2019 21:32:08 +0100 Message-Id: <20191127203135.110246790@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann commit 04e7712f4460585e5eed5b853fd8b82a9943958f upstream. We are going to share the compat_sys_futex() handler between 64-bit architectures and 32-bit architectures that need to deal with both 32-bit and 64-bit time_t, and this is easier if both entry points are in the same file. In fact, most other system call handlers do the same thing these days, so let's follow the trend here and merge all of futex_compat.c into futex.c. In the process, a few minor changes have to be done to make sure everything still makes sense: handle_futex_death() and futex_cmpxchg_enabled() become local symbol, and the compat version of the fetch_robust_entry() function gets renamed to compat_fetch_robust_entry() to avoid a symbol clash. This is intended as a purely cosmetic patch, no behavior should change. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- include/linux/futex.h | 8 - kernel/Makefile | 3 kernel/futex.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++- kernel/futex_compat.c | 202 -------------------------------------------------- 4 files changed, 192 insertions(+), 216 deletions(-) --- a/include/linux/futex.h +++ b/include/linux/futex.h @@ -9,9 +9,6 @@ struct inode; struct mm_struct; struct task_struct; -extern int -handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi); - /* * Futexes are matched on equal values of this key. * The key type depends on whether it's a shared or private mapping. @@ -55,11 +52,6 @@ extern void exit_robust_list(struct task long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, u32 __user *uaddr2, u32 val2, u32 val3); -#ifdef CONFIG_HAVE_FUTEX_CMPXCHG -#define futex_cmpxchg_enabled 1 -#else -extern int futex_cmpxchg_enabled; -#endif #else static inline void exit_robust_list(struct task_struct *curr) { --- a/kernel/Makefile +++ b/kernel/Makefile @@ -50,9 +50,6 @@ obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += time/ obj-$(CONFIG_FUTEX) += futex.o -ifeq ($(CONFIG_COMPAT),y) -obj-$(CONFIG_FUTEX) += futex_compat.o -endif obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o obj-$(CONFIG_SMP) += smp.o ifneq ($(CONFIG_SMP),y) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -44,6 +44,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include @@ -173,8 +174,10 @@ * double_lock_hb() and double_unlock_hb(), respectively. */ -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG -int __read_mostly futex_cmpxchg_enabled; +#ifdef CONFIG_HAVE_FUTEX_CMPXCHG +#define futex_cmpxchg_enabled 1 +#else +static int __read_mostly futex_cmpxchg_enabled; #endif /* @@ -3458,7 +3461,7 @@ err_unlock: * Process a futex-list entry, check whether it's owned by the * dying task, and do notification if so: */ -int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi) +static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi) { u32 uval, uninitialized_var(nval), mval; int err; @@ -3707,6 +3710,192 @@ SYSCALL_DEFINE6(futex, u32 __user *, uad return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); } +#ifdef CONFIG_COMPAT +/* + * Fetch a robust-list pointer. Bit 0 signals PI futexes: + */ +static inline int +compat_fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry, + compat_uptr_t __user *head, unsigned int *pi) +{ + if (get_user(*uentry, head)) + return -EFAULT; + + *entry = compat_ptr((*uentry) & ~1); + *pi = (unsigned int)(*uentry) & 1; + + return 0; +} + +static void __user *futex_uaddr(struct robust_list __user *entry, + compat_long_t futex_offset) +{ + compat_uptr_t base = ptr_to_compat(entry); + void __user *uaddr = compat_ptr(base + futex_offset); + + return uaddr; +} + +/* + * Walk curr->robust_list (very carefully, it's a userspace list!) + * and mark any locks found there dead, and notify any waiters. + * + * We silently return on any sign of list-walking problem. + */ +void compat_exit_robust_list(struct task_struct *curr) +{ + struct compat_robust_list_head __user *head = curr->compat_robust_list; + struct robust_list __user *entry, *next_entry, *pending; + unsigned int limit = ROBUST_LIST_LIMIT, pi, pip; + unsigned int uninitialized_var(next_pi); + compat_uptr_t uentry, next_uentry, upending; + compat_long_t futex_offset; + int rc; + + if (!futex_cmpxchg_enabled) + return; + + /* + * Fetch the list head (which was registered earlier, via + * sys_set_robust_list()): + */ + if (compat_fetch_robust_entry(&uentry, &entry, &head->list.next, &pi)) + return; + /* + * Fetch the relative futex offset: + */ + if (get_user(futex_offset, &head->futex_offset)) + return; + /* + * Fetch any possibly pending lock-add first, and handle it + * if it exists: + */ + if (compat_fetch_robust_entry(&upending, &pending, + &head->list_op_pending, &pip)) + return; + + next_entry = NULL; /* avoid warning with gcc */ + while (entry != (struct robust_list __user *) &head->list) { + /* + * Fetch the next entry in the list before calling + * handle_futex_death: + */ + rc = compat_fetch_robust_entry(&next_uentry, &next_entry, + (compat_uptr_t __user *)&entry->next, &next_pi); + /* + * A pending lock might already be on the list, so + * dont process it twice: + */ + if (entry != pending) { + void __user *uaddr = futex_uaddr(entry, futex_offset); + + if (handle_futex_death(uaddr, curr, pi)) + return; + } + if (rc) + return; + uentry = next_uentry; + entry = next_entry; + pi = next_pi; + /* + * Avoid excessively long or circular lists: + */ + if (!--limit) + break; + + cond_resched(); + } + if (pending) { + void __user *uaddr = futex_uaddr(pending, futex_offset); + + handle_futex_death(uaddr, curr, pip); + } +} + +COMPAT_SYSCALL_DEFINE2(set_robust_list, + struct compat_robust_list_head __user *, head, + compat_size_t, len) +{ + if (!futex_cmpxchg_enabled) + return -ENOSYS; + + if (unlikely(len != sizeof(*head))) + return -EINVAL; + + current->compat_robust_list = head; + + return 0; +} + +COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid, + compat_uptr_t __user *, head_ptr, + compat_size_t __user *, len_ptr) +{ + struct compat_robust_list_head __user *head; + unsigned long ret; + struct task_struct *p; + + if (!futex_cmpxchg_enabled) + return -ENOSYS; + + rcu_read_lock(); + + ret = -ESRCH; + if (!pid) + p = current; + else { + p = find_task_by_vpid(pid); + if (!p) + goto err_unlock; + } + + ret = -EPERM; + if (!ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS)) + goto err_unlock; + + head = p->compat_robust_list; + rcu_read_unlock(); + + if (put_user(sizeof(*head), len_ptr)) + return -EFAULT; + return put_user(ptr_to_compat(head), head_ptr); + +err_unlock: + rcu_read_unlock(); + + return ret; +} + +COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, + struct old_timespec32 __user *, utime, u32 __user *, uaddr2, + u32, val3) +{ + struct timespec ts; + ktime_t t, *tp = NULL; + int val2 = 0; + int cmd = op & FUTEX_CMD_MASK; + + if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || + cmd == FUTEX_WAIT_BITSET || + cmd == FUTEX_WAIT_REQUEUE_PI)) { + if (compat_get_timespec(&ts, utime)) + return -EFAULT; + if (!timespec_valid(&ts)) + return -EINVAL; + + t = timespec_to_ktime(ts); + if (cmd == FUTEX_WAIT) + t = ktime_add_safe(ktime_get(), t); + tp = &t; + } + if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || + cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) + val2 = (int) (unsigned long) utime; + + return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); +} +#endif /* CONFIG_COMPAT */ + static void __init futex_detect_cmpxchg(void) { #ifndef CONFIG_HAVE_FUTEX_CMPXCHG --- a/kernel/futex_compat.c +++ /dev/null @@ -1,202 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * linux/kernel/futex_compat.c - * - * Futex compatibililty routines. - * - * Copyright 2006, Red Hat, Inc., Ingo Molnar - */ - -#include -#include -#include -#include -#include -#include - -#include - - -/* - * Fetch a robust-list pointer. Bit 0 signals PI futexes: - */ -static inline int -fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry, - compat_uptr_t __user *head, unsigned int *pi) -{ - if (get_user(*uentry, head)) - return -EFAULT; - - *entry = compat_ptr((*uentry) & ~1); - *pi = (unsigned int)(*uentry) & 1; - - return 0; -} - -static void __user *futex_uaddr(struct robust_list __user *entry, - compat_long_t futex_offset) -{ - compat_uptr_t base = ptr_to_compat(entry); - void __user *uaddr = compat_ptr(base + futex_offset); - - return uaddr; -} - -/* - * Walk curr->robust_list (very carefully, it's a userspace list!) - * and mark any locks found there dead, and notify any waiters. - * - * We silently return on any sign of list-walking problem. - */ -void compat_exit_robust_list(struct task_struct *curr) -{ - struct compat_robust_list_head __user *head = curr->compat_robust_list; - struct robust_list __user *entry, *next_entry, *pending; - unsigned int limit = ROBUST_LIST_LIMIT, pi, pip; - unsigned int uninitialized_var(next_pi); - compat_uptr_t uentry, next_uentry, upending; - compat_long_t futex_offset; - int rc; - - if (!futex_cmpxchg_enabled) - return; - - /* - * Fetch the list head (which was registered earlier, via - * sys_set_robust_list()): - */ - if (fetch_robust_entry(&uentry, &entry, &head->list.next, &pi)) - return; - /* - * Fetch the relative futex offset: - */ - if (get_user(futex_offset, &head->futex_offset)) - return; - /* - * Fetch any possibly pending lock-add first, and handle it - * if it exists: - */ - if (fetch_robust_entry(&upending, &pending, - &head->list_op_pending, &pip)) - return; - - next_entry = NULL; /* avoid warning with gcc */ - while (entry != (struct robust_list __user *) &head->list) { - /* - * Fetch the next entry in the list before calling - * handle_futex_death: - */ - rc = fetch_robust_entry(&next_uentry, &next_entry, - (compat_uptr_t __user *)&entry->next, &next_pi); - /* - * A pending lock might already be on the list, so - * dont process it twice: - */ - if (entry != pending) { - void __user *uaddr = futex_uaddr(entry, futex_offset); - - if (handle_futex_death(uaddr, curr, pi)) - return; - } - if (rc) - return; - uentry = next_uentry; - entry = next_entry; - pi = next_pi; - /* - * Avoid excessively long or circular lists: - */ - if (!--limit) - break; - - cond_resched(); - } - if (pending) { - void __user *uaddr = futex_uaddr(pending, futex_offset); - - handle_futex_death(uaddr, curr, pip); - } -} - -COMPAT_SYSCALL_DEFINE2(set_robust_list, - struct compat_robust_list_head __user *, head, - compat_size_t, len) -{ - if (!futex_cmpxchg_enabled) - return -ENOSYS; - - if (unlikely(len != sizeof(*head))) - return -EINVAL; - - current->compat_robust_list = head; - - return 0; -} - -COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid, - compat_uptr_t __user *, head_ptr, - compat_size_t __user *, len_ptr) -{ - struct compat_robust_list_head __user *head; - unsigned long ret; - struct task_struct *p; - - if (!futex_cmpxchg_enabled) - return -ENOSYS; - - rcu_read_lock(); - - ret = -ESRCH; - if (!pid) - p = current; - else { - p = find_task_by_vpid(pid); - if (!p) - goto err_unlock; - } - - ret = -EPERM; - if (!ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS)) - goto err_unlock; - - head = p->compat_robust_list; - rcu_read_unlock(); - - if (put_user(sizeof(*head), len_ptr)) - return -EFAULT; - return put_user(ptr_to_compat(head), head_ptr); - -err_unlock: - rcu_read_unlock(); - - return ret; -} - -COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, - struct compat_timespec __user *, utime, u32 __user *, uaddr2, - u32, val3) -{ - struct timespec ts; - ktime_t t, *tp = NULL; - int val2 = 0; - int cmd = op & FUTEX_CMD_MASK; - - if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || - cmd == FUTEX_WAIT_BITSET || - cmd == FUTEX_WAIT_REQUEUE_PI)) { - if (compat_get_timespec(&ts, utime)) - return -EFAULT; - if (!timespec_valid(&ts)) - return -EINVAL; - - t = timespec_to_ktime(ts); - if (cmd == FUTEX_WAIT) - t = ktime_add_safe(ktime_get(), t); - tp = &t; - } - if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || - cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) - val2 = (int) (unsigned long) utime; - - return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); -}