Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp933522pxb; Mon, 25 Oct 2021 22:52:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf8DeXV2j2sjQMh/iucqoLBUdlm12Ec9t6kCUVtFGbdWdn5XUfQkBuzVaZxKP9R9vlvO8b X-Received: by 2002:a17:90b:3b8a:: with SMTP id pc10mr38746274pjb.245.1635227520816; Mon, 25 Oct 2021 22:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635227520; cv=none; d=google.com; s=arc-20160816; b=Kp8hCpZ3YOPXmGCOImuB7ai9VR62QISsG0RuxAHV2Up0hLsBOilDZnbVcodyZGGQOV DYuVRwsfjpst/USjzBcWGDYopNjH+zLMjJQ8Frs6/yAWQNlCY+QIlNCvOQ97zfumYQKz mDFpXw8FYVc4wR7O8k4AmkxXCaW0GFOpuRUoKIZ9W7FqLkEpnI2J7TU56dx1/MoMwqkF rMzAo3dR5t/AooaVBtERMDL8cVh04unDdk9QW7XvCOWMLhQayPb7y5L9lSmFB+JzSnji +QNPZICgWLUCqBRiLxrF/sOLSNTlYIIJWDnzYZADS0n3aTnIpkB14hBrQwx223trCLjq +J+w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=5znon4iCho05Hu+qdNP4H8pF1rkGlP/vfvPo8Af0PG8=; b=BL7EMle1UElCF3tO92Or2swGQPOCQd6icseNd+rF/k9We7Tk8oPa6ugZQxCxBDTW6A J6k/EppHCrgvPxJlPPclEKur8uOzaaaCiTnM3h/AIVgigu4EG2q/TTaaiJd8jmAIzkYV N8mS7n8CMGp5WrT+XG7+jIDlOmH/htcvC42/0wbDfK447voPE8Lk0lf6dFDi/1iKPLaE 0LX3AEz/E+BgxQl4AgQut/MV9ezselEqRw21Z8Ysj4fZnCUKPKXZfJxDJYUBboCMTREx Q6gNGd+aOKx4C8hkFU4loyLHWB0UWY9pWCTLz3qVtO3fSwMSTdaOo6kl6wfGPcN+9VKR kkkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=vlFlKkEn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me16si4534671pjb.74.2021.10.25.22.51.47; Mon, 25 Oct 2021 22:52:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=vlFlKkEn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235848AbhJZAto (ORCPT + 99 others); Mon, 25 Oct 2021 20:49:44 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:14972 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235810AbhJZAtn (ORCPT ); Mon, 25 Oct 2021 20:49:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1635209240; x=1666745240; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5znon4iCho05Hu+qdNP4H8pF1rkGlP/vfvPo8Af0PG8=; b=vlFlKkEn7rxqiS+mBZ+aerxYFyWS+AfpHd9n3CxXmpxJU9NbXyDwW9W+ RtaBggBK7omZuhYZFny3ZIYXpFST4+eLXjoqoltoN/jkfu1IffTfL+oJf JiAuez0EI5rJTMYKd6pWy5CgKmYZoHjNSjcm86GwVb/HkJeD6h0anjkWj s=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 25 Oct 2021 17:47:19 -0700 X-QCInternal: smtphost Received: from nalasex01b.na.qualcomm.com ([10.47.209.197]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2021 17:47:19 -0700 Received: from wcheng-linux.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Mon, 25 Oct 2021 17:47:19 -0700 From: Wesley Cheng To: , CC: , , Wesley Cheng Subject: [PATCH] usb: gadget: f_mass_storage: Disable eps during disconnect Date: Mon, 25 Oct 2021 17:44:56 -0700 Message-ID: <20211026004456.23054-1-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wesley Cheng When receiving a disconnect event from the UDC, the mass storage function driver currently runs the handle_exception() routine asynchronously. For UDCs that support runtime PM, there is a possibility the UDC is already suspended by the time the do_set_interface() is executed. This can lead to HW register access while the UDC is already suspended. Signed-off-by: Wesley Cheng --- drivers/usb/gadget/function/f_mass_storage.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 3cabf7692ee1..752439690fda 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -2342,6 +2342,16 @@ static void fsg_disable(struct usb_function *f) { struct fsg_dev *fsg = fsg_from_func(f); + /* Disable the endpoints */ + if (fsg->bulk_in_enabled) { + usb_ep_disable(fsg->bulk_in); + fsg->bulk_in_enabled = 0; + } + if (fsg->bulk_out_enabled) { + usb_ep_disable(fsg->bulk_out); + fsg->bulk_out_enabled = 0; + } + __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, NULL); } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project