From patchwork Fri Jan 4 09:24:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Li X-Patchwork-Id: 1020656 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="fyqxgOkk"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43WK9k3L3Xz9rxp for ; Fri, 4 Jan 2019 20:24:26 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 0BDE1C21DB3; Fri, 4 Jan 2019 09:24:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 40CA5C21C93; Fri, 4 Jan 2019 09:24:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8A1C2C21C93; Fri, 4 Jan 2019 09:24:16 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140044.outbound.protection.outlook.com [40.107.14.44]) by lists.denx.de (Postfix) with ESMTPS id EF8E9C21C8B for ; Fri, 4 Jan 2019 09:24:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bY0FPcNlGcsYgt6xlQk0kAJvozJBqIs27tVEqVV96B0=; b=fyqxgOkkGYm5ondrZLzpbsp9Vu3buvejh/p90fSYnPG0+xJB1Q1bP+xrZThTfTWf+zvUjm0zXuQIGQ3IxfYh7bg7O5siPqsVFhRooaqR4+/JJAYf9Qwx4dklJT04DXsMVGWINgEp3mfDl//ddijqJjii9qHT0salF+8eIWtKfYU= Received: from VI1PR04MB4414.eurprd04.prod.outlook.com (20.177.55.153) by VI1PR04MB5391.eurprd04.prod.outlook.com (20.178.120.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.7; Fri, 4 Jan 2019 09:24:14 +0000 Received: from VI1PR04MB4414.eurprd04.prod.outlook.com ([fe80::f1e0:df54:f9c:b4b9]) by VI1PR04MB4414.eurprd04.prod.outlook.com ([fe80::f1e0:df54:f9c:b4b9%3]) with mapi id 15.20.1495.005; Fri, 4 Jan 2019 09:24:14 +0000 From: Ye Li To: "trini@konsulko.com" , "u-boot@lists.denx.de" Thread-Topic: [PATCH] arm: Round the dma_alloc_coherent memory size to cache line aligned Thread-Index: AQHUpA9CMLSPF1khtkC7/ylOc/BOiw== Date: Fri, 4 Jan 2019 09:24:14 +0000 Message-ID: <1546593834-41316-1-git-send-email-ye.li@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK2PR06CA0009.apcprd06.prod.outlook.com (2603:1096:202:2e::21) To VI1PR04MB4414.eurprd04.prod.outlook.com (2603:10a6:803:6e::25) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ye.li@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.68] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR04MB5391; 6:BG8dF4gPWnqHOI+giSHvix/+8UOst40eQTZdcmScrfAin1svKe7lU792qXQicHiRvXeIYqYoGu/ELX4t1njMYDbaTqBvx9jwBqm/bvXIxHdpLHALNgvEwpi4JvTYLsJVgpwnmnmHZyemdelVWW4so0RkwYlefz5EB3afrZb8v3YAMj8ABjVoiRm51sQ3F+dk9H2toR9EZmletE4g9Nzoo3IPtz6iSpQVLEbthTMm3iuAKhBm2P1AtzOD9ZxdfK/iZWTs0xEhRGNOjtw9qKSrDV+iTuLkf6q14mdaGgkKhLq8NTnB/wddk2YmkMd8eWsla86hqKX9eNWf44FEdP1FXZAWnFz41CXcz96JZGHHz5KOZlV9xDFxRcsO4B+tgrNTH0Fd+3kw8I/gqmMtTlTqLK2xpBDSKkOvNFc1NJir19dfaKlGCwQ/QwCOH2Hqb2UzzujgoUQMVRmu73JOSxPexQ==; 5:ERevcVgf/lMv2kbB4lS/IbD60uZclv3IFN/+ugvAT9pj+8K4cOq99WF6nblYtvsv1yNyEqoUhXECbCob3UIlch8VOg/5YaJ57nFhT/jcOSJMH8s0USTR7+FLHLhmeQ527VgNu301cp+H966YgST0JgIG82h/UU9lTV50TYkl1ueNbhizLE+DOBujUQ/eNY3JE/eKrPyC60cCOVCSd3gHRA==; 7:D/FYKuneXEj/TpFNewWAOXqYPwSQUw9klH+JFGdityBD7x9Ufkiq7JBKbYur9DSKdZVRPgOWAHvWNfKfuKUe8kXOmgEwRZoVCMGuCK8vdpZ5FWtzaSWZEswg7v4fav4QsP1ukN52Pjbpn87E8taL8A== x-ms-office365-filtering-correlation-id: 19627671-16ed-43a6-88b1-08d6722664a0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB5391; x-ms-traffictypediagnostic: VI1PR04MB5391: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(3002001)(10201501046)(6055026)(6041310)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:VI1PR04MB5391; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB5391; x-forefront-prvs: 0907F58A24 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(366004)(136003)(39860400002)(199004)(189003)(25786009)(478600001)(14454004)(6486002)(5660300001)(26005)(186003)(68736007)(86362001)(4326008)(53936002)(54906003)(305945005)(44832011)(7736002)(110136005)(71190400001)(316002)(6512007)(486006)(6506007)(2906002)(6116002)(3846002)(2616005)(2501003)(476003)(6436002)(71200400001)(105586002)(106356001)(52116002)(8676002)(8936002)(81156014)(81166006)(386003)(97736004)(256004)(14444005)(102836004)(36756003)(99286004)(66066001)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB5391; H:VI1PR04MB4414.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: P0x5TJqo6ArpJpmZe05FU8yHwy6I6EEUrXrcPSgtMo7tIwl08fOmgx9LPdtJp/LjJc46lfNrV7BsuDYJj3/byovr2sLavWVmuBXJRQ/fcYu5Yyo6hZtEnQl2C1udJTrYWhfyv7JC8S7vBBu4Z5kk1zyA2lbCSLaU7Az+Pvqaogbomm57rKn4YU3mhx0lXkWL5kRA3dBIWXENHN27e71bPlQsaLFCzpdLR0BvDpA5WcL9rrN6aLRgoVA28/RsqI52ScjAo3oKwl0B6NCG4H4kCcEPpuyByFLlCEoSrrYjJ7c8opg9QhN2Pw2oPBHciZ/6 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19627671-16ed-43a6-88b1-08d6722664a0 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2019 09:24:11.7538 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5391 Cc: Fabio Estevam , dl-uboot-imx Subject: [U-Boot] [PATCH] arm: Round the dma_alloc_coherent memory size to cache line aligned X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When running usb dwc3 gadget driver, we meet random USB enumeration failure in fastboot. The root cause is a cache coherence issue. When it happens, the ctrl_req in gadget driver is allocated at 0xfe932f40, and the usb_composite_dev (cdev) is allocated at 0xfe932f60. So after we submit the setup request (cache flushed) to USB controller, any accessing to usb_composite_dev variable will cause the cache line refill, then when setup transfer is completed, reading the setup data in ctrl_req will gets old value from cache not from memory. The ctrl_req is allocated by API dma_alloc_coherent, but u-boot don't have cohernet memory. so it still needs cache maintain operations before/after HW accessing. Since the cache flush or invalidate bases on cache line, so when the allocated memory size is not cache line aligned, potentially it may meet such issue. This patch modifies the dma_alloc_coherent API to round the size to cache line aligned. Signed-off-by: Ye Li Reviewed-by: Peng Fan --- arch/arm/include/asm/dma-mapping.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 0883b7e..fc5b8f6 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -13,7 +13,7 @@ static inline void *dma_alloc_coherent(size_t len, unsigned long *handle) { - *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len); + *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, ROUND(len, ARCH_DMA_MINALIGN)); return (void *)*handle; }