From patchwork Wed Mar 31 04:58:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 12174333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E56CC433DB for ; Wed, 31 Mar 2021 05:00:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97B3A61998 for ; Wed, 31 Mar 2021 05:00:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97B3A61998 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=IZ3syErxkiovrLhtO56EXJnc1vco1cU5cQfiSQ0xcDk=; b=m5x9yda6tQpvpmNuDsOmH2hjFF OthJF1eQ0BVv/AMVl7P4U2oDtCbCD1x9byehcL1douKmpqB203D4le1L9Q4bi/zVnLfXz5i9Cwn0g cMaIRBSn4bG5Lw2yAeuAm9X9xLA8VCu5CBZufNbb541ocGM8hVi0vYXxpO/jYMYYnF3eVaZ+mKyXt VUFxSWWdxZZGXHqrl7VWfXLNZYw0Yev7ZMzsMCdf3DfF1QOG4fxTqvw8dGHpLVM8zTV2R+EmXFrvL QwSMf1wZiE4pNTDhpmOj1iPsmFkfwJ7ZLCeSz4Q0S1gOfcOFNbzr9medlZoJTAqa8ChtlP97kMWbc VrQb9GgQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRSwN-005VWh-94; Wed, 31 Mar 2021 04:58:51 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lRSwI-005VUD-QD for linux-arm-kernel@lists.infradead.org; Wed, 31 Mar 2021 04:58:48 +0000 Received: by mail-pj1-x102c.google.com with SMTP id il9-20020a17090b1649b0290114bcb0d6c2so570722pjb.0 for ; Tue, 30 Mar 2021 21:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=M9IEZCF3Kb5rzDpus85iH1dAL2w2ZrIdfYygwHVDvMs=; b=QOx+xP0OZ9SwBGZAcMXCuioMLzdjTff51PtRLVQmxuiKezcDEiMqpJNi0HnkZQmHNx 4CX6FTDHqn0bNK3YpNvch7/LCc5iekuFtAiyJ1ZCDw29+RCFssk777mEBiO7JKMSTqe7 FWmZfiLQC1Tb/Fk03vbxBZeUOmV6PwErF//XkcSl/RTjdjN7d2JWXP3F/xZBakHuvir+ 2HfVjTCQVYGFTCZIdG+s+0kBGsY6BLTwjmV1RTciFZSNbSq1k6u5I0Eqy3pIU2lj/aK1 +j1GEYDcGl1oqj26f/FcqQv/1SwPJYKQhLmWdJS33+5pLbf3SRSlXRWCtoBPBNQjWsX/ VWnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=M9IEZCF3Kb5rzDpus85iH1dAL2w2ZrIdfYygwHVDvMs=; b=Kv4a7nO7HyIJf+oemg8pScvS/NX362tC0m+CQiF95d3+X9ST1ZUHICsa2oDXAUn1TZ 6a9wzC9uAssUIn/wZLCbW7p4/m9cSsFfeeeHSIFXlzrvPtP6TO/rpDd+okmxNw3k5Ld5 cURQFf0izm2zL6RdhERRZU4RjB/nU+Eqzm7rfKZhzrNX7C248EVDcCbajx9AtcBoslyj hX2hOX02w9LUbQza/vGAthH6nvVhfl4EbC1VIpnARDU8xy5h11qHQWO7sM2psyUX5l+U I5PpFJFsm1O9UiWblpE+X1eyHSBpUdL1mV6NP3dZB3dBP1oDpi3oHJjwSp6sV4dxbcWL 9Bfw== X-Gm-Message-State: AOAM532JNYD1bEgyo/SvssRIj04L9bMdtT16XPEsiP5AEcBBEaxoxkYj LWQL73LGV/GXoUv8h+KcG4M= X-Google-Smtp-Source: ABdhPJxCQskMGUM7pUf8tLPCPJKZG1Bkr8uITpKSbc8zP5PBHshTADmqpzQJd1Y+m/V/iFE4MN9CAw== X-Received: by 2002:a17:90a:db51:: with SMTP id u17mr1695746pjx.194.1617166725244; Tue, 30 Mar 2021 21:58:45 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-73-252-146-110.hsd1.ca.comcast.net. [73.252.146.110]) by smtp.gmail.com with ESMTPSA id a70sm587054pfa.202.2021.03.30.21.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 21:58:44 -0700 (PDT) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , kernel test robot , Masahiro Yamada , Sasha Levin , Julia Lawall , Ryan Chen , Thomas Tai , Konrad Rzeszutek Wilk , Christoph Hellwig , Benjamin Herrenschmidt , Robin Murphy , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Tao Ren Cc: Tao Ren Subject: [PATCH] usb: gadget: aspeed: fix dma map failure Date: Tue, 30 Mar 2021 21:58:31 -0700 Message-Id: <20210331045831.28700-1-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210331_055847_107235_21156FC4 X-CRM114-Status: GOOD ( 15.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tao Ren Currently the virtual port_dev device is passed to DMA API, and this is wrong because the device passed to DMA API calls must be the actual hardware device performing the DMA. The patch replaces usb_gadget_map_request/usb_gadget_unmap_request APIs with usb_gadget_map_request_by_dev/usb_gadget_unmap_request_by_dev APIs so the DMA capable platform device can be passed to the DMA APIs. The patch fixes below backtrace detected on Facebook AST2500 OpenBMC platforms: [<80106550>] show_stack+0x20/0x24 [<80106868>] dump_stack+0x28/0x30 [<80823540>] __warn+0xfc/0x110 [<8011ac30>] warn_slowpath_fmt+0xb0/0xc0 [<8011ad44>] dma_map_page_attrs+0x24c/0x314 [<8016a27c>] usb_gadget_map_request_by_dev+0x100/0x1e4 [<805cedd8>] usb_gadget_map_request+0x1c/0x20 [<805cefbc>] ast_vhub_epn_queue+0xa0/0x1d8 [<7f02f710>] usb_ep_queue+0x48/0xc4 [<805cd3e8>] ecm_do_notify+0xf8/0x248 [<7f145920>] ecm_set_alt+0xc8/0x1d0 [<7f145c34>] composite_setup+0x680/0x1d30 [<7f00deb8>] ast_vhub_ep0_handle_setup+0xa4/0x1bc [<7f02ee94>] ast_vhub_dev_irq+0x58/0x84 [<7f0309e0>] ast_vhub_irq+0xb0/0x1c8 [<7f02e118>] __handle_irq_event_percpu+0x50/0x19c [<8015e5bc>] handle_irq_event_percpu+0x38/0x8c [<8015e758>] handle_irq_event+0x38/0x4c Signed-off-by: Tao Ren Reviewed-by: Joel Stanley --- drivers/usb/gadget/udc/aspeed-vhub/core.c | 3 ++- drivers/usb/gadget/udc/aspeed-vhub/epn.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/gadget/udc/aspeed-vhub/core.c index be7bb64e3594..d11d3d14313f 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/core.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c @@ -36,6 +36,7 @@ void ast_vhub_done(struct ast_vhub_ep *ep, struct ast_vhub_req *req, int status) { bool internal = req->internal; + struct ast_vhub *vhub = ep->vhub; EPVDBG(ep, "completing request @%p, status %d\n", req, status); @@ -46,7 +47,7 @@ void ast_vhub_done(struct ast_vhub_ep *ep, struct ast_vhub_req *req, if (req->req.dma) { if (!WARN_ON(!ep->dev)) - usb_gadget_unmap_request(&ep->dev->gadget, + usb_gadget_unmap_request_by_dev(&vhub->pdev->dev, &req->req, ep->epn.is_in); req->req.dma = 0; } diff --git a/drivers/usb/gadget/udc/aspeed-vhub/epn.c b/drivers/usb/gadget/udc/aspeed-vhub/epn.c index 02d8bfae58fb..cb164c615e6f 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/epn.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/epn.c @@ -376,7 +376,7 @@ static int ast_vhub_epn_queue(struct usb_ep* u_ep, struct usb_request *u_req, if (ep->epn.desc_mode || ((((unsigned long)u_req->buf & 7) == 0) && (ep->epn.is_in || !(u_req->length & (u_ep->maxpacket - 1))))) { - rc = usb_gadget_map_request(&ep->dev->gadget, u_req, + rc = usb_gadget_map_request_by_dev(&vhub->pdev->dev, u_req, ep->epn.is_in); if (rc) { dev_warn(&vhub->pdev->dev,