From patchwork Thu Sep 5 16:17:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 173155 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp934898ilq; Thu, 5 Sep 2019 09:18:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjPcxrMC7V3b2GhIE80+g/HXWvoMItHEQIlO3k7AU15Jwpn1LqSWWlntHHTBXRJUXrMUll X-Received: by 2002:a17:902:a58c:: with SMTP id az12mr4460024plb.129.1567700290341; Thu, 05 Sep 2019 09:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567700290; cv=none; d=google.com; s=arc-20160816; b=tfTiAYSBQ31XunnQDaclimZK6r5fSuCctMuTmyT+XT8KA/ysKhC2e5RXc6uIBhX42I duetESQpCf2EVY3owSYu8E46t7SbkAWPKIFHfL+vXrpNW0/lrF7a/WG/3XUiLp6nJIPG bKNEl2ZzAuoO0THwdROfjIXNtfmwfn2rBZSQhEJUiFWWx4r5mD7HkbwGmGXKX/MWyUYW Zfos7AyoQYdzs9fXHoFdJX+0FdRmaIgljhiQFvWgQgCME4e4aZEztUZWWE3DBDAW2k6T lZzUx+j/tLZFSH4bCWnqM2t/Ezn45lLj6ywPe2J/A/VCdSp2UhIOhGYZ1/C8ZVG+KQ7R Td6Q== 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=oxweDnammrNyIt2aaQLCe6r9vThCpXKTK19Q9yGm1E4=; b=ZNgbTqJrczWFBBkYQ/inj7l07dk+tDNreU3QGuh6u1io/ATsD3cYCIV4mti8drBBSJ b1PKB1b1tHIF8oa8qZFrCeaRfEtVsy29431IRXvPT0+r4unegH6ueC2EKp7kRtND8QZS 4nVyUBQERUE4fxtcO9DNK0WqP8HPVcZpotKPJE/1CxjljZ6yeNbx3hQAyntTtiwoPo1w zE8h3D1okrD34qrtJZnUeWv/JxlYQm93+VvHD+fcQ0u8Fs7wo3J4vHrWIAhK7+etPPjb Rfc6Nc/Ku7dW8MI3v6NhvThmLIXnIVy3c9h+Pg3RkmuekM9ysWExLs+/hy1WMl/M2cLP m28g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+cZWsZu; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m22si1327529pls.277.2019.09.05.09.18.10; Thu, 05 Sep 2019 09:18:10 -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=@linaro.org header.s=google header.b=B+cZWsZu; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387845AbfIEQSJ (ORCPT + 28 others); Thu, 5 Sep 2019 12:18:09 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40720 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387612AbfIEQSH (ORCPT ); Thu, 5 Sep 2019 12:18:07 -0400 Received: by mail-pg1-f193.google.com with SMTP id w10so1680360pgj.7 for ; Thu, 05 Sep 2019 09:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oxweDnammrNyIt2aaQLCe6r9vThCpXKTK19Q9yGm1E4=; b=B+cZWsZuXFEQB01N9qcY/nKk7nFveM0bQSkHouQZ+2v8KRCDItQu12g91o55OqiDIl SQnnn5r6vvZTn3KSmZR9+5rl9wxcTUw4H96aAEmGDnjJxx3uKAFfio+dNp5I+wQr3Vwe gbXWR4hTOwsV+tXvAEB+6kyHio5Z54rthgV5q6RE89zhMs4lr/LJm01282eHycMXzU0z U9a2VMJKcYvCVPouURNHnaM7gNG9pAlCnZKkh1Y0vrCEBkYcoJQ5dlKEJOS6mj8Rfcf/ 3BOqGGxylR2E7voPViPNnWEY2QFJ0exUKtekqdkZckIcT8g6oOqpENw3lQbrUEfCQSqK d4Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oxweDnammrNyIt2aaQLCe6r9vThCpXKTK19Q9yGm1E4=; b=TlVMfApr+ppnP9EFLjoVsfklVp7dCP/nsMrN8P10A836h8L91Jbcb8Dv3XjUeBoGDJ pDuKLkciq7FJ8/pwplsZ3E9xTQbo+D2VN3ehwPTDwFpg+uMEPokoJewaMpa8yjo9R587 CfQCqdyctVQlGv1pSy/rhXwEq4FIxz0QUC61K9Jx5ZZfgBpfHW9C6q9Aucz2Czb0oB6N gI8SILlO7t2dNZK7muvcGxdU1HSg6oM2quw9CiCaxPXlNqiDEcnPrxkqDkOJ1NXsGrfr zaeDSg9k1gFOToFMRHx7X0yc73IdgmWjNI5Z5U7o5gsok/zrsSWKjSzFz4HOlrHQta4x Q1mg== X-Gm-Message-State: APjAAAXnMKIfk5kv6lWFT7eqCNLvHqE359R+KXVSP/7KKctjqt0DQLd7 UiGS8Q8h2GkB/hUUjSing1KXEg== X-Received: by 2002:a17:90a:303:: with SMTP id 3mr4750663pje.124.1567700285921; Thu, 05 Sep 2019 09:18:05 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id m129sm6324005pga.39.2019.09.05.09.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 09:18:05 -0700 (PDT) From: Mathieu Poirier To: stable@vger.kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [BACKPORT 4.14.y 04/18] usb: dwc3: Allow disabling of metastability workaround Date: Thu, 5 Sep 2019 10:17:45 -0600 Message-Id: <20190905161759.28036-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905161759.28036-1-mathieu.poirier@linaro.org> References: <20190905161759.28036-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roger Quadros commit 42bf02ec6e420e541af9a47437d0bdf961ca2972 upstream Some platforms (e.g. TI's DRA7 USB2 instance) have more trouble with the metastability workaround as it supports only a High-Speed PHY and the PHY can enter into an Erratic state [1] when the controller is set in SuperSpeed mode as part of the metastability workaround. This causes upto 2 seconds delay in enumeration on DRA7's USB2 instance in gadget mode. If these platforms can be better off without the workaround, provide a device tree property to suggest that so the workaround is avoided. [1] Device mode enumeration trace showing PHY Erratic Error. irq/90-dwc3-969 [000] d... 52.323145: dwc3_event: event (00000901): Erratic Error [U0] irq/90-dwc3-969 [000] d... 52.560646: dwc3_event: event (00000901): Erratic Error [U0] irq/90-dwc3-969 [000] d... 52.798144: dwc3_event: event (00000901): Erratic Error [U0] Signed-off-by: Roger Quadros Signed-off-by: Felipe Balbi Signed-off-by: Mathieu Poirier --- Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ drivers/usb/dwc3/core.c | 3 +++ drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/gadget.c | 6 ++++-- 4 files changed, 12 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 52fb41046b34..44e8bab159ad 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -47,6 +47,8 @@ Optional properties: from P0 to P1/P2/P3 without delay. - snps,dis-tx-ipgap-linecheck-quirk: when set, disable u2mac linestate check during HS transmit. + - snps,dis_metastability_quirk: when set, disable metastability workaround. + CAUTION: use only if you are absolutely sure of it. - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 945330ea8d5c..9b093978bd24 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1115,6 +1115,9 @@ static void dwc3_get_properties(struct dwc3 *dwc) device_property_read_u32(dev, "snps,quirk-frame-length-adjustment", &dwc->fladj); + dwc->dis_metastability_quirk = device_property_read_bool(dev, + "snps,dis_metastability_quirk"); + dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index abd1142c9e4d..40bf0e0768d9 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -869,6 +869,7 @@ struct dwc3_scratchpad_array { * 1 - -3.5dB de-emphasis * 2 - No de-emphasis * 3 - Reserved + * @dis_metastability_quirk: set to disable metastability quirk. * @imod_interval: set the interrupt moderation interval in 250ns * increments or 0 to disable. */ @@ -1025,6 +1026,8 @@ struct dwc3 { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + unsigned dis_metastability_quirk:1; + u16 imod_interval; }; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 1b99d44e52b9..5916340c4162 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2034,7 +2034,8 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g, * STAR#9000525659: Clock Domain Crossing on DCTL in * USB 2.0 Mode */ - if (dwc->revision < DWC3_REVISION_220A) { + if (dwc->revision < DWC3_REVISION_220A && + !dwc->dis_metastability_quirk) { reg |= DWC3_DCFG_SUPERSPEED; } else { switch (speed) { @@ -3265,7 +3266,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) * is less than super speed because we don't have means, yet, to tell * composite.c that we are USB 2.0 + LPM ECN. */ - if (dwc->revision < DWC3_REVISION_220A) + if (dwc->revision < DWC3_REVISION_220A && + !dwc->dis_metastability_quirk) dev_info(dwc->dev, "changing max_speed on rev %08x\n", dwc->revision); From patchwork Thu Sep 5 16:17:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 173156 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp935001ilq; Thu, 5 Sep 2019 09:18:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWAdmXWM4Tx7/OchwFSmD/cwuUTjOXuRHi5453mA1YXAqI7ARnBxBqyaKXwmaorr5DI8up X-Received: by 2002:a63:4042:: with SMTP id n63mr3832469pga.75.1567700295456; Thu, 05 Sep 2019 09:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567700295; cv=none; d=google.com; s=arc-20160816; b=AV0V8fSIHz8xsPsI4uMNM9yn/o37UDeOFTwFrjRxGkWjcq1JNAS2QBMuDqz9RgfRcl QRUKfYGqvGxNy9DhsrFWqyLkJp3mlo7k99aEYPuZd37i/enK3Sd3e+vZ+1Y9OeBI1Xd3 c03zQm+nqWcOw0aanVqEbNLJE82Lfzrmb3K6xQ+bC925p4MvCyDDzr+rINdTVMISTIlh EycUtflgx6riQaq+3cko/hDs2vE4CPfbV4A0sAG+xBOiqXLb0GQ7OEn9qG0MvEZl0UI/ cmthA7qr+Qq3jWFPcS6P2LXaOH7SxwBnHufvEQZ3yyVIeugMrOXRzV8SBmK4YhmzeYyE AK0A== 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=/ld8MsvJyHX4xiXhT/vACY8V+T9SsrvyxVWLxkWmOHw=; b=FYcBFOEs471qCo+a4/TduF6zNtjVJ88bEviUGwgT49YelEywN8eMvc19kNfsZlzMwN J7MQABWEOekq+PZ9qvSNuHkdbBpInq1vba9Yz2EVUNJOC/o/NovqbrZth2Q6YncDM1X7 aP8ofAAxmK+ky4zULSvb9qGiUAdBjVwsKDa9axt8tfSoHrc8PnaPz5q8TcqWapRu23BU +612aWHHR3xUT3+hbIjjegvDvNe7J/CeXkRbwMnl8eFT6JuU4Ff7aIzwFAG9rLfaycVb x3EkiwBgsgQW3tTlAmj62pq5woCNK30l1z0U5VgQCiWpUwZCMN22/pyukrNy/07I7wKT MOrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XT3Az7zz; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si2375086pjn.58.2019.09.05.09.18.15; Thu, 05 Sep 2019 09:18:15 -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=@linaro.org header.s=google header.b=XT3Az7zz; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388337AbfIEQSO (ORCPT + 28 others); Thu, 5 Sep 2019 12:18:14 -0400 Received: from mail-pg1-f182.google.com ([209.85.215.182]:45288 "EHLO mail-pg1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388032AbfIEQSK (ORCPT ); Thu, 5 Sep 2019 12:18:10 -0400 Received: by mail-pg1-f182.google.com with SMTP id 4so1662160pgm.12 for ; Thu, 05 Sep 2019 09:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/ld8MsvJyHX4xiXhT/vACY8V+T9SsrvyxVWLxkWmOHw=; b=XT3Az7zzBbgbLvMexBlhl28H1zweak4MTFSDW4Z2X3Ha/QND0Bs7fu1GlJQslffzeB LWlUlyWIAmzVk/+mUyPdD+4nZwAO9nk1ji12txKMyNEST223rFfRlFB6AeFPMZvq7wy/ tXFpIGd7WBH3k/q538r3XaFEMh0s3bPPDl3wPolk9LypaKTfGB6UzVKsLLeAS07gj1rn fdweJBOKtEZq8Zmfgu1NcESYEF48FPKrzvVBBc5+gyUyrbJ//dUWwgy6OH85myV+ToOC HgL1kn+e4YWS/JFJ4yB6alQ12JjDhFV87for4spwtn7BdUdPfyqfJYpWsYs/lzpIIiIM 3BKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/ld8MsvJyHX4xiXhT/vACY8V+T9SsrvyxVWLxkWmOHw=; b=EvppuxQCE8oZs5I/IuowDebEADdETN1zynbu4VlfO33Mx1cp5uGshLwVhFb8L3u75j 0G00O4FpaPYWf5I2YKvBh5YAHkNLMBghpRJoHUHFnbobeeoGlOQ4kAFLhoIcaP8PCO+e RZ4ovNQfZS8ROQeLmG/maTClo2g90xliek3pokK3eArWevGWC/Q3xJFWrHP67ESQFZnd b2tRySXOD8bQLLHDriY3dWZoGwXrHes/7yCbOqmgEoVlMb8rUsMDiKSjBO0kk/I0Ehkg AQHcZt1jR+xUJd3gy7QOcT+h+76iAVedAJ8mmQjbXSSfqDM3octJPN25V4ABytYK9b22 K6HQ== X-Gm-Message-State: APjAAAV1X+SCThqf5O2xxCGOUv1weSa1EVS5rtEJgZKx5H4na0bcDppB ttUUuC2+Xl+yiYOc6JTuUNoT5Q== X-Received: by 2002:a63:2364:: with SMTP id u36mr3780682pgm.449.1567700289680; Thu, 05 Sep 2019 09:18:09 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id m129sm6324005pga.39.2019.09.05.09.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 09:18:09 -0700 (PDT) From: Mathieu Poirier To: stable@vger.kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [BACKPORT 4.14.y 07/18] mtd: spi-nor: enable 4B opcodes for mx66l51235l Date: Thu, 5 Sep 2019 10:17:48 -0600 Message-Id: <20190905161759.28036-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905161759.28036-1-mathieu.poirier@linaro.org> References: <20190905161759.28036-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Yeryomin commit d342b6a973af459f6104cad6effc8efc71a0558d upstream Signed-off-by: Roman Yeryomin Signed-off-by: Cyrille Pitchen Signed-off-by: Mathieu Poirier --- drivers/mtd/spi-nor/spi-nor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 34ecc12ee3d9..6c013341ef09 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1030,7 +1030,7 @@ static const struct flash_info spi_nor_ids[] = { { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_4B_OPCODES) }, { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) }, - { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, { "mx66u51235f", INFO(0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, { "mx66l1g45g", INFO(0xc2201b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) }, From patchwork Thu Sep 5 16:17:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 173157 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp935058ilq; Thu, 5 Sep 2019 09:18:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxO886epbHoN3pKpGy2IKJ2joOtLS/PbpCLfbVWqXW/IAqk0vgH6P0l7RVEqWre2oGq3h+R X-Received: by 2002:a17:902:ba16:: with SMTP id j22mr4025540pls.253.1567700298084; Thu, 05 Sep 2019 09:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567700298; cv=none; d=google.com; s=arc-20160816; b=IuXQGaTvojuuKMoJvhCKgZC/31dVH6JodScyAlBwbhV3HacE/GaKL1Hd3fsTq6HJyX 5bd55ImG72krNksXTLl1AOV0tjujW08RVePDhkrmHUr+Qsszx7gz5a7Q+4sGMl2qsYOA quGP2Mzi29CBJ2hBRBIM7siOjdM7tLo3h8j28O2vXtWJdL9QSAz6VGhGBNr8uVeOLtkm RSzgkdPMzeiAujjP0u7vjgnjLzGa+fLtbyJt9uzCQThfZw6SLDsy2OH6pKebNcjWvzLY VuRiU78gR65Owdw2sVirygbDd/VLonr0h6LePbOBGM2q6XndArMzXJUa9VBZ1iMXmg51 EvZw== 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=NoTtLr1lztWfrS92BUWnGWn3zk0jvQAYseg1lZWuSGs=; b=s0vpEh7W3c/6w24UIFIyGiw3TMGKtuVeB40a4hM5b7STTCKPLvuvs/+li7JXPfw73L 7RBKAExU90fNoj0fm+BP2IV9g2wktJ0C9ZukT5vETMhnMybGz153sHK2Ub2sJ0Ps8Bcv zVu/8y8eSaDV26ZQyA1RIhNOfaeJ0Me6oN/+8v0aoElGae3B4Owozd7/hZSVmNEHrkgJ 3EqYUWYLcQHHQtC5YCcAFx4zyXn/TMbCvwPV23GyN73NSHtKgWB9KGRM6sB2Ou/k8us9 inaIWRc+93SF1fKxAAccmKX9uEsR3wsm0ANgmGsP7bJCr9OjGhwju1ecLIGtq/u94APP Iy1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GFbERyZ9; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si2375086pjn.58.2019.09.05.09.18.17; Thu, 05 Sep 2019 09:18:18 -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=@linaro.org header.s=google header.b=GFbERyZ9; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388334AbfIEQSQ (ORCPT + 28 others); Thu, 5 Sep 2019 12:18:16 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33898 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388096AbfIEQSL (ORCPT ); Thu, 5 Sep 2019 12:18:11 -0400 Received: by mail-pf1-f195.google.com with SMTP id r12so2090696pfh.1 for ; Thu, 05 Sep 2019 09:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NoTtLr1lztWfrS92BUWnGWn3zk0jvQAYseg1lZWuSGs=; b=GFbERyZ9NRV2dkkLT4vQsg2O43TovjaGYNn6dZQb4zlipk1hrBEI93ONy4uCdy17BN qs6turZaX0cjL2hsvD0XQcPWWyT5eGXz7QIlN5q8rtchZ5viCWRBDwkHQ7obcrcC3Uar 1ortXnAwgQMvUwFZEFdfF67Zd3yS6nt3iV9SSsbRUiIhAZwUvGND/emO1CKYf2KWOr28 VxlM82pRtImf20eiipHbpwiiWXaq0nZI2+bBsKhiaerAHkOFKlpVyiIpgMWISCo/STX0 lWqLo+YlveCj4WJwPQ/Qdyw/LyipxCRHxudVAm/baaKD40BYKWBjg0PjlTT0keABvYme Sx5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NoTtLr1lztWfrS92BUWnGWn3zk0jvQAYseg1lZWuSGs=; b=B3oqoqbPdwNsj+1z65o4F8m1Jze6EpfoH+lMdY8nRX3T6uvkOHLVH/cWLuhAL1RbsQ rlYm+vNXz6pzaMBbYc5xaBe4YOZJtL0XPezp1uJXJc4j5D1ikC5XgXkpSN0t2yBYOG9r vFT0x78PQ3dAZQBWM7eckY5qkAvWUFQR6ptXA6C/d00bupoUkHH+Xa+0BstFLfuC8NFF gbyEBejxxyG2vz7nKKlUCbgpKeN84rjjJuFlkYyESERYAjriFNihhffGtvXkDVwDgyzP gcAN+/9WcBE2fkH591j/x6j5DewnNmmrWBwlbKkx/b2TIYFPNuO/Ols/8ey+2lDdQDD1 WMNA== X-Gm-Message-State: APjAAAXkqc11KoGbqukOx0JUhWkW6ggXU4w3++Yq7ThIJiAqjX5ysxu2 5bndtidEH5YH7wodgliDetamWw== X-Received: by 2002:a63:60a:: with SMTP id 10mr3873993pgg.381.1567700290813; Thu, 05 Sep 2019 09:18:10 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id m129sm6324005pga.39.2019.09.05.09.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 09:18:10 -0700 (PDT) From: Mathieu Poirier To: stable@vger.kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [BACKPORT 4.14.y 08/18] mtd: spi-nor: cadence-quadspi: add a delay in write sequence Date: Thu, 5 Sep 2019 10:17:49 -0600 Message-Id: <20190905161759.28036-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905161759.28036-1-mathieu.poirier@linaro.org> References: <20190905161759.28036-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vignesh R commit 61dc8493bae9ba82a1c72edbc6c6065f6a94456a upstream As per 66AK2G02 TRM[1] SPRUHY8F section 11.15.5.3 Indirect Access Controller programming sequence, a delay equal to couple of QSPI master clock(~5ns) is required after setting CQSPI_REG_INDIRECTWR_START bit and writing data to the flash. Introduce a quirk flag CQSPI_NEEDS_WR_DELAY to handle this and set this flag for TI 66AK2G SoC. [1]http://www.ti.com/lit/ug/spruhy8f/spruhy8f.pdf Signed-off-by: Vignesh R Acked-by: Marek Vasut Signed-off-by: Cyrille Pitchen Signed-off-by: Mathieu Poirier --- drivers/mtd/spi-nor/cadence-quadspi.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c index f22dd34f4f83..ff4edf4bb23c 100644 --- a/drivers/mtd/spi-nor/cadence-quadspi.c +++ b/drivers/mtd/spi-nor/cadence-quadspi.c @@ -38,6 +38,9 @@ #define CQSPI_NAME "cadence-qspi" #define CQSPI_MAX_CHIPSELECT 16 +/* Quirks */ +#define CQSPI_NEEDS_WR_DELAY BIT(0) + struct cqspi_st; struct cqspi_flash_pdata { @@ -76,6 +79,7 @@ struct cqspi_st { u32 fifo_depth; u32 fifo_width; u32 trigger_address; + u32 wr_delay; struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT]; }; @@ -623,6 +627,15 @@ static int cqspi_indirect_write_execute(struct spi_nor *nor, reinit_completion(&cqspi->transfer_complete); writel(CQSPI_REG_INDIRECTWR_START_MASK, reg_base + CQSPI_REG_INDIRECTWR); + /* + * As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access + * Controller programming sequence, couple of cycles of + * QSPI_REF_CLK delay is required for the above bit to + * be internally synchronized by the QSPI module. Provide 5 + * cycles of delay. + */ + if (cqspi->wr_delay) + ndelay(cqspi->wr_delay); while (remaining > 0) { size_t write_words, mod_bytes; @@ -1184,6 +1197,7 @@ static int cqspi_probe(struct platform_device *pdev) struct cqspi_st *cqspi; struct resource *res; struct resource *res_ahb; + unsigned long data; int ret; int irq; @@ -1241,6 +1255,10 @@ static int cqspi_probe(struct platform_device *pdev) } cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk); + data = (unsigned long)of_device_get_match_data(dev); + if (data & CQSPI_NEEDS_WR_DELAY) + cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC, + cqspi->master_ref_clk_hz); ret = devm_request_irq(dev, irq, cqspi_irq_handler, 0, pdev->name, cqspi); @@ -1312,7 +1330,14 @@ static const struct dev_pm_ops cqspi__dev_pm_ops = { #endif static const struct of_device_id cqspi_dt_ids[] = { - {.compatible = "cdns,qspi-nor",}, + { + .compatible = "cdns,qspi-nor", + .data = (void *)0, + }, + { + .compatible = "ti,k2g-qspi", + .data = (void *)CQSPI_NEEDS_WR_DELAY, + }, { /* end of table */ } }; From patchwork Thu Sep 5 16:17:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 173170 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp936610ilq; Thu, 5 Sep 2019 09:19:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkXK2/tt/IOL2eSjYK3+hI5YPzL5snQLXUeo0GQw1ASYX04vGgRbypkJn2zfLp63OSkTrs X-Received: by 2002:aa7:8481:: with SMTP id u1mr4941641pfn.3.1567700365615; Thu, 05 Sep 2019 09:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567700365; cv=none; d=google.com; s=arc-20160816; b=X3jejoNbti4HRyoRCktWMU8lkljP0b2EI6LkF+Dd7af84dKJdzjYjCR5B5zMOO+x3d RZxqa9Ygr6nAko8/pa/v6QcmpG8zlP/zPK42WcFIEScuvVRBLpbCkCgMXEYjzinQD/XE pjZQnVkyVYJURwPBOR1ioODEKAXhVC42gbZXzEGoTksXjpXhA3wIuGwsHmvHLAQyMgD/ Ko09q+42pfg4/1SKE1ZmDDhGK0b/zz0SFwNBDSIYiN0+t0JhOP1L7gEPk2JPjTJ9A7WC IMljnJLKldbkjyNpkEJitOhbhZIArfYDtV6DVuKtNQLmC+WzmmSNKCZ6fGxO35Y37UUI rBiQ== 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=zGhRU3CF0nckn4q3RpFyAUKnMAipsfpJ2Ggo67IAKJc=; b=MkHLXNDWzvqn4COAWX1WtWsZytUtHkE4N1i1C2XxEKR1ebKOTw8ISUnnFm8fMOFplA gQKaTvOP9V0oPmjm/pVs6vgXLAjlVJ8H2FRUdvtthmvqR2Lm3up/FiYff4IQ8odXIrbi JBWDtPk9CZ3tw5KWwzGbU9LWqV4YhlK8CrzGsUqaiblHyu04dheU4LNcRIBWK9EyN9t+ E2k1I45zfXZIwYM1icPNXw9OB6VLzqSlcgaYZmlrU3PJr8MS8eopLQ8Ku2LO21beX2oh CC8U3NsGsKOSvE5rAPc/JVox/W4gLhSHXylNpwclgcSox/hHo7Pt8E6YoObnUl+/puqm hgMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Esj7f4QN; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si2147873pgv.417.2019.09.05.09.19.25; Thu, 05 Sep 2019 09:19:25 -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=@linaro.org header.s=google header.b=Esj7f4QN; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388834AbfIEQTY (ORCPT + 28 others); Thu, 5 Sep 2019 12:19:24 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36080 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388173AbfIEQSN (ORCPT ); Thu, 5 Sep 2019 12:18:13 -0400 Received: by mail-pf1-f196.google.com with SMTP id y22so2082709pfr.3 for ; Thu, 05 Sep 2019 09:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zGhRU3CF0nckn4q3RpFyAUKnMAipsfpJ2Ggo67IAKJc=; b=Esj7f4QN25ld+Ovd4UPXhi2gSS9+Lzc1VVLMSaLedss00TUu/574n7510/KARXCZI3 7W6vE5cd7uARf9ipf0Ags1oPwG3CFAYVMe29Tybo5a64c/5svbgUNtDOdTUTjtzJgzsk BBVG0AUZqbY2eMEesm9XN02filAWjn0hrxTZtIA6mzGsPfn9CVvXwJMErc9ztNrFDZlQ hSJdg6l4K5XNAYyr1Od0KnturBe85nLy/GTao8rjSvtfT1nPC/0vFWd+7bbID+jHlLNF uVWRzrdTujIrO+oTLdms5SAw0eB7uKDL1CNjQPdxf+8SUROE+hX1TvIpDFBHgWNZSiuB ++TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zGhRU3CF0nckn4q3RpFyAUKnMAipsfpJ2Ggo67IAKJc=; b=U9h1IAg1u/ZKNm4i0vUAstheCvN6rlN/f4ECDCClb+VlvznpmxsqXtRV0DW/MsIcCg AdbveNx4Yb8g5zEnnaJduFDLFrOaXOpK3Q5JKdLvbKSwjnHpgeboEi6At6rQaMamwPSc nkZxeJDEQia2XG8kwets89FuWt9C//X7IMb90eEQLVeIJIATzcBYlzoHo2LtdjBN8fGy HOQGht9YqjWHGW7GXOLVa2oWA/bf+CiU4Mzk8OI6fR4QYB4bBVi3UYrtf5zNJ52Xv7gF D/DaPDqyVBhkiaMYLFt9Y/7ZPZoqZX5MUgOro12so1CQdqWbusZ2tNHL1hJVMlGT2gm4 7HDw== X-Gm-Message-State: APjAAAUisvglXK+u7uHG+rudAbnzkBbpNi+Z70/tx/wTw8Pm5OJYCfuR CaTPmI3YMvIeaLxK/lPaGEIaCA== X-Received: by 2002:a63:5f01:: with SMTP id t1mr3605020pgb.200.1567700292199; Thu, 05 Sep 2019 09:18:12 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id m129sm6324005pga.39.2019.09.05.09.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 09:18:11 -0700 (PDT) From: Mathieu Poirier To: stable@vger.kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [BACKPORT 4.14.y 09/18] misc: pci_endpoint_test: Prevent some integer overflows Date: Thu, 5 Sep 2019 10:17:50 -0600 Message-Id: <20190905161759.28036-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905161759.28036-1-mathieu.poirier@linaro.org> References: <20190905161759.28036-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit 378f79cab12b669928f3a4037f023837ead2ce0c upstream "size + max" can have an arithmetic overflow when we're allocating: orig_src_addr = dma_alloc_coherent(dev, size + alignment, ... I've added a few checks to prevent that. Fixes: 13107c60681f ("misc: pci_endpoint_test: Add support to provide aligned buffer addresses") Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman Signed-off-by: Mathieu Poirier --- drivers/misc/pci_endpoint_test.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.17.1 diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 9849bf183299..504fa680825d 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -226,6 +226,9 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, size_t size) u32 src_crc32; u32 dst_crc32; + if (size > SIZE_MAX - alignment) + goto err; + orig_src_addr = dma_alloc_coherent(dev, size + alignment, &orig_src_phys_addr, GFP_KERNEL); if (!orig_src_addr) { @@ -311,6 +314,9 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, size_t size) size_t alignment = test->alignment; u32 crc32; + if (size > SIZE_MAX - alignment) + goto err; + orig_addr = dma_alloc_coherent(dev, size + alignment, &orig_phys_addr, GFP_KERNEL); if (!orig_addr) { @@ -369,6 +375,9 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size_t size) size_t alignment = test->alignment; u32 crc32; + if (size > SIZE_MAX - alignment) + goto err; + orig_addr = dma_alloc_coherent(dev, size + alignment, &orig_phys_addr, GFP_KERNEL); if (!orig_addr) { From patchwork Thu Sep 5 16:17:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 173159 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp935113ilq; Thu, 5 Sep 2019 09:18:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqy31QxeXYNC8kjuJ5ehB/xZjidHMW67kMcYK8Op771JQIO4A9EgPrlDJx6E5ytZNJYJMPZe X-Received: by 2002:a17:90a:b292:: with SMTP id c18mr4773408pjr.1.1567700299947; Thu, 05 Sep 2019 09:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567700299; cv=none; d=google.com; s=arc-20160816; b=HVKBW8rI8r+s+fMcjoCBNJwlWLmIE4AEFhaBEZd1Hry3L73NPM0t266kasvPoy7Ijo 70MBqX7X6P1xIZmBf38FLjLlK6rAO9E9eQXB+wFcsaXHPi2XA7Rj2/2fZHmZIY4dmeez E7DDS6H/7kwrBdhCm/vRfrqWVh2ZRshAL0vrgR7IFcEMhjg5ADySmVF6X5i0TNuysiME OpxOqnE+EwumY3239YdzM5U+SZHH6v37wQCSC1kCZdVnah1WidufYDEXROvpkxjDemkv RJspRJ0zoEtcz12Ne4qnquc/948s7U6icv/vOYU87UBjy7YP8EZYDvR4JBU66HaRStwh WpZg== 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=8QjjqDFW2as8gsE3MNwHPLPN76USmssxyGkKOBC9D3E=; b=mgDxaSgLRWHothMtcDB2PdxhpEmoW5owuk0O9DQifFNFIMdxyM/cyXvN93lqvUhkWg 0UPPXGSFlSFtaam/Il4P0t0R1P3GaNEmWeLNRJMkrY7a88kCcZOt17vRrK9PIYl99fZL y6y2DRmiVnOSgOvm7Cv15IWShQ4U7n8OAkAlSz8C90r9fGXQLVLjHHRCKo5V0W3Dd50x 5Qt1SgdSNjWPxy1mdx0xKNx2ghI3cjvomZ0ZOQm5xGTBnQnIxnvaSG5y+nhaVpAw2GWj c3tYBTTWTJdJEF0VoQfdrkHEsX7nITo3KATlEDZXBPyJN1RThI9IfO5VXBBjMu1S+1oa 9ykw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HL27V+NY; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si2442272pld.431.2019.09.05.09.18.19; Thu, 05 Sep 2019 09:18: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=@linaro.org header.s=google header.b=HL27V+NY; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388593AbfIEQSS (ORCPT + 28 others); Thu, 5 Sep 2019 12:18:18 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:34148 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388431AbfIEQSQ (ORCPT ); Thu, 5 Sep 2019 12:18:16 -0400 Received: by mail-pl1-f196.google.com with SMTP id d3so1556208plr.1 for ; Thu, 05 Sep 2019 09:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8QjjqDFW2as8gsE3MNwHPLPN76USmssxyGkKOBC9D3E=; b=HL27V+NYul1f+O0bmc6YkYSMF5euNDbYJl3hh04CdtFtjxmvNCYdhhn4rVKZ4mtbnC haoz4ZuRykOa1EVcbKBLOnulQom5g/1qMM4K3pUJqI9gyl8+8M7gUP3hdV27jiyNhaLP o/VZfks/pnLsAsEemsNEwt2UAy9aH5QMHPRsXyteaLVX8yuXtIU8Q7J3Kt0GHRGIjeu+ 6uqwAVSO0rrjztAQNUcFDtt/AS9X6aQBAlsAr+yR2VeRxvHvm5f4PTxaab1YLr0ySVHa WGR7mnvK9yLWmfNAcVoLZFMGqTS8ZaLoVAcycwWbcXSXF16pUzOt3ohlbzYqLRrORRPt DjoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8QjjqDFW2as8gsE3MNwHPLPN76USmssxyGkKOBC9D3E=; b=fjML/jdcBbFZTIjJA4nsoSI3d6I/09SlbnxIdH0jxG+khMkfIxB2jBK7yW91Wg+yqv VkznMy38dS9q6MUrPVffcgvq2fh9EJN/F0rGrwlSk+W9EUSbz+zHx9NuzbnZP6vRttwr RWH8+I4J0jNkB+CILbe59JzGV8vnSwJcaesdCrLyNLmBXZVZ2VrU5gwMY4cc6JI4Ry+m qWRc4lxOtx5SzrzghoPd/I3K3KYhgqmWVJLDN/Jg0IaZu1QLul3u08B4TRhGwhQ8tQWu JpFiiaoTAy3G5zZuASmE8KV0NfRuumopM5pYs1GNEJzLYSMo9LQio87DAif8r70GO68F MT4g== X-Gm-Message-State: APjAAAVXdNAhYG23RHNUe79XGKIsG4s3NpEDB+zRSdMhGmcqTLOPBiBx H7tE/W6BFZowijp+sJXKDcw46A== X-Received: by 2002:a17:902:8a87:: with SMTP id p7mr4384259plo.240.1567700295503; Thu, 05 Sep 2019 09:18:15 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id m129sm6324005pga.39.2019.09.05.09.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 09:18:14 -0700 (PDT) From: Mathieu Poirier To: stable@vger.kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [BACKPORT 4.14.y 12/18] mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone Date: Thu, 5 Sep 2019 10:17:53 -0600 Message-Id: <20190905161759.28036-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905161759.28036-1-mathieu.poirier@linaro.org> References: <20190905161759.28036-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sudeep Holla commit 33cd7123ac0ba5360656ae27db453de5b9aa711f upstream Currently the mailbox framework sets txdone_method to TXDONE_BY_POLL if the controller sets txdone_by_poll. However some clients can have a mechanism to do TXDONE_BY_ACK which they can specify by knows_txdone. However, we endup setting both TXDONE_BY_POLL and TXDONE_BY_ACK in that case. In such scenario, we may end up with below warnings as the tx ticker is run both by mailbox framework and the client. WARNING: CPU: 1 PID: 0 at kernel/time/hrtimer.c:805 hrtimer_forward+0x88/0xd8 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.12.0-rc5 #242 Hardware name: ARM LTD ARM Juno Development Platform task: ffff8009768ca700 task.stack: ffff8009768f8000 PC is at hrtimer_forward+0x88/0xd8 LR is at txdone_hrtimer+0xd4/0xf8 Call trace: hrtimer_forward+0x88/0xd8 __hrtimer_run_queues+0xe4/0x158 hrtimer_interrupt+0xa4/0x220 arch_timer_handler_phys+0x30/0x40 handle_percpu_devid_irq+0x78/0x130 generic_handle_irq+0x24/0x38 __handle_domain_irq+0x5c/0xb8 gic_handle_irq+0x54/0xa8 This patch fixes the issue by resetting TXDONE_BY_POLL if client has set knows_txdone. Cc: Alexey Klimov Signed-off-by: Sudeep Holla Signed-off-by: Jassi Brar Signed-off-by: Mathieu Poirier --- drivers/mailbox/mailbox.c | 4 ++-- drivers/mailbox/pcc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 44b49a2676f0..055c90b8253c 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -351,7 +351,7 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) init_completion(&chan->tx_complete); if (chan->txdone_method == TXDONE_BY_POLL && cl->knows_txdone) - chan->txdone_method |= TXDONE_BY_ACK; + chan->txdone_method = TXDONE_BY_ACK; spin_unlock_irqrestore(&chan->lock, flags); @@ -420,7 +420,7 @@ void mbox_free_channel(struct mbox_chan *chan) spin_lock_irqsave(&chan->lock, flags); chan->cl = NULL; chan->active_req = NULL; - if (chan->txdone_method == (TXDONE_BY_POLL | TXDONE_BY_ACK)) + if (chan->txdone_method == TXDONE_BY_ACK) chan->txdone_method = TXDONE_BY_POLL; module_put(chan->mbox->dev->driver->owner); diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 9b7005e1345e..27c2294be51a 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -266,7 +266,7 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, init_completion(&chan->tx_complete); if (chan->txdone_method == TXDONE_BY_POLL && cl->knows_txdone) - chan->txdone_method |= TXDONE_BY_ACK; + chan->txdone_method = TXDONE_BY_ACK; spin_unlock_irqrestore(&chan->lock, flags); @@ -312,7 +312,7 @@ void pcc_mbox_free_channel(struct mbox_chan *chan) spin_lock_irqsave(&chan->lock, flags); chan->cl = NULL; chan->active_req = NULL; - if (chan->txdone_method == (TXDONE_BY_POLL | TXDONE_BY_ACK)) + if (chan->txdone_method == TXDONE_BY_ACK) chan->txdone_method = TXDONE_BY_POLL; spin_unlock_irqrestore(&chan->lock, flags);