Received: by 10.213.65.68 with SMTP id h4csp1874201imn; Mon, 19 Mar 2018 16:00:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELt9+L+JQ7peO/eFMorwnieAyhUwLvf+LBEGu4WBj3AmNNDrM5GkQzHen5xoyKLGoLemeL9Q X-Received: by 2002:a17:902:85:: with SMTP id a5-v6mr9443188pla.99.1521500433962; Mon, 19 Mar 2018 16:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521500433; cv=none; d=google.com; s=arc-20160816; b=Da4uaAjngc6cWzhSCa41R7Ja3dZ9MwNbSX5VeQJirwfA0SE2hCpyGXGulMygige5VJ xUOleHC6gSAsmcKh+eQ5zL/Y/A3abBVhCXcTG666IwYVYa8xPc4CetzDoJRWgG25HICz xDgSKWhLqLgg3yZFYz/ZbXRRhknL8/b5AkaLjyUX2WwHqz11mRyN9sBifs57XChRMacH U1HNX0Va81K0svqrghPPeINhWJcR9ATJCL1ldHPWzK2mbAfWC+b8hCVADYRJEnu4xb+6 lIJ4YeCR1EE8kuv4JT0lkOSdijOun5BcGE5mZ9/U0PpMPUuDS2iB79uUuUyisoYFIXwm u67A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=g+tGQviEpZnFc/9HVIzZwV5UgybDeC0ReSnd//GpjKI=; b=JiUDbYbVZ5HXlNJfEtcW2Ht9RENIbyvhVN9z1c8fs44ml9YxgTf27u4qJMif/5+iAH I8JVTV7acard7wt0tiJr8U4rS1vU1epj4o5yzX28sWxnM1/ukSLffwiN5ivHWJMOVYjP 6e6/bfAZ/2NaNCLgDN572shTQtC1j2c55GaSQ0dVeTIw46fBods1mMHfLoF90w6tvRlS wiIEhl2RN9aTRPbWbmuI0LwNdd+ijJ2Avy4QrVCaGb0dtHmvRCQ6t2wUCJ+8nsXtXCgN 4Bo6SJSCIeieCVmiZnztK/gQHsfk04G36GkLNEL9bL771rMycAF4Ol6toU4LvhrZwFzZ J6EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=K3Sv4dOX; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si230186pfj.58.2018.03.19.16.00.18; Mon, 19 Mar 2018 16:00:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=K3Sv4dOX; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933776AbeCSPs3 (ORCPT + 99 others); Mon, 19 Mar 2018 11:48:29 -0400 Received: from mail-co1nam03on0136.outbound.protection.outlook.com ([104.47.40.136]:48409 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933522AbeCSPsN (ORCPT ); Mon, 19 Mar 2018 11:48:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=g+tGQviEpZnFc/9HVIzZwV5UgybDeC0ReSnd//GpjKI=; b=K3Sv4dOX6ToC1MFdwSvbyyWY+tx7I/B0qioO9sK26bAwCjma7+u7ACcsQWsGaZYFuFtQDJg0exUcTKpzPYXdhqyZVM/QgTm7W92iYDJ4Gf4uOudxXdcOBuHEDCVIWvXU0TCkngU7/DH9z8WfhykYGWSYnDsEvmncpLUp6tBFiiw= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0998.namprd21.prod.outlook.com (52.132.133.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.0; Mon, 19 Mar 2018 15:48:06 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:48:06 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Geert Uytterhoeven , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 040/124] spi: sh-msiof: Fix timeout failures for TX-only DMA transfers Thread-Topic: [PATCH AUTOSEL for 4.15 040/124] spi: sh-msiof: Fix timeout failures for TX-only DMA transfers Thread-Index: AQHTv5mcVa7fcwofo0CnATnRBU02rQ== Date: Mon, 19 Mar 2018 15:47:40 +0000 Message-ID: <20180319154645.11350-40-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0998;7:uVLzMRFvpbtYjmnBcjmofM8/yaA8aE70KZi90Bvy2faHRpO04LdNT2VtUrCX8W48R3uOTQXthbSWo1pkpIbLmGwJRkskmsOXBtOGRvFmi+8WNPmB6XteWvYrdfnwQURRl2cdBTscKCsVaZQs7DZTnd8aLG5EU9+ovykV5KbTVyj+IjbHkLmjuMUMRtlR6U4F22OmS4E2+zyzj/JMvWGI4gz8xUJznFjz9q9iEfwtM7CSAugVKIKKS8M/YmRUBPUP;20:fCrdlehUlhQgGI5nzmDMXzZW1ZcRyk/SrvTz5CQZtZxubbGtDW6+BZTmpc01nkKaWC2kHWrzDENf0A4Cj8KI8MadQYlofozwhMosQTde0/O+74rxSGiisRklbRhHCRR4AAyII8QdLdM2Vm7sWE4qxp5mKl4OXWBbq5uv9GS+98o= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 35b2420d-4587-4c45-7dbd-08d58db0ceef x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0998; x-ms-traffictypediagnostic: DM5PR2101MB0998: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0998;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0998; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(366004)(376002)(396003)(346002)(199004)(189003)(3846002)(6116002)(8936002)(6486002)(102836004)(68736007)(6506007)(2900100001)(22452003)(25786009)(3660700001)(7736002)(76176011)(6512007)(72206003)(86362001)(53936002)(8676002)(81156014)(6436002)(81166006)(305945005)(478600001)(99286004)(2950100002)(14454004)(6666003)(10290500003)(186003)(107886003)(2501003)(106356001)(26005)(86612001)(97736004)(5660300001)(10090500001)(110136005)(54906003)(316002)(2906002)(66066001)(105586002)(4326008)(36756003)(3280700002)(1076002)(5250100002)(59450400001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0998;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: okoCL3DW+x5wkFDKfbF0/21OSqmjOL2W1EU1eAldmB4rT/W+yQgGE5ZxAzF/wIxm4c4ig+X4NvDIZqB4+xmhM59674kNit0DhCKfh3rWVRRYjg/fYxuw03XSc9fzSuF47uKrsvWzSjV8GijnJ6MPx2JCYDG/MsILtMQ9FpG6sfFr2kwm25MXZpvG2gGY4kLpGUQdvnqJUNlN1xlII3RoD3lKZRdDGOnkeinWzJUQsDh390chlICwkO2VZkvvoZlqDeztI+WLMse7E+L5UnWkU0WFTbuRO/C1z1ptMk22cxXaDzXRdnuMr/XugkH7iozsyamutey7BHylCIu7HCLh9Q== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35b2420d-4587-4c45-7dbd-08d58db0ceef X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:47:40.7453 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0998 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven [ Upstream commit 89434c3c35081439627baa2225622d5bd12242fe ] When using RX (with or without TX), the DMA interrupt triggers completion when the RX FIFO has been emptied, i.e. after the full transfer has finished. However, when using TX without RX, the DMA interrupt triggers completion as soon as the DMA engine has filled the TX FIFO, i.e. before the full transfer has finished. Then sh_msiof_modify_ctr_wait() will spin until the transfer has really finished and the TFSE bit is cleared, for at most 1 ms. For slow speeds and/or large transfers, this may cause timeouts and transfer failures: spi_sh_msiof e6e10000.spi: failed to shut down hardware 74x164 spi2.0: SPI transfer failed: -110 spi_master spi2: failed to transfer one message from queue 74x164 spi2.0: Failed writing: -110 Fix this by waiting explicitly until the TX FIFO has been emptied. Based on a patch in the BSP by Hiromitsu Yamasaki. Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-sh-msiof.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index fcd261f98b9f..06bc4b170c47 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c @@ -784,11 +784,21 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv= *p, const void *tx, goto stop_dma; } =20 - /* wait for tx fifo to be emptied / rx fifo to be filled */ + /* wait for tx/rx DMA completion */ ret =3D sh_msiof_wait_for_completion(p); if (ret) goto stop_reset; =20 + if (!rx) { + reinit_completion(&p->done); + sh_msiof_write(p, IER, IER_TEOFE); + + /* wait for tx fifo to be emptied */ + ret =3D sh_msiof_wait_for_completion(p); + if (ret) + goto stop_reset; + } + /* clear status bits */ sh_msiof_reset_str(p); =20 --=20 2.14.1