Received: by 10.213.65.68 with SMTP id h4csp2119025imn; Sun, 8 Apr 2018 20:10:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx48dU+Flo7hwjsvvPSdKSaArNC/VbE3pPnWmsf2qg1ZvSueqKxLU+xPd1jxfxkw6s9Jneeo9 X-Received: by 10.101.69.198 with SMTP id m6mr23711592pgr.244.1523243338117; Sun, 08 Apr 2018 20:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243338; cv=none; d=google.com; s=arc-20160816; b=EyF1a314/c+UZ2KR1xrqmktH+D0H85UVJR+x5gyK2Adv55cRZ+JtoT+cFTyc+wtsa6 H3i/XmfHpccrZFDHjMsFPPk5KONdHAXF4RqxP4Q7l7rN62yQ87W2+d2o2ZsFIBd5MAwA f4nWbBRigOZHsMKArgLH6H/rliVCiCd3t7Ibqcmgy9ZuJQ6q0Jc4l1P+XIvUw5XYABj2 CpL+zbzcNSUd1RSKzaXEL58V3LKqALy+XY5XIETxu+ZSnWNELxOJlrUHf+SJAxPqGmfy bnWjhoM4tL3T7jsJhV4pk/lnhoz0o8RPhJCJ6w3nIXjWRLQV8ldFIbXOeWzC7SJCHL3b USJw== 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=rEiLyWdzEcTBKvUl1wWhDb71+YfW4Cg+mTk2INAVt7c=; b=kZNhESYJW37164oj7GQG5dVkhhcF44GRwZC0MgJ4FY2NMdSqaonOlrDAk5+t9cIKEZ PHr4s8kXZwAYDmtOdbblFhTzCRiQ4nCEVrODpvJUTXpPcG5UkcLa+w4ipAvUmN89v/cs 1QK05SAtYNslBhgggZjfb9/XWrpxUz1PCQRYGOTBH5SCbEoCG2rTvSFO8NG4qkW/WA8O 4j6mMAEi6x4Nt0AoFQnHuh1tvNqZpuDW9NMzilgJzwHl6k1WvLaK+Okauq+bv8rwYPCK XG+szQA3yAHnKO8stHeSdj/hbdhWxTJsEjmcF3WLvAIgSGA8kIifDeWgb2340Cf/Gqz3 1NPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Qs/9nJi2; 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 l4-v6si13311882plb.741.2018.04.08.20.08.21; Sun, 08 Apr 2018 20:08:58 -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=Qs/9nJi2; 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 S932452AbeDICQq (ORCPT + 99 others); Sun, 8 Apr 2018 22:16:46 -0400 Received: from mail-dm3nam03on0093.outbound.protection.outlook.com ([104.47.41.93]:60032 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755154AbeDIAaa (ORCPT ); Sun, 8 Apr 2018 20:30:30 -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=rEiLyWdzEcTBKvUl1wWhDb71+YfW4Cg+mTk2INAVt7c=; b=Qs/9nJi20MQQumdrhAnZuWO5l/GC/LdXYHeYrRsS70LDhIW4s7oGwLI7nEbt8prMU3Uil/kFa47K7BcJD0VHIBezzIUy5OJTdKUKBj3sBFLypaWbtN8VA0LXUA8aK/zqkOg5MXve64gaod62EW4L7KHdxkUWpekaWxZdtiqaD1c= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0807.namprd21.prod.outlook.com (10.167.110.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:30:25 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:30:25 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Sunil Goutham , Will Deacon , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 135/293] iommu/arm-smmu-v3: Increase CMDQ drain timeout value Thread-Topic: [PATCH AUTOSEL for 4.9 135/293] iommu/arm-smmu-v3: Increase CMDQ drain timeout value Thread-Index: AQHTz5kkstlDnN0SlUiUipCZ9Ww4ew== Date: Mon, 9 Apr 2018 00:24:38 +0000 Message-ID: <20180409002239.163177-135-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0807;7:C+BNYYrtWQVna8ZLmjSXpUAuziqrGyYGZYhRTx6MZN+rMxpV9BQ7MV3EzHDc2yiAVFPQmjDlloAsElqk/QVtx828kI2N4CFfrjptMWVye3qIZ3Vk4UdhP1o9S9EOxHKogkKmYgKoKD+5qc18J+iveBiIINDp9ZPhnGExJVW9oS+j8QP29asx0cr4p9mk72q4/gr+RFZlMc0lbVy6LOXDAzy/OasWm+ZHYv8Z/ssMIq9oTibNurtulglmMVGXWb2I;20:4r6lybb0wNH0oZUGIQFRVezEE+nJMGH9JPgeCFizexYF1Ab1MZI3kDpjytVjN955riwYe84NJSHG/3ndBV8mfUGbS13IDIvB4iLnSs3EHTT/5X7y3ylqeJaaQ3lTGU5Ah7D0NRdcYhIgmcWYg6ut7Nq57YJTWAPPLgyHAGjkw3g= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 0dfc504f-3558-4a89-84a5-08d59db116c0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0807; x-ms-traffictypediagnostic: DM5PR2101MB0807: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(180628864354917)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231221)(944501327)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0807;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0807; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(396003)(366004)(376002)(346002)(199004)(189003)(14454004)(4326008)(54906003)(25786009)(53936002)(2900100001)(1076002)(3280700002)(6486002)(186003)(2616005)(68736007)(110136005)(11346002)(10090500001)(6116002)(107886003)(3846002)(36756003)(8676002)(72206003)(22452003)(66066001)(26005)(6512007)(478600001)(3660700001)(81156014)(86362001)(81166006)(86612001)(7736002)(305945005)(8936002)(10290500003)(6436002)(105586002)(6666003)(316002)(76176011)(5660300001)(476003)(106356001)(2906002)(6506007)(446003)(2501003)(99286004)(5250100002)(486006)(102836004)(97736004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0807;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: IWBFPLj2jEX06d+g9Hv6tkSaV4JvrD3azO9caYXORbCHcwQBm8p9+/kLapky45vQ1L8HfLyB2w9QzkxZjIzfxj+Wwz0kezZZy+s9V3nsQzbSkWyu0Cy9x4v13oKixHQV9TqJl0iYiDJ6k1tAjtZV7P8kvCLSjfxyL4jerFHYX3y0IKg1HO6/PX/xPxOQqELr2weHqkqDANzNRJLENX9owCc5pTi8Q/BRTlhABF1D5xcnfxm6puuoB5QXJUEj2tIcnC+r4QSTDDVBLoHDW6YNX9A+zXkGQZlU7ZI+IjGl7HRzLssO6mDnTlHkbb6WOpmrAaDx/iCiw3MqDnftBH04uwXFnSYYQybX0orY5KDxRblkMIPXmyQckOQvWbsRVgoVgxELdPcwwBxS0JJwGCxP543OG2Hv5y1Fn7iymAHwcaI= 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: 0dfc504f-3558-4a89-84a5-08d59db116c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:38.1125 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0807 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sunil Goutham [ Upstream commit b847de4e5087fc8577c38a697d14fd2a5ce93352 ] Waiting for a CMD_SYNC to be processed involves waiting for the command queue to drain, which can take an awful lot longer than waiting for a single entry to become available. Consequently, the common timeout value of 100us has been observed to be too short on some platforms when a CMD_SYNC is issued into a queued full of TLBI commands. This patch resolves the issue by using a different (1s) timeout when waiting for the CMDQ to drain and using a simple back-off mechanism when polling the cons pointer in the absence of WFE support. Signed-off-by: Sunil Goutham [will: rewrote commit message and cosmetic changes] Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/iommu/arm-smmu-v3.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 7f294f785ce6..399b7f31fccb 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -409,6 +409,7 @@ =20 /* High-level queue structures */ #define ARM_SMMU_POLL_TIMEOUT_US 100 +#define ARM_SMMU_CMDQ_DRAIN_TIMEOUT_US 1000000 /* 1s! */ =20 static bool disable_bypass; module_param_named(disable_bypass, disable_bypass, bool, S_IRUGO); @@ -726,7 +727,13 @@ static void queue_inc_prod(struct arm_smmu_queue *q) */ static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe) { - ktime_t timeout =3D ktime_add_us(ktime_get(), ARM_SMMU_POLL_TIMEOUT_US); + ktime_t timeout; + unsigned int delay =3D 1; + + /* Wait longer if it's queue drain */ + timeout =3D ktime_add_us(ktime_get(), drain ? + ARM_SMMU_CMDQ_DRAIN_TIMEOUT_US : + ARM_SMMU_POLL_TIMEOUT_US); =20 while (queue_sync_cons(q), (drain ? !queue_empty(q) : queue_full(q))) { if (ktime_compare(ktime_get(), timeout) > 0) @@ -736,7 +743,8 @@ static int queue_poll_cons(struct arm_smmu_queue *q, bo= ol drain, bool wfe) wfe(); } else { cpu_relax(); - udelay(1); + udelay(delay); + delay *=3D 2; } } =20 --=20 2.15.1