{"id":811007,"url":"http://patchwork.ozlabs.org/api/1.2/patches/811007/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1504790001-24715-5-git-send-email-bmeng.cn@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1504790001-24715-5-git-send-email-bmeng.cn@gmail.com>","list_archive_url":null,"date":"2017-09-07T13:13:21","name":"[U-Boot,5/5] dm: usb: storage: Fix broken read/write when both EHCD and xHCD are enabled","commit_ref":"ea7fad91019654fb21e6cd04f963e0482869dba5","pull_url":null,"state":"accepted","archived":false,"hash":"3cc5954ddafbdd2967fd2a6c8c35f7830cbb5da1","submitter":{"id":64981,"url":"http://patchwork.ozlabs.org/api/1.2/people/64981/?format=json","name":"Bin Meng","email":"bmeng.cn@gmail.com"},"delegate":{"id":1699,"url":"http://patchwork.ozlabs.org/api/1.2/users/1699/?format=json","username":"marex","first_name":"Marek","last_name":"Vasut","email":"marek.vasut@gmail.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1504790001-24715-5-git-send-email-bmeng.cn@gmail.com/mbox/","series":[{"id":1998,"url":"http://patchwork.ozlabs.org/api/1.2/series/1998/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=1998","date":"2017-09-07T13:13:17","name":"[U-Boot,1/5] dm: usb: Add a new USB controller operation 'get_max_xfer_size'","version":1,"mbox":"http://patchwork.ozlabs.org/series/1998/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/811007/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811007/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"jLzzP4KM\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xp16k6n9gz9sNd\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 23:11:10 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 973FEC21E9D; Thu,  7 Sep 2017 13:10:08 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 29541C21EA2;\n\tThu,  7 Sep 2017 13:09:39 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 717D2C21E8A; Thu,  7 Sep 2017 13:09:09 +0000 (UTC)","from mail-it0-f67.google.com (mail-it0-f67.google.com\n\t[209.85.214.67])\n\tby lists.denx.de (Postfix) with ESMTPS id CDF4EC21E84\n\tfor <u-boot@lists.denx.de>; Thu,  7 Sep 2017 13:09:05 +0000 (UTC)","by mail-it0-f67.google.com with SMTP id b76so901149itb.2\n\tfor <u-boot@lists.denx.de>; Thu, 07 Sep 2017 06:09:05 -0700 (PDT)","from ala-d2121-lx1.wrs.com (unknown-156-139.windriver.com.\n\t[147.11.156.139]) by smtp.gmail.com with ESMTPSA id\n\tw63sm1238554iof.18.2017.09.07.06.09.03\n\t(version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 07 Sep 2017 06:09:04 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:subject:date:message-id:in-reply-to:references;\n\tbh=1oz7epuaqQKiow+mUYogBM/j+w4jZpy3snsLr+TqydA=;\n\tb=jLzzP4KMLthZ8ua6k2R7UPEsRQG9pHzAFfP3XhV1Py+dM2FTzB83CszqddNcAYEtkD\n\tXazGinXPs7+LVbyEM1Bz11aiCAVt0Lrv3uXc4+ksG1Lc2+/CgoJ3oFq7rvdYgjdu5IIQ\n\tPwzh/JeeUhQqvsWt2pZ9Mmt99u1tP7QxJF/QTndxSmmVTr1b0gJDrHIwrRl984aHJPQK\n\tbyEVsF8vwAL9OjxGGBmClfMy3XZWhhtLt6hcN7BBJIj+bmhP+Tb/icMIkuQrng7+BiWL\n\tAhaCDNu7Ralb/r0LmL95G19wc/lgvquQL+Lc0sKZRevryLpySrlrcqCcKT/MUZiYm0Yt\n\tCE7g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=1oz7epuaqQKiow+mUYogBM/j+w4jZpy3snsLr+TqydA=;\n\tb=cAD8spOt9LLmNDghFoYxPnqd810o/RV3dRwoXyHTvTwVJB0dw5x4vEe5OsLEErEdOo\n\ttGdzpriKucFeeza33/YGqEFaPX6aQ57q92QRgFGq92wTiIrKPEvuNu4XGqzbpR3yMclq\n\tDHgX5gKpulCwQJy/hVdvmvpn4pnbFO3FoU0M7m8CMzjUyvLR8vRglOKOhZ47W4/BYWaU\n\tNTAHN3nU8vsAxLMn8eFaUamltzaKYAk7TSRUoLWGQR8IXXOJBHFFLZBUWmmCS/ii5a24\n\tmWz1Vt0XlBPN9cBlLOkt3OdNp5N6U3j8p+xCFZE8+DX3T8hQVJbbQk4NIkKR46nA+ice\n\t4oAQ==","X-Gm-Message-State":"AHPjjUgGsCO92IVzkW0R5P2TTJ/hvIJz00Hzmoy4AgKEVp6wAnn2EcSu\n\tsuAI17vkVrNxxg==","X-Google-Smtp-Source":"ADKCNb7id+o9vBSPWFECtuoN5bvWI4hgihTFmyBg9nK4YupcTfsvVqcGgWFL4I/OYn50SeUhftTfXA==","X-Received":"by 10.36.166.72 with SMTP id r8mr3399673iti.113.1504789744779;\n\tThu, 07 Sep 2017 06:09:04 -0700 (PDT)","From":"Bin Meng <bmeng.cn@gmail.com>","To":"Marek Vasut <marex@denx.de>, Stefan Roese <sr@denx.de>,\n\tMasahiro Yamada <yamada.masahiro@socionext.com>,\n\tSimon Glass <sjg@chromium.org>,\n\tU-Boot Mailing List <u-boot@lists.denx.de>","Date":"Thu,  7 Sep 2017 06:13:21 -0700","Message-Id":"<1504790001-24715-5-git-send-email-bmeng.cn@gmail.com>","X-Mailer":"git-send-email 1.7.9.5","In-Reply-To":"<1504790001-24715-1-git-send-email-bmeng.cn@gmail.com>","References":"<1504790001-24715-1-git-send-email-bmeng.cn@gmail.com>","Subject":"[U-Boot] [PATCH 5/5] dm: usb: storage: Fix broken read/write when\n\tboth EHCD and xHCD are enabled","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"When EHCD and xHCD are enabled at the same time, USB storage device\ndriver will fail to read/write from/to the storage device attached\nto the xHCI interface, due to its transfer blocks exceeds the xHCD\ndriver limitation.\n\nWith driver model, we have an API to get the controller's maximum\ntransfer size and we can use that to determine the storage driver's\ncapability of read/write.\n\nNote: the non-DM version driver is still broken with xHCD and the\nintent here is not to fix the non-DM one, since the xHCD itself is\nalready broken in places like 3.0 hub support, etc.\n\nSigned-off-by: Bin Meng <bmeng.cn@gmail.com>\n---\n\n common/usb_storage.c | 19 +++++++++++++++++--\n 1 file changed, 17 insertions(+), 2 deletions(-)","diff":"diff --git a/common/usb_storage.c b/common/usb_storage.c\nindex 957ccdb..a57570b 100644\n--- a/common/usb_storage.c\n+++ b/common/usb_storage.c\n@@ -939,10 +939,14 @@ do_retry:\n \treturn USB_STOR_TRANSPORT_FAILED;\n }\n \n-static void usb_stor_set_max_xfer_blk(struct us_data *us)\n+static void usb_stor_set_max_xfer_blk(struct usb_device *udev,\n+\t\t\t\t      struct us_data *us)\n {\n \tunsigned short blk;\n+\tsize_t __maybe_unused size;\n+\tint __maybe_unused ret;\n \n+#ifndef CONFIG_DM_USB\n #ifdef CONFIG_USB_EHCI_HCD\n \t/*\n \t * The U-Boot EHCI driver can handle any transfer length as long as\n@@ -953,6 +957,17 @@ static void usb_stor_set_max_xfer_blk(struct us_data *us)\n #else\n \tblk = 20;\n #endif\n+#else\n+\tret = usb_get_max_xfer_size(udev, (size_t *)&size);\n+\tif (ret < 0) {\n+\t\t/* unimplemented, let's use default 20 */\n+\t\tblk = 20;\n+\t} else {\n+\t\tif (size > USHRT_MAX * 512)\n+\t\t\tblk = USHRT_MAX;\n+\t\tblk = size / 512;\n+\t}\n+#endif\n \n \tus->max_xfer_blk = blk;\n }\n@@ -1393,7 +1408,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,\n \t}\n \n \t/* Set the maximum transfer size per host controller setting */\n-\tusb_stor_set_max_xfer_blk(ss);\n+\tusb_stor_set_max_xfer_blk(dev, ss);\n \n \tdev->privptr = (void *)ss;\n \treturn 1;\n","prefixes":["U-Boot","5/5"]}