From patchwork Thu Jul 8 17:14:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1502553 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-secospa-onmicrosoft-com header.b=s32bi+60; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GLNGF3LW2z9sWc for ; Fri, 9 Jul 2021 03:15:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C37E9831BD; Thu, 8 Jul 2021 19:15:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.b="s32bi+60"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D315831BD; Thu, 8 Jul 2021 19:14:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on0604.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::604]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2E3DA831A5 for ; Thu, 8 Jul 2021 19:14:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WChqC/Z/0I6p2E3UpZxiqjSAY14NKK0Xi8kf+B6t6LFOYuK4Yn7guHvtzDPPJw2F0jDc+2cV5qjSTSt/y1aikH1w8si2AQntjRvEHf2pdI1Sz90hK8GqD0oeLBfedRXxXxUQGNZ6aZgdPDn4N5RaO1P6tyBt2S15fEjydL5Q0aEkoeff+2sg5IPnu23H4YvETKjkKxzT6t+Mmt0xWT8lwJL0jsg3zMYvvLzoz6V4cgTbutB3zS38QtK841pKfbRsGkdbfA1e887t5l9GJvgoercr71bXxvq2EgCdfaHam9Jfh1oO69+TZyDmscuEALCais/8bxYOyj1y03UMWJyBVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=188Kw+90vquADOdqDzeFeyx10JU30uAKOEoZkt/09S4=; b=GAjhT9Pc7UnlkgrGtpDR7MuyWeeRe9rQaR09E2K/7Oyh3Zj7ijXdcRJR0BvixDv++WWaLdyt8b9cLwyXvWvvI5jhqf1phmvNNBJcnqAy4dlY1E656XTGhmrnJQZ8xmdCILvc9LOhiE3z4PSL+fGn67OjhgREf0I3TQUa9HKMjCGxGljdae4s+Q/ZyK4xMSojRTnEFvg9gN1lJmaF7pgZh2tnuIdKksDEtFMOH70DytRWyJXPJSMDahCFyoE8QT5FkBcAtEju64bUoTJqYP7Hdr5T5tzy03hiOBkbGeGFWayl+W46YDNq5kGU+6chcmlDb/2W9CUDj7swEVU1lhUXIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=188Kw+90vquADOdqDzeFeyx10JU30uAKOEoZkt/09S4=; b=s32bi+60mST4nEoEiG6DYZ2lK4FpRUSoFk7cZd7luOClgpoa6vcNaw5zhwJg1BkqCLmKiHwMuJ87LxpEgITuwvy4VQZIWHT8DyHRRZJmPfsrLjEvdvKJQrduNyaLSimTVBrmDd3TXCpxNW9dc+S67w9h2FvR7NdlZArgpiH3dBU= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DBBPR03MB6762.eurprd03.prod.outlook.com (2603:10a6:10:20b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Thu, 8 Jul 2021 17:14:55 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b%5]) with mapi id 15.20.4264.035; Thu, 8 Jul 2021 17:14:55 +0000 From: Sean Anderson To: u-boot@lists.denx.de, Lukasz Majewski Cc: Maxime Ripard , Jun Li , Andre Przywara , Jagan Teki , Marek Vasut , Marek Szyprowski , Ye Li , Peng Fan , Bryan O'Donoghue , Sean Anderson Subject: [PATCH 1/4] cmd: usb_mass_storage: Use part_get_info_by_dev_and_name_or_num Date: Thu, 8 Jul 2021 13:14:20 -0400 Message-Id: <20210708171424.970928-1-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.12 via Frontend Transport; Thu, 8 Jul 2021 17:14:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4edf9fab-bd01-4ecf-d844-08d94233e7c9 X-MS-TrafficTypeDiagnostic: DBBPR03MB6762: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6iJWghJ3hvTfoOgC7/D0fWEFkjBwDY5Vm/L8zAS4rV3rRtv0uY8eZYuatIdIwqTFIGDiok465hhXvgLNm/M/4w2InuZwAHCrhtG71ejCMmC5X75CbcwgqOYHzsckwn206rU52CXDreYv6Za+p/iDf8S+EHa8G8L+LeVRZ/eIUVbBpZgzC8fWI3se8UE7nJk95E4BGZ2PQdlNRxXdcB18cHsOL5bs7E2s5GXe9A/VIfbrQejrramEDeifGehoWDXYZQFw9Gft+lItffOOHpzmCROyH7Phh8E/zGrFg/KheLn7lerzm+SPy3H1MqAdJCdCzN3+nBkrtvMPXA58506tfi5iTce6bx53nDUhE25wT7wU9F2yf3FMOBBnu+JwSdhtmBNdtmNLukSB2OMMXW6sTK1Ug709rZfFcuamSTmhGZL/4LzY5pWiPNgoFrK3W/bndO8ShlCKQKiObIu2svd59w7/6xmhlo5GwtF/CZFJZJRWY33ppZb9Io30AjEuNUNGhBO7AqsyOR+dPhUdVW7Vi8ZU3rMBgYrbn3dtWmLbgmSKoRYGNQnl7v4g1PLFO8Ri5/ltfkkjJRg/p9zv2bUaGvnpEXVFhj4sXmp8+gOB3agTjmeYS3qUamGiD5KV+TO2tBJm+DeJKLJyp1xXBC+6+ekWoDAEfaU8L+PRm26y/RMauyd3HvTt2nbVxfMg35fpS+sSamaRzih4J3fOGJHbVg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(52116002)(54906003)(498600001)(6506007)(6666004)(38350700002)(38100700002)(2906002)(8676002)(4326008)(36756003)(6486002)(8936002)(83380400001)(66946007)(66476007)(66556008)(86362001)(44832011)(1076003)(186003)(7416002)(6512007)(2616005)(107886003)(956004)(4744005)(26005)(6916009)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SEoOt+nEynwoRrKn07FLDkCjDwide7e/caYvtqh3IGe59e8JXFDfGOqtnZivj9wlDLzfupnIoDn0nTLs1WVgt09UO1z2p26NJGyWuLwDzH3duGW4mmeXpB8hkQN9tLjzC5ZVkibPoMHaZHi4VDjZZFuNPcAL34kzLhtB+bZz1FDjuIT5T1qRIW+grVkMaKYCMr1gAcckmDP4K825EEgTMo6/FCi+QxPcRWXB4mDaK5jc5hAD0ixYKMqLMMOYXVFDefdTUqwDUNtAI09kqTVxKAa+Lmsgl3KApzsv2GMtI0MteX/8R6Ndph6TUP4cR0oXPEamNxWEbzwO02sCi5mVO/4Mrva3vOwZUB1ZByVdqYixn/95iqGdmvFSLeChwe+Lb3x3hZrvsAYD1M4TWgSKFnstqFq2BT5yOyYOAnIMmUDHcz5iUvLP8NtCkQhVjEGetwh3GSQTT2PsmC7mWCdN2wOUGqmWTi48cwB6/9+o8HoWbwZGUFc553lzbaZSU4uq9cacOOQqtil6d3ai4gauK5aL3vJhDueHmSwmiOyJZcup7UQxJ/EYrgNwJNa8Z1vXqOyNOKBw4j3+5BZdYyaXOi8OIk6/k/dFbgnRWKm6w8ot2ykphjUlrlytYwufUpwx/l6pQY7ZnCFaO+y5x+ZfEirlWy6MLPPgM6Sao/mr4B56yWYNkJOGoRNVbrEpPZCb9mrtFPE3y73F04LV10NSyatRXrypjKvkq85V7KaX1o2OKr7x1dy0wXEmsBZgY9Nh5jiFN2Vyh/QF+Ydg6yKVconGTw91+OvfFFw0/8s2OkfZ5uqengT6dk8a5DPEPIBaiQh/HgDzwh8dViZ20l0iSxzLaBlyCAE4CEmoxi+1ctddKmXiDf4yeqmVz4pKxTT14PhftQbi7RnJdsv2lFGuGrjFf//wWkZKPw1ZpOMSYS5uERrraNgTrG/dR1iRvgT0CWLZ9m52NlgDuRRa9gjC2p3ayH/vV24RPEuxrfi1kMYyQJPmNvBaTjM+e/q4N50OmQFEyu/boEpIdtNzNCDz82PRR+POkiHjgPuH+DifazUIUdYzayMjl+uJQZ5nJOSweFOLVJ8e3fZv0We8M1CIruRLpKvMne7ivFO0xBGn+GmlbdzoK2npMCnHNSFleNj9/mMAYCX+oLKQLtnIc7UBNZ1JGSPcLB2KlActUIf5Qj1AJQlXKZqvpslWpjo1QEPE/FEHvzy2C8lOEOa6iRwypfCzoYyvtrS5Q0hMm7WlhW3Re+knkQKhSqVyJ2PEtrFEOlw5h++eJ/6r7qji+Ro8hx3vpJj/wuD5yqu4N9ZfZMmNFvJXA9xlf9W3fY5WrhbJ X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4edf9fab-bd01-4ecf-d844-08d94233e7c9 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2021 17:14:55.0935 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SSii0CdjD+regS+zTvmQxTnr4gI0z1fRlp8V4bd214+8EyFyuAV1BPcDo5YhEPAYDMrJeCauDFYDNx84FoSYqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB6762 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This allows specifying partitions using more extended syntax. This is particularly useful to access eMMC hardware partitions. Signed-off-by: Sean Anderson --- This patch is independent of the others in this series and may be applied separately. cmd/usb_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c index 14fa7233c7..d4e619b842 100644 --- a/cmd/usb_mass_storage.c +++ b/cmd/usb_mass_storage.c @@ -74,8 +74,8 @@ static int ums_init(const char *devtype, const char *devnums_part_str) if (!devnum_part_str) break; - partnum = blk_get_device_part_str(devtype, devnum_part_str, - &block_dev, &info, 1); + partnum = part_get_info_by_dev_and_name_or_num(devtype, devnum_part_str, + &block_dev, &info, 1); if (partnum < 0) goto cleanup; From patchwork Thu Jul 8 17:14:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1502555 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-secospa-onmicrosoft-com header.b=kI024+Ra; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GLNGT5Lwlz9sWl for ; Fri, 9 Jul 2021 03:15:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ABA73831C0; Thu, 8 Jul 2021 19:15:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.b="kI024+Ra"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 99570831C0; Thu, 8 Jul 2021 19:15:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on0610.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::610]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1DCCD831B0 for ; Thu, 8 Jul 2021 19:14:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SH9LiJehfEfmj3m+uWpmsxRHF+KzHcthwBlrVuG82m3vJHkBTGum9ogcsUwU9xHfLdyy8UkKQnG5p5uvWNcoia+JJPlksKyKcOonMeBTt1zozbYliLnFOLcwXmhKk86lhvOqfilvPSbN5skQqw7VUysyjhqpLEY/SZuAE+l36J78vVROVG7FVgTfeMIdE1feID9Gt274AGBm8IMtAXv1XmkyHva+iSkg2jMMGUfo9AWjLPS9mWH+h/TGSHaEKHVt8Knl0+I8mCYAunGDX/TYrkXLNf3WQKw7DBFCxNxTQ0jGjcYBwSBLF0R7xNab/rVhQ8dEMfh2vs5aLEL+8mB99w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6UoW03cYGS9vzjdVsyu0Fb5ZPnngvtb88tOOmwjq3S0=; b=cBuh7DhOTY1u/9rbnMKiALUecYbauT4OhH7jrWNb0ezz4XqWKhQhPx9OVIxtNKxHgurQjcM36Zu6Qu5wYqip54j44/mCi9d76mss1jeQL0YYxp3NjFmQ1MTs3t6eacVCh/7MsiEWtOTa5+iR7jaQJs6OWWn6DVBp78uM0XIJNsf/JeiDpb+AhqhY3we9OhIlMauwiG9lE9fIgnu0XhNxV7efjCS2BXxc8qTxv+O3inhg3i7Qz1GkI3Ps/PLKZQH/as6AzmTJENtHsBl2H8CzkdwtpU03l006DItYUv5zMLZ4Hoe7fiCzjVkQpG5GAhHN+wyNClCgU1M/4zxnlIVprg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6UoW03cYGS9vzjdVsyu0Fb5ZPnngvtb88tOOmwjq3S0=; b=kI024+Ra3t+baAKn7UmHgx+KfSjveSATPJsWHp0V2z3LoZuf6h1p/6z91W5lui0UpZDxCqoehwX7HpYM8efMCQOY0Qc/pEwolcLrTqkpgYSSM3TqdtaZ8LIraMQZeWZUkW9UMregRVeme2r59i6kTAeQiEj6BWx3kuUmk8QbRiw= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DBBPR03MB6762.eurprd03.prod.outlook.com (2603:10a6:10:20b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Thu, 8 Jul 2021 17:14:57 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b%5]) with mapi id 15.20.4264.035; Thu, 8 Jul 2021 17:14:57 +0000 From: Sean Anderson To: u-boot@lists.denx.de, Lukasz Majewski Cc: Maxime Ripard , Jun Li , Andre Przywara , Jagan Teki , Marek Vasut , Marek Szyprowski , Ye Li , Peng Fan , Bryan O'Donoghue , Sean Anderson Subject: [PATCH 2/4] usb: f_mass_storage: Check bh->state in sleep_thread Date: Thu, 8 Jul 2021 13:14:21 -0400 Message-Id: <20210708171424.970928-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708171424.970928-1-sean.anderson@seco.com> References: <20210708171424.970928-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.12 via Frontend Transport; Thu, 8 Jul 2021 17:14:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9eed1207-8eab-4f3d-1ff0-08d94233e8e6 X-MS-TrafficTypeDiagnostic: DBBPR03MB6762: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:291; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9bTWbvPZqzePedXWXVbfU1NUE5YVdPys/No7Y8aZBm4Ump9AlKkRrRDy3TZSllaqDJ2GvECDTYgjlcMMkfDw8lve+z6eWRZDfwXFhtwx9Mh1eQAVl3E5dTRx7mtP4ZXziteDAs7KA0HrCUP2vMq0a29TIZ8ZqLk5Pyyy11WPAquucdlEDu8khGVPbuCGX+WOzWMb2QEGyGzGfB+oeBSd5rkujS++0jhduZIKy5zuN1R7HL/gMEveb9A6wXJ9MmtxEf+GDqxXyPCFlBpkkug1m1Ca/pTkbyzFzvVpQ4vOWQx14xfnIXFiSog9hADrlVJzvldgHt29FDI+nqu/E7aABAj3P1lzZjCXTAG6O5VD5Uo3hgC+PNFovUhYGlNzX7pqVneTlKNlR/VvnIx9Aead4xnoUHJevKufmIJigEIrKW07ZVf4HBv3BBr9PtFix5CCZfdagNu62gDZMurIMK84POXK6pKmKdJTDIeyI2KiQXZPbjJK8v6KxQct3s1/v/tR1HBKV2PwHbnLefSsXgppjsN4iAKDv+ffVcwMfoWnKVzwu5TZlusyfArJGz5k5Tiyeo9vzo+8yxsjxLd1JBegHwGx72eQu30Gu/iBEzwKbQE7ckAzgr5o8WAxjBEAqOjn34UD+/PtRRrrNCk3eHnovD2V3Z5v9+2S5v0RvNKinc1Jsdv1/bIm2CZaa5WL708SPliGBFhwHS8I7VgPpm8kDw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(366004)(376002)(346002)(396003)(39840400004)(52116002)(54906003)(478600001)(30864003)(316002)(6506007)(6666004)(38350700002)(38100700002)(2906002)(8676002)(4326008)(36756003)(6486002)(8936002)(83380400001)(66946007)(66476007)(66556008)(86362001)(44832011)(1076003)(186003)(7416002)(6512007)(2616005)(107886003)(956004)(26005)(6916009)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5uUg4oJiV0TV8K1jbFJXH7xL3Vy7cTyWbVjxJV0yDT5WIt2gej+6E5HOUPjYX8wy6ZnGzS5jWHXVfCG+X8YYfwIg7oJcfoIUaiv5p6JIeECTm2KicNAiLX3P5zXgV2X1MxRrwVmll1LgLdXSGlYeMTgbVEVgaizIL0kxKM4Ph40r9PH7H4LV4lkNJJzz5JA3c/zi9b5JtlnKnsJoO6P4qGUiBbNssNb+cQGwwis11PG0TR4Sx8JxgN+QpvfAci/xFKzxJXMkq6dhknziZfBRdAI2i8OOhp+6Q2lmxsaFw2b/u4BiQowqrqNSJEMRahZsVYXh/qbWOv3KkZoEqLVakXLAMkNJ2NC3PZRCPCueZ5TFl0siih4WR5Fiqwb+5YDjGLJMu46Aml9OQkcHHJjbcOA60hQt9AubZpuUHt0KwDppMzFsJB0c8uqePNOwZ1CO+FcC5/0O6wjpgC/2TRv1qL3wTZVRoFVzZnGTWusuNtsO2yNY5PsUHnxSIObOURFwG7uEuIul57P1ODjefvjgXA/4fB63rPe4pQsdN0TmdwNPJMAG/lGxc1ahf3AUgFgB0uxbWmXYIyoZYOWZ+Xzs9Ms+vBS4vdrU5Kr7YvY8CFny6oXAYM8BNjHGPd8oYrRa9ZbZtCQG4rTquozLX0nFOfwW/HIr69taRykzgGI1UaBLhmwuvSSCEA1TD15NQsKSs1GDzM6IrGnNvFdwJgE+NwRvy21oAiyBAoHdDJuHqUF8SEoU/Kagn5wuLNs0UtkCjsnKDLiq1G8eLo13aXKyoR6uRaGoHZ7YPEkB/cWP9/KBn/slqqblxDJaHW0JJm2oC7x2jzsaB4Cssk/YXhG7HJ4OYWzu+hN0UDwEWl/E68+zL3kpkP1n2/ycfigC/NVvgSc9xjwNyoLWovSk8YocywUgEuSyeGvyrrAav1pHotl/NDYkmhN5vkPyc39isbLMDIpyETGbbwF6F9ozCxwwYqsZ/mlUfx1PPN/Zo/7439j4fOjADG0SfBBJjsGoeGnnR8k3VNuVAmx8Li2R4zoGTx3rK9DpMnHzxpLDUDJKR9Cyn7q490fVQq4AgmeMfAzsK2n4Lcvm5WDOPn1gUNqF/c7twv+tfkmKDWUYIjjKQEdZObC4fsyiHBObliB6cUChxGOFaPi1RUkkug4qmzWoaro02qgX+ejUmdljlVuNWJvIVw4dVoHQ7N5riGXg1asaK9knJ9J8IMNeEm2gSRHYUXRd+lZxhGJNM57B6YBhounoh6hRHeHh4d8W0Z+NB2YkwLvQD0QG0/1XNpzvoL/tcT8jV6jVlNlx8I0DOZ8dEpCK4gSrvYgABI18ckzimF+d X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9eed1207-8eab-4f3d-1ff0-08d94233e8e6 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2021 17:14:56.9096 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kkVkIl5MNDzNcmy2jmzBPaTn50zhurMEEdPPZy1d1weF7BOX3qFAG/HPul7x+CWjja+g1HaGpXs67asWv21mbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB6762 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Every caller of sleep_thread except one wraps it in a second loop which waits for a buffer head to be filled. Since sleep_thread is already (infinitely) looping, we can move this check down. Some parts of the code have been reorganized to better take advantage of this property and and be structured closer to their Linux counterparts. In addition, sleep_thread now returns -EINTR if we need to wake up, mirroring Linux. This takes advantage of the existing logic regarding sleep_thread, which typically returns immediately on error. With this change, any exception causes the current operation to be backed out of immediately. Lastly, we only clear thread_wakeup_needed in handle_exception, mirroring Linux's signal-handling logic. Any subsequent calls to sleep_thread will still wake up. While these changes are conceptually different, their implementation is interdependent, so they are all performed at once. These changes are primarily inspired by Linux commit 225785aec726 ("USB: f_mass_storage: improve memory barriers and synchronization"). Signed-off-by: Sean Anderson --- drivers/usb/gadget/f_mass_storage.c | 225 ++++++++++++---------------- drivers/usb/gadget/storage_common.c | 2 +- 2 files changed, 100 insertions(+), 127 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 45f0504b6e..99935fe9a3 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -652,15 +652,17 @@ static void busy_indicator(void) state = 0; } -static int sleep_thread(struct fsg_common *common) +static int sleep_thread(struct fsg_common *common, struct fsg_buffhd *bh) { - int rc = 0; int i = 0, k = 0; - /* Wait until a signal arrives or we are woken up */ - for (;;) { - if (common->thread_wakeup_needed) - break; + /* + * Wait until a signal arrives, we are woken up, or the buffer head is + * full. + */ + while (!bh || bh->state == BUF_STATE_BUSY) { + if (exception_in_progress(common)) + return -EINTR; if (++i == 20000) { busy_indicator(); @@ -682,8 +684,7 @@ static int sleep_thread(struct fsg_common *common) usb_gadget_handle_interrupts(controller_index); } - common->thread_wakeup_needed = 0; - return rc; + return 0; } /*-------------------------------------------------------------------------*/ @@ -744,11 +745,9 @@ static int do_read(struct fsg_common *common) /* Wait for the next buffer to become available */ bh = common->next_buffhd_to_fill; - while (bh->state != BUF_STATE_EMPTY) { - rc = sleep_thread(common); - if (rc) - return rc; - } + rc = sleep_thread(common, bh); + if (rc) + return rc; /* If we were asked to read past the end of file, * end with an empty buffer. */ @@ -922,67 +921,64 @@ static int do_write(struct fsg_common *common) bh = common->next_buffhd_to_drain; if (bh->state == BUF_STATE_EMPTY && !get_some_more) break; /* We stopped early */ - if (bh->state == BUF_STATE_FULL) { - common->next_buffhd_to_drain = bh->next; - bh->state = BUF_STATE_EMPTY; - /* Did something go wrong with the transfer? */ - if (bh->outreq->status != 0) { - curlun->sense_data = SS_COMMUNICATION_FAILURE; - curlun->info_valid = 1; - break; - } + rc = sleep_thread(common, bh); + if (rc) + return rc; - amount = bh->outreq->actual; + common->next_buffhd_to_drain = bh->next; + bh->state = BUF_STATE_EMPTY; - /* Perform the write */ - rc = ums[common->lun].write_sector(&ums[common->lun], - file_offset / SECTOR_SIZE, - amount / SECTOR_SIZE, - (char __user *)bh->buf); - if (!rc) - return -EIO; - nwritten = rc * SECTOR_SIZE; + /* Did something go wrong with the transfer? */ + if (bh->outreq->status != 0) { + curlun->sense_data = SS_COMMUNICATION_FAILURE; + curlun->info_valid = 1; + break; + } - VLDBG(curlun, "file write %u @ %llu -> %d\n", amount, - (unsigned long long) file_offset, - (int) nwritten); + amount = bh->outreq->actual; - if (nwritten < 0) { - LDBG(curlun, "error in file write: %d\n", - (int) nwritten); - nwritten = 0; - } else if (nwritten < amount) { - LDBG(curlun, "partial file write: %d/%u\n", - (int) nwritten, amount); - nwritten -= (nwritten & 511); - /* Round down to a block */ - } - file_offset += nwritten; - amount_left_to_write -= nwritten; - common->residue -= nwritten; - - /* If an error occurred, report it and its position */ - if (nwritten < amount) { - printf("nwritten:%zd amount:%u\n", nwritten, - amount); - curlun->sense_data = SS_WRITE_ERROR; - curlun->info_valid = 1; - break; - } + /* Perform the write */ + rc = ums[common->lun].write_sector(&ums[common->lun], + file_offset / SECTOR_SIZE, + amount / SECTOR_SIZE, + (char __user *)bh->buf); + if (!rc) + return -EIO; + nwritten = rc * SECTOR_SIZE; - /* Did the host decide to stop early? */ - if (bh->outreq->actual != bh->outreq->length) { - common->short_packet_received = 1; - break; - } - continue; + VLDBG(curlun, "file write %u @ %llu -> %d\n", amount, + (unsigned long long) file_offset, + (int) nwritten); + + if (nwritten < 0) { + LDBG(curlun, "error in file write: %d\n", + (int) nwritten); + nwritten = 0; + } else if (nwritten < amount) { + LDBG(curlun, "partial file write: %d/%u\n", + (int) nwritten, amount); + nwritten -= (nwritten & 511); + /* Round down to a block */ } + file_offset += nwritten; + amount_left_to_write -= nwritten; + common->residue -= nwritten; - /* Wait for something to happen */ - rc = sleep_thread(common); - if (rc) - return rc; + /* If an error occurred, report it and its position */ + if (nwritten < amount) { + printf("nwritten:%zd amount:%u\n", nwritten, + amount); + curlun->sense_data = SS_WRITE_ERROR; + curlun->info_valid = 1; + break; + } + + /* Did the host decide to stop early? */ + if (bh->outreq->actual != bh->outreq->length) { + common->short_packet_received = 1; + break; + } } return -EIO; /* No default reply */ @@ -1430,13 +1426,10 @@ static int pad_with_zeros(struct fsg_dev *fsg) bh->state = BUF_STATE_EMPTY; /* For the first iteration */ fsg->common->usb_amount_left = nkeep + fsg->common->residue; while (fsg->common->usb_amount_left > 0) { - /* Wait for the next buffer to be free */ - while (bh->state != BUF_STATE_EMPTY) { - rc = sleep_thread(fsg->common); - if (rc) - return rc; - } + rc = sleep_thread(fsg->common, bh); + if (rc) + return rc; nsend = min(fsg->common->usb_amount_left, FSG_BUFLEN); memset(bh->buf + nkeep, 0, nsend - nkeep); @@ -1461,23 +1454,7 @@ static int throw_away_data(struct fsg_common *common) bh->state != BUF_STATE_EMPTY || common->usb_amount_left > 0; bh = common->next_buffhd_to_drain) { - /* Throw away the data in a filled buffer */ - if (bh->state == BUF_STATE_FULL) { - bh->state = BUF_STATE_EMPTY; - common->next_buffhd_to_drain = bh->next; - - /* A short packet or an error ends everything */ - if (bh->outreq->actual != bh->outreq->length || - bh->outreq->status != 0) { - raise_exception(common, - FSG_STATE_ABORT_BULK_OUT); - return -EINTR; - } - continue; - } - /* Try to submit another request if we need one */ - bh = common->next_buffhd_to_fill; if (bh->state == BUF_STATE_EMPTY && common->usb_amount_left > 0) { amount = min(common->usb_amount_left, FSG_BUFLEN); @@ -1494,13 +1471,24 @@ static int throw_away_data(struct fsg_common *common) return -EIO; common->next_buffhd_to_fill = bh->next; common->usb_amount_left -= amount; - continue; } - /* Otherwise wait for something to happen */ - rc = sleep_thread(common); + /* Wait for the data to be received */ + rc = sleep_thread(common, bh); if (rc) return rc; + + /* Throw away the data in a filled buffer */ + bh->state = BUF_STATE_EMPTY; + common->next_buffhd_to_drain = bh->next; + + /* A short packet or an error ends everything */ + if (bh->outreq->actual != bh->outreq->length || + bh->outreq->status != 0) { + raise_exception(common, + FSG_STATE_ABORT_BULK_OUT); + return -EINTR; + } } return 0; } @@ -1613,11 +1601,9 @@ static int send_status(struct fsg_common *common) /* Wait for the next buffer to become available */ bh = common->next_buffhd_to_fill; - while (bh->state != BUF_STATE_EMPTY) { - rc = sleep_thread(common); - if (rc) - return rc; - } + rc = sleep_thread(common, bh); + if (rc) + return rc; if (curlun) sd = curlun->sense_data; @@ -1790,11 +1776,9 @@ static int do_scsi_command(struct fsg_common *common) /* Wait for the next buffer to become available for data or status */ bh = common->next_buffhd_to_fill; common->next_buffhd_to_drain = bh; - while (bh->state != BUF_STATE_EMPTY) { - rc = sleep_thread(common); - if (rc) - return rc; - } + rc = sleep_thread(common, bh); + if (rc) + return rc; common->phase_error = 0; common->short_packet_received = 0; @@ -2118,11 +2102,9 @@ static int get_next_command(struct fsg_common *common) /* Wait for the next buffer to become available */ bh = common->next_buffhd_to_fill; - while (bh->state != BUF_STATE_EMPTY) { - rc = sleep_thread(common); - if (rc) - return rc; - } + rc = sleep_thread(common, bh); + if (rc) + return rc; /* Queue a request to read a Bulk-only CBW */ set_bulk_out_req_length(common, bh, USB_BULK_CB_WRAP_LEN); @@ -2137,11 +2119,9 @@ static int get_next_command(struct fsg_common *common) * next_buffhd_to_fill. */ /* Wait for the CBW to arrive */ - while (bh->state != BUF_STATE_FULL) { - rc = sleep_thread(common); - if (rc) - return rc; - } + rc = sleep_thread(common, bh); + if (rc) + return rc; rc = fsg_is_set(common) ? received_cbw(common->fsg, bh) : -EIO; bh->state = BUF_STATE_EMPTY; @@ -2291,6 +2271,7 @@ static void handle_exception(struct fsg_common *common) struct fsg_lun *curlun; unsigned int exception_req_tag; + common->thread_wakeup_needed = 0; /* Cancel all the pending transfers */ if (common->fsg) { for (i = 0; i < FSG_NUM_BUFFERS; ++i) { @@ -2300,18 +2281,9 @@ static void handle_exception(struct fsg_common *common) if (bh->outreq_busy) usb_ep_dequeue(common->fsg->bulk_out, bh->outreq); - } - /* Wait until everything is idle */ - for (;;) { - int num_active = 0; - for (i = 0; i < FSG_NUM_BUFFERS; ++i) { - bh = &common->buffhds[i]; - num_active += bh->inreq_busy + bh->outreq_busy; - } - if (num_active == 0) - break; - if (sleep_thread(common)) + /* Wait until the transfer is idle */ + if (sleep_thread(common, bh)) return; } @@ -2403,15 +2375,16 @@ int fsg_main_thread(void *common_) } if (!common->running) { - ret = sleep_thread(common); - if (ret) + ret = sleep_thread(common, NULL); + if (ret != -EINTR) return ret; - continue; } ret = get_next_command(common); - if (ret) + if (ret == -EINTR) + continue; + else if (ret) return ret; if (!exception_in_progress(common)) diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 5674e8fe49..723549ef09 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c @@ -318,7 +318,7 @@ static struct fsg_lun *fsg_lun_from_dev(struct device *dev) enum fsg_buffer_state { BUF_STATE_EMPTY = 0, BUF_STATE_FULL, - BUF_STATE_BUSY + BUF_STATE_BUSY, }; struct fsg_buffhd { From patchwork Thu Jul 8 17:14:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1502554 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-secospa-onmicrosoft-com header.b=Ev0cjgia; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GLNGH4yJgz9sWc for ; Fri, 9 Jul 2021 03:15:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 11312831B0; Thu, 8 Jul 2021 19:15:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.b="Ev0cjgia"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 46CA5831CF; Thu, 8 Jul 2021 19:15:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::61b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 96636831A5 for ; Thu, 8 Jul 2021 19:14:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bSpcIJ/W8L61LnxBRAy/KVEwHB/2lBqRc526HWGO+PikN6oPCSMpdKKjkPH9l8fxucBaIigeoYQul7+QJwqs+H0CVAggiF6vLbJ9kkb8iETWNbVZ6MM7Zv60N8k8DZSQWkIK8BUaAND52vJM2eH6gEcJCFi6VikljrbvWBYV2q0wCwTPO7IpIJzqSW5vU7obYBtTb5ph2BSPw8bpYrDCHFI4jtMEtxHcEQ5YdctYO3B6wVFjkm0OSajHwFxCcqV5ToLzOgt9+pZ3ZTThmGDwUcx33N2nX2fDZFLevnYsLEK7f+O4K2cjciJHme9uGmctiAf0TmWgYFwFFUGTYXP7OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ely/JqOFD0JM7iQy0w5S1NNCYfzlsJg1xUrlp7PKgYw=; b=VYVej0kapGWE6LmPS0wxO5P15I2DsZ+myAY1pBxLOxl3I8ybMQQMaX/S4/+Yj8DqnFcNu3SfnWFL7UeXHHNS3u44wyZGiu2qBPgxOAAXe8eDkkIYjW5abubERrdGl6jb1nboafIW4WLGkN7n5fNXu8embB/hWKXnVTkMxPnKZdGr8EQDyW1y77rX0cHWCKXxPvSjrFr1wNLKH2pL4w4Nu6pXA1jwwKmjNHno4xxfCJaiMRcvKOr/lUwtaS+ce+k+shDpFrovqfH/XDnuB+tMPib6p6p1S0rtDB8fIF3xX6PCm/CYbSqtK8R3fHlQmeruUcZH1MIK/6jOg7QZLRHQ1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ely/JqOFD0JM7iQy0w5S1NNCYfzlsJg1xUrlp7PKgYw=; b=Ev0cjgiao2CBE6dB8HEp8kiyG+zL5M3GRHbgUw99rMC5ZqBCScj0fBVVZFHT0TsxCPDbZHNYg0wU8OYBNvKNCXXv3hyZKY9nQFCoQl65BBS9chluZQ1OzWe897mRnteOQ5+GIDoKuRAhmzC1yHQUKKJp7CWVamnItvJLYbkwH2o= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DBBPR03MB6762.eurprd03.prod.outlook.com (2603:10a6:10:20b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Thu, 8 Jul 2021 17:14:58 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b%5]) with mapi id 15.20.4264.035; Thu, 8 Jul 2021 17:14:58 +0000 From: Sean Anderson To: u-boot@lists.denx.de, Lukasz Majewski Cc: Maxime Ripard , Jun Li , Andre Przywara , Jagan Teki , Marek Vasut , Marek Szyprowski , Ye Li , Peng Fan , Bryan O'Donoghue , Sean Anderson Subject: [PATCH 3/4] usb: f_mass_storage: Drop wakeup_needed Date: Thu, 8 Jul 2021 13:14:22 -0400 Message-Id: <20210708171424.970928-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708171424.970928-1-sean.anderson@seco.com> References: <20210708171424.970928-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.12 via Frontend Transport; Thu, 8 Jul 2021 17:14:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01f54367-091f-487b-7dca-08d94233e9f8 X-MS-TrafficTypeDiagnostic: DBBPR03MB6762: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8GqkGCxGTc23Kmigpu33iySBPG/zGRruK+jmY7zahCCvZzdzywoJomKK3WJfoLGg4Q+qSBktB7MaZw/sqxIvzXLXw1QczOBNLoJLeRB6ICJ5CBUDkpLapkgueyCX+sZDhXr9q4vBGT8m/YNg/aRVU/tG+69g7q6UknYJ9Z6O8TAwOogqGvlQvsenr8mFKQMxwPIrGwSrEbFUeHhUG7ZkD9dccvXBr697iozhknREho2iF0WdJtA+78xW4CxRScfMBCYeuRsK+JhBZJ5hfex+Uf1lpYFrC2wUE3vzzn5axkTE6urTgdyb0Z2XmRyMyiu5VTwCezb9UHdsf4gPnTfwg8AIaIoTQrYP1tJOn1Xi/FoXDSuo1DPud6LSLlHUOXTBkiUa4oVadepWpOp/E19XnuAyZRGYWBYryPY9lecZRK6ffIyF5BwT1ibtzsn90j1obfBeO55l5LmbI9M4VvnvMo6briMIw/YCMO2zJ42uZTCxeqC969NFHa11g+Dvl3rR/6JAoIiucWYxsRoAfkX6vJ+haOWZdqbuO3AybP80e2lWkH1iuPplaQrug+LsumA6q2qNEf3uoMmNp9T7/GHm4v/nODBWlDLcwvNcrvVl32tiTq9Iiba8ot3WfDpmpfVrGNk5X6tQbQGvT5+Pk6yunY1lmRz2neupnm+gYi9C9slejlSyAzzxeIwWMATlG36bcVfr0S94HEJLw1fbNOwLxg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(366004)(376002)(346002)(396003)(39840400004)(52116002)(54906003)(478600001)(316002)(6506007)(6666004)(38350700002)(38100700002)(2906002)(8676002)(4326008)(36756003)(6486002)(8936002)(83380400001)(66946007)(66476007)(66556008)(86362001)(44832011)(1076003)(186003)(7416002)(6512007)(2616005)(107886003)(956004)(26005)(6916009)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BuJsY1t3g/OfFrmMLQKl4Q4ksA+6zEfxAkL8CYEkzIO1ivlCRmxJ5KUdGQw0l5ffzSmFhoKD47KwH+Rv0iC6sSnilIvA7N3/oK+WqKzIfvJe6qwAPi0zLoFGNYGiXZC5Ydh1NJIrlfxRi+ikvHYkdN2LEj6OA8lEMlaacBSCBUJ0vU8birHQv6ve9MKr7Qh4V6+Irn28R42C+t+26aVMp3LLNXj5gdP7PcLwL4CH9nndsU/i6Wfn5WNq1dOy5/2/jXR2WItpBJDIYpmCcyHAK4jWwmdHlJIE3ZcWOXacYVdYg+kr3XHuweKjqy5CJEg6VXNfl/P7x4rLGoLaqpXkWeRtHTnJzz563ZPUb0+Y58uSC419+0YQ8R7TJvc5zZ5WcYAhj3YBDK+gfCkcBr7Ruz38tsCugmaJuWJwgFKibEtJhFKsYPhWlRmJ4+gEkhDgRT2yPaK1hZPxH+iFZ/wBQvEVR0GKm3myvk5/xq0y//2b7S+1jQOTGyBbyhjPDFtZHQY4lRe3MSiAcxdEDehesXxEW9FOWiuNyTgEY2meRZRKtbvZ2hXA0sfOMns8QqgpSpP13HJYsqrrERumDYS0kDzDQUR09BMg1X0djJT7va6d2TuFSk3GiXIPjbms5/QF9j9mHnDevREBQZiEyD7fUSRn0aBCw01qL4k5qsAEkb1iGJ92IA8v38GkIPynrljZcuTtP5BLrXOzRnSbJ9SVMUpJxrj2X2qMOsnR0WSWUWDpN5X6pU/4btz8BnaMA5YsAbi3n0eJzWnCl8ZAdmQe3mgfcoaReZ7krWf4ABxSytpzoudtkJdcXqrykW/1Y9OKWETAITKAPHOyxGaMgWU7Txf5BBsO/qVw1bvsNBabCDX87Za/0CrNIaNdVlc1hKihmImvoeQJNuQg1H+3S78Th4dLpfSF4tLgWSz+e3HPR2No2bLOOWt7AjDayXYlsNGw9g1WBHN68P14CWZZkc8U8Pc3yOtOE9awF1VZeRfE4TnkKhkn2DJyn+T1qS3Is6lI1RxmgU2VNVgvzTIEahxjCcItjOH7GkGZY9kVR+r7tUm2dvAz0Hnv3GZcXfV1vI1MIZFFyek8zNUYbu+iTS7Ag+POGFngbHeRejkRJE25AdiMZZKwkTAjJg98zjevhf5XzYOZ3xkMbeEdwojD9HALXXIgYEiBZtgJXD5mo9U3k8DNXjpKQEBXUe0b4I4mFXOUkKj7J/uhgJYWiGD3NUzWAMl78mzt2ANX1QrrCs1GNGySrAhPD5p0JRa3gLm5L2OUeqChcRfGqH2XKqtrPdgPuJuFo9sxiCBTgLwsMah9YeIbSwsG1J0UiI6PfiB9kize X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01f54367-091f-487b-7dca-08d94233e9f8 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2021 17:14:58.7226 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T6Jye2Rj3hoBUoAac6vdA8MKeOxcNlX7kk0MQf26Lu5eoFDVI6+ifHybi1+quX9G5vOMJhDSUyLK+LhAY42JuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB6762 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Now that we check bh->state in sleep_thread, there is no need to have a separate wakeup_needed flag. Drop it. Signed-off-by: Sean Anderson --- drivers/usb/gadget/f_mass_storage.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 99935fe9a3..190053590f 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -328,7 +328,6 @@ struct fsg_common { unsigned int bad_lun_okay:1; unsigned int running:1; - int thread_wakeup_needed; struct completion thread_notifier; struct task_struct *thread_task; @@ -455,12 +454,6 @@ static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep) /* These routines may be called in process context or in_irq */ -/* Caller must hold fsg->lock */ -static void wakeup_thread(struct fsg_common *common) -{ - common->thread_wakeup_needed = 1; -} - static void raise_exception(struct fsg_common *common, enum fsg_state new_state) { /* Do nothing if a higher-priority exception is already in progress. @@ -469,7 +462,6 @@ static void raise_exception(struct fsg_common *common, enum fsg_state new_state) if (common->state <= new_state) { common->exception_req_tag = common->ep0_req_tag; common->state = new_state; - common->thread_wakeup_needed = 1; } } @@ -508,7 +500,6 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req) /* Hold the lock while we update the request and buffer states */ bh->inreq_busy = 0; bh->state = BUF_STATE_EMPTY; - wakeup_thread(common); } static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) @@ -527,7 +518,6 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) /* Hold the lock while we update the request and buffer states */ bh->outreq_busy = 0; bh->state = BUF_STATE_FULL; - wakeup_thread(common); } /*-------------------------------------------------------------------------*/ @@ -2271,7 +2261,6 @@ static void handle_exception(struct fsg_common *common) struct fsg_lun *curlun; unsigned int exception_req_tag; - common->thread_wakeup_needed = 0; /* Cancel all the pending transfers */ if (common->fsg) { for (i = 0; i < FSG_NUM_BUFFERS; ++i) { From patchwork Thu Jul 8 17:14:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1502556 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-secospa-onmicrosoft-com header.b=c4ssEjbM; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GLNGh3mW5z9sWc for ; Fri, 9 Jul 2021 03:15:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 540DA831DA; Thu, 8 Jul 2021 19:15:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.b="c4ssEjbM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0937E831B8; Thu, 8 Jul 2021 19:15:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::603]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A1BE3831B8 for ; Thu, 8 Jul 2021 19:15:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UZmHMULatfpx9gnBCYMhkMKIpf8/WHa6ZCthJvdVaq0tjG/dq3sNi8+q1IoM+At+6L8yS1ndnPuHruOaUAx3Q+ZN2O5smMUey873f/LIL5bA8NXuRe2mOmLlttkRMxfCDSbM8MyzunJF2KjA8JPDigMNNwLH1ta8IUYmACYKaUhPRB+J7tgAlvCnpIXEzeW4KHJq+Mo61r9qUYgJbdwTLgJf+0ZVzteSLbjPvdF57zxU8w2EhgvhIb6T4kh4MHP7fJKdG0hr7VUE4Zfx9UmBSQzJF//MEdM1BRfIw9ozkAucg9kC1ycF6fNlqVo6inPZ55Vq89+vHaUf1EGqDqvKnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e0Upe43rJpWwG/qlRE0nG1AeDC+dbNDa2vChmBKHs/o=; b=BuLLwjXKYD17rcj1f6Ao0U6eWJmt2IKXdQuuOCRpFAeZof+R+Gg7cvAnSAAsG3aEVZKigJHbkKbgnFA2yY6aikYjG4HY7KiA8dMTtyaEgJFdw+l2iz9ku6bB7k+RvoUw/blQfymUMx2bbFPr9Z1X9TG+nLnDyQekBj9VkgfRwoL01MHPW4WUZ22jfNfyv5vsjv9HPBT7I3stCRSFVns1e1HHYwjbA3CuVQzBUDlSaWTNEUrhbKVoO+kePDkYZe4W99r8f3mrfXFMbDdgCkQanlKAXQ1p16m78Iq1lw95QCdHJt57Waa53tsndQQD9ktOaJlUV/B8KamI4UUmZcsszA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e0Upe43rJpWwG/qlRE0nG1AeDC+dbNDa2vChmBKHs/o=; b=c4ssEjbMLLtbN2y+kiedIpejuxFUqA6e+Xz9C6gVpbybFMSo7mjd4pZCYa+y+YDyPkq77g3d7E+3ZMOLF5YN8O2o8F4I85DsXOA5BdfGWZ1V0MThqCKqaQJf94Z/i1i+e/1wSSeoISBxvYmCz4ytzvuzmZky3Son2cMKSmjlXlU= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DBBPR03MB6762.eurprd03.prod.outlook.com (2603:10a6:10:20b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Thu, 8 Jul 2021 17:15:00 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b%5]) with mapi id 15.20.4264.035; Thu, 8 Jul 2021 17:15:00 +0000 From: Sean Anderson To: u-boot@lists.denx.de, Lukasz Majewski Cc: Maxime Ripard , Jun Li , Andre Przywara , Jagan Teki , Marek Vasut , Marek Szyprowski , Ye Li , Peng Fan , Bryan O'Donoghue , Sean Anderson Subject: [PATCH 4/4] usb: f_mass_storage: Stop after the host deconfigures us Date: Thu, 8 Jul 2021 13:14:23 -0400 Message-Id: <20210708171424.970928-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708171424.970928-1-sean.anderson@seco.com> References: <20210708171424.970928-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.12 via Frontend Transport; Thu, 8 Jul 2021 17:14:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3ca9415-886f-4506-9a66-08d94233eb0d X-MS-TrafficTypeDiagnostic: DBBPR03MB6762: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W2cFa6xp+nJYVybqCa9f4jstfsyvmmd3X9EBzm1RjdgHuoBhUm2rmWHRnZmSPFJT8eVpL0+eUvskI6OdEI/VAsC3TfcTIEv6MA0Ux8riMJq4GSjd2MNqyGzkIv7vZ0GUp04L084KhPSEKI0tTSgSJzxsbVe3xFYDGuzWvk1Hds+QO8vu3Z1/w5Un35EMhfNBd8NMEnsoEuNVbQulGleXlReVb5xYfZS7BDvvyuWd4ScEubSUUcQcV58HVvVW32JnYSzRcyBqgWDWdJ9CMLeOKcZAzoSH9Rb15Elgm4Q+Qd46JucU/el6Lqz+TSLmFogk/HYX2FNIxyLBy4vivPElGH5qTofawcQPEsPJzVwdHmEjGNJED2x7evz/CTRJKXpyneTMJk68mH81nuD5MZG+/Y9RSPKX8Y3HBok2gDtzo4XgYFglOly/eZ4yD+M1Zp1tjB4K9GJ5jyCQGcUc4Lmf/Cy3b3zI4mmSqAr04gBXN58rS3Kf2Mlxg4prGZtrDUJI7qgnruBgzde3VKYQ860TQ8XhauvMY60WcFz8eFHRAFK9D/T9Ir4c+J6fWxEcPVg6gor/5xu4pMRcCW1lwTZbGyVRQ+nILuVzl8d3tXiWgSVhRVxn2LAMqxy/1yVJ7mlgFPBwPIBExB0LNiOtxdXn/oQrgoMWxVMg9sIIw8D0ByV6Ak4Y2SkjPGRGjnTpdJreeFlL+x9Dokv71UDQqgALiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(366004)(376002)(346002)(396003)(39840400004)(52116002)(54906003)(478600001)(316002)(6506007)(6666004)(38350700002)(38100700002)(2906002)(8676002)(4326008)(36756003)(6486002)(8936002)(83380400001)(66946007)(66476007)(66556008)(86362001)(44832011)(1076003)(186003)(7416002)(6512007)(2616005)(107886003)(956004)(26005)(6916009)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e9WVr1rxGuzMaFgnCVUc/74FMUBSbef5Ly1pKR4v5ZsPBLZWG/U4a3ljrhZ5qS2JGy1RXauH5rCCWxiF7SBhosIzpWvhtVmwP1GjxFAV3n0wzHk6BFNSEIuf2DmbWlK+CFJ2IHxeayMusJcz+KasLoJdlaS+dIAFaAbGCTljmWTK7XE09Ph0wv6hYncuhc+PleN1Fca6zQ177krhZyOfkssVLpVl80rVuIdVpW2Ai2DGQvATl/p1CejJ7TSO9rkPxVWknDFW/0gyx5ywMe6L1DVDcD5b0PKECy51+HSRoGkmNUvkeCMG/sOuHYnGK1PB72sY7oqshNa2Bi4DPrBTD/Ond3dMhpwXcxoEWuwcbaJYlZj/cvljT1xPsSaIHROFcIcpohAtG+08WBksZH9UU+4E3bBt2tXGZCdvYTFjNUYDKkPxO/lMr+18V7a4f6e+TGCWIDfsN+ndTaIvSNWCOUOrMmnBJ5DA2yHHR7lKvvyYGePM4DtvKB4TemRCtpcA6lnr816k9r55oHmVHzv3g8WwudZaarPGJdKWXOky8V6CAiEYLLTTxqZN1rnvuxoXmP4RXgnfx8MxQnSJFdoVYtZ5Mbwc+JW4/gIxLT3FaMoYjk32TIypBis9196GYIn4xR6ilym52Ln+3RSeL7c39wnSHkZqCrE63DVMPTSscEeT7AxO40Q9cWYY8uqRxraOiV1yE9DhBDx4Ru9ygr8aKB7E/bOopjWoG8eXqgmm6rSzlpJJ6UbguYhs5SBLmE53Ro1kGGNkpNJZJ+S7VoXL2brv0QdtaFKBRxdvkNPUw7ExXFWGuG+kZycvL/LlWNzwWh+6Ia6TxyFPbQtQZM8eujTsHjs2k2A8tqxDPnRZejjb84cVK0AWux95IEjbnvCPR3HWfN/gc3/hWoJVKmHTp7S2dQMHEinuetWW4PaohoyyPS1/WT0Cb5c3NW+LTJ3LuKFnXdHZIRoz/yiFMFI6WZJDGSVCJSOZcGpc5BRDogG/itCYFAo7IwKC0UwawLMcQnYfXPcL3mRET18PgNRtAv9W5M05Y25lwO6VrrxUCWiZpDgXjoBnQtwup/Pcle/fdYy+dcExTvYnwOGhuo1lvTIXV3KkgS6hpMzcumWnJ98OB+kSqQAPrxa/FrPnfCpInNtp6K+gUSAs7Xb2C+it3m8uTzzPd5ddiImokfYBK/msDOaYgqQjvpm1HwGcgDRIhHF4llWk+twhlrcte9qd2h6bdF2D3idA/rxtESJnhEmKOvlQQc/q06g6uyezTHkoofCj+T3yV1Zs53BLc6lgtJVKf7GT5MV0EKbgLIiFICaexox5oaFqWdgImyXoX5yc X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3ca9415-886f-4506-9a66-08d94233eb0d X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2021 17:15:00.4937 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Jdy7fXJ50EWF7My9MfJ3sBWhFBYM5Ym8BBQrY9/SwsnrwETN//0TPl+5/jUHIOPVegc/83QIHKDeoiEVNmKP/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB6762 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean At the moment there is no way to signal to U-Boot from the host that we are done reading/writing data. This stops the gadget after the host deconfigures us by selecting config 0. In theory, the host could later select this configuration again, but this rarely happens. On Linux this may be accomplished by running udisksctl power-off -b /dev/sdX Signed-off-by: Sean Anderson --- cmd/usb_mass_storage.c | 3 +++ drivers/usb/gadget/f_mass_storage.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c index d4e619b842..bac4ad87b9 100644 --- a/cmd/usb_mass_storage.c +++ b/cmd/usb_mass_storage.c @@ -227,6 +227,9 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag, if (rc == -EPIPE) printf("\rCTRL+C - Operation aborted\n"); + if (rc == -ENOLINK) + printf("\rHost closed connection\n"); + rc = CMD_RET_SUCCESS; goto cleanup_register; } diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 190053590f..5968146b1c 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2248,7 +2248,10 @@ static void fsg_disable(struct usb_function *f) { struct fsg_dev *fsg = fsg_from_func(f); fsg->common->new_fsg = NULL; - raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); + if (fsg->common->running) + raise_exception(fsg->common, FSG_STATE_EXIT); + else + raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); } /*-------------------------------------------------------------------------*/ @@ -2394,6 +2397,8 @@ int fsg_main_thread(void *common_) common->thread_task = NULL; + if (common->state == FSG_STATE_TERMINATED) + return -ENOLINK; return 0; }