Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4715052pxj; Wed, 12 May 2021 11:32:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQHYRrprjKw1ODwBFtzK3fnfb43CxaY5mIedKb+sb3i/GiB+3xggFIfNicat1MbL3rZoud X-Received: by 2002:aca:b9c1:: with SMTP id j184mr27220161oif.134.1620844353222; Wed, 12 May 2021 11:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620844353; cv=none; d=google.com; s=arc-20160816; b=fi4k9mQBU+ccI0q4YOm0YLLw6t7jzERf6s3z8jnf7cuWhK/51LkKoyXimMef5CDCZv Ld9x1L20E0cecKA9bHc3Nlu3h2dD0orGBuNR2im3lE7rSQn92btp83o9QzFgwB0VhtdT XSSW62eM19hrG7ig191UIOdxpfr5rNvVdORxh9No2unsy9MY/VOYOD+OKsFehP9XKJmB 9cfhuy7L2xolHjNcvJHvu/J35V7a19dnI2DSJ2i3zRuLBpOpjeMtF6aU5n6KMbXqcpVw iPe8IzWLRwrlDngZBbzDs8Nf0+w2ID7tDmbkKYGXND2rm5TnvDuLu+zIzdJTol3OhFmR WkTg== 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=0g4lBiiTfVhOVNUf7DYe6Sa+FeyeJwo5DDWx19ehQPo=; b=YqIqf0Pc8n0/gPioqjCZeMLTc3/nKchopayh9fYCHcczOIZgTbq44OinWYJcva8h+w ddqC8rojoY34/gatqZHYfByiNwROaplxNXtiPLT2zIPWildx01ZnYX6dJ5BGvf1D/McF +TkfPOtqsclpE8LUEgDSQiZgnpfmbw7ZJHIMrwivUgiHAayeZEZ25grM1Z/ZzVDcIB00 T1T2OhsS8KTypZlmUuUG7zMn8rx76KKRyeJLPjQNNR2jLA6pQuzxNPUaF9noOg4EpK+B W4ec/ldzku6BIneIi9EWmNDXJElm5Gs7lkPWfy9bS0FYlaKtmb87mGkHjznu43FrVyIN D2mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CRjYlWIk; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si561278otk.211.2021.05.12.11.32.19; Wed, 12 May 2021 11:32:33 -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=@linuxfoundation.org header.s=korg header.b=CRjYlWIk; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355488AbhELS21 (ORCPT + 99 others); Wed, 12 May 2021 14:28:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:54972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242880AbhELQgD (ORCPT ); Wed, 12 May 2021 12:36:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6D5E61E0C; Wed, 12 May 2021 15:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620835200; bh=jn2O8K8pwyjBmwgYvllvrLtifNuQlyc77vV+Gf+3RcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CRjYlWIkd1w2ofNmIQzHXBxO0nq+VmutQ8H/2zAkc0xoMGGly80pceWodHJz50yLi XyCYJFnfNZRMx+evrfRfn8AI746P7X9PS892iFWK3uFwpc3PwKCagJ5oHmPm2XSSfY qofp6qiNJ5Ng5bwgcDQIWEA/FPNvd+nFdOdMznlg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joel Stanley , Tao Ren , Sasha Levin Subject: [PATCH 5.12 248/677] usb: gadget: aspeed: fix dma map failure Date: Wed, 12 May 2021 16:44:54 +0200 Message-Id: <20210512144845.472409707@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tao Ren [ Upstream commit bd4d607044b961cecbf8c4c2f3bb5da4fb156993 ] 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 Fixes: 7ecca2a4080c ("usb/gadget: Add driver for Aspeed SoC virtual hub") Reviewed-by: Joel Stanley Signed-off-by: Tao Ren Link: https://lore.kernel.org/r/20210331045831.28700-1-rentao.bupt@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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, -- 2.30.2