Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3014611rwb; Mon, 15 Aug 2022 16:10:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR51lcaDsvXSqAkh9Hz46prZ2/E7ATyWZmRATVHbPb83rM4tl1eyJUs1Vstck5dROBsTHyms X-Received: by 2002:a05:6402:2816:b0:434:ed38:16f3 with SMTP id h22-20020a056402281600b00434ed3816f3mr16366263ede.116.1660605037139; Mon, 15 Aug 2022 16:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605037; cv=none; d=google.com; s=arc-20160816; b=o9pPlHBy5QvdojqOboF+7sI8JwbppGSOx8ka8Ij30InJs31TDxC/hz+antavxQmmGf G4rclxUiQcKeXd5NFjkPIo62aQAafnEl8sDAZvI1hfq/Z6EJone8vIlEGywT5UvRzZWG L33Z4se2A7N81psNb6DaZFUsGSjjYbO71XzixNhI1fRGzPv5IL8TRV6iLVO4XoQtPATS a9fDJ/pYuXgYecznnQsazlPxp5lqOhNB5nquQN4o11FL/SvHr44lbSQM7YjDR1g2FuHF rH84B10lHmRvGbJPZOw4RoeYkpLuxbrDERRnqclafmr05Aw586S7xLz6/az5b+Ca74dv fthQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uJpgDo7Xtymt7EFQRcLDjdEc022zVedrr2JcpZLcmMc=; b=Pw5+6fdOfgprUljOsJ0r2yrrW9WUeEwGxMApt9FF6kkfJilHiqQcK6krxzxWzICzwp XsnAUhuqlXZEX4/7lwRiOgEP1r6JL6Iv3U3ewMtRfMg1YvT2h00s5oxitnvA4RMfN685 HLB3vNLY0wtCV4W/G7JbHVWUxIvPlqZpH6yhtOdv6M/kwlXCm6LQ9h/HY4S1ZbBecXUB ZPIgZ/FIyrCxjGtSyzAFY5OAM9+bYuAOzCBo0nxNh/AjKS4dyQav7Io4zlmnsEccAh99 Y5djQtYcBcFOs8nddmxk550ny6l9GHurVF4qTxoGhqY3GSyvN1ZnRJvCp5BFesJQqazH e6vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Kv6aiWSx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a056402349200b0043d0b64b70asi9580080edc.43.2022.08.15.16.10.12; Mon, 15 Aug 2022 16:10:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Kv6aiWSx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350061AbiHOVwL (ORCPT + 99 others); Mon, 15 Aug 2022 17:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350257AbiHOVrc (ORCPT ); Mon, 15 Aug 2022 17:47:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFB875FAD0; Mon, 15 Aug 2022 12:31:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6DB68B81125; Mon, 15 Aug 2022 19:31:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98BC0C433C1; Mon, 15 Aug 2022 19:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591886; bh=8xVoADYwIv4LNKJ9F7p8sP2HeEkSfNtj+oTvGTxCvuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kv6aiWSxGJ9RKEg0+EpWhF7HNZNZXcTNkQYH9pdX8scKioL3qCXyLhWmCeaFEPi/4 vN78iUEE6uI32yrralX6PNAUrR21jaX+F5BYo+0QbdofvnbK9Yi+X1cGIItx48cq1m 300yNkG/c53ouISPSnaHCGWxZjq8QX45haY1NaN8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Neal Liu , Sasha Levin Subject: [PATCH 5.18 0699/1095] usb: gadget: f_mass_storage: Make CD-ROM emulation works with Windows OS Date: Mon, 15 Aug 2022 20:01:38 +0200 Message-Id: <20220815180458.306057483@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Neal Liu [ Upstream commit 3b91edd624ab1ab694deef513a45eb9e9d49d75f ] Add read TOC with format 1 to support CD-ROM emulation with Windows OS. This patch is tested on Windows OS Server 2019. Fixes: 89ada0fe669a ("usb: gadget: f_mass_storage: Make CD-ROM emulation work with Mac OS-X") Reviewed-by: Alan Stern Signed-off-by: Neal Liu Link: https://lore.kernel.org/r/20220628021436.3252262-1-neal_liu@aspeedtech.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/f_mass_storage.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 3a77bca0ebe1..e884f295504f 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -1192,13 +1192,14 @@ static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) u8 format; int i, len; + format = common->cmnd[2] & 0xf; + if ((common->cmnd[1] & ~0x02) != 0 || /* Mask away MSF */ - start_track > 1) { + (start_track > 1 && format != 0x1)) { curlun->sense_data = SS_INVALID_FIELD_IN_CDB; return -EINVAL; } - format = common->cmnd[2] & 0xf; /* * Check if CDB is old style SFF-8020i * i.e. format is in 2 MSBs of byte 9 @@ -1208,8 +1209,8 @@ static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) format = (common->cmnd[9] >> 6) & 0x3; switch (format) { - case 0: - /* Formatted TOC */ + case 0: /* Formatted TOC */ + case 1: /* Multi-session info */ len = 4 + 2*8; /* 4 byte header + 2 descriptors */ memset(buf, 0, len); buf[1] = len - 2; /* TOC Length excludes length field */ @@ -1250,7 +1251,7 @@ static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) return len; default: - /* Multi-session, PMA, ATIP, CD-TEXT not supported/required */ + /* PMA, ATIP, CD-TEXT not supported/required */ curlun->sense_data = SS_INVALID_FIELD_IN_CDB; return -EINVAL; } -- 2.35.1