Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4592304pxj; Wed, 12 May 2021 08:51:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv2F/di6UlYPIFrHqcdSp9jL7N54/K+S7F1qpJ6dorpU+LZpzT6qyQ25cUQpVQH+QvAN2B X-Received: by 2002:a17:906:cd27:: with SMTP id oz39mr38270520ejb.129.1620834686166; Wed, 12 May 2021 08:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834686; cv=none; d=google.com; s=arc-20160816; b=H5hEly7zr9SQg5n6qCjnMyeOvuCUhN75t33bROtciUqK4WdfuXpL3Bo6fZIDpnf5PQ Zm1aH2CudvUW/YCSW9RMDJzGMdi/w/IwG3YmWQDA5gTepy5uvlt28akxv0TBFRA4eUzJ Z1R8ZEDiihW8hRcbpX6zPMsdQJNdk9w/7DObL/V21v8CUn5xK1lmOCbXcnwUJ/BynbYo Sky7gr+aJphY8C5IjFbQpeNzHp8mEQq/RxIv4A4WwQ6nsMp8+kx02kdeEoP2Bvdti/ip S7Ca6Fhiy5xuedMwsw1d5pavIHCF9Vm0bj2DFpCj6lMd8G5y0Cb/FPo4nA2cOjXnjjt/ soLQ== 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=UCp369HkLyoVxHG7VX7av4zA805DhhIeOsNC6L9MlojeYtEb5ZVn2x81tHIBGn0fum MWTanQqz2HwiP4dpe/KQoV7hvG9oLCA6cycqPqAh0Y2C02Ds/RVgQWPPrLpB8nZSyzgY 6KsiGQnf2fU6l2Kk63oanZljAmdwBaz60WQFblkV720LvE8z6ZA7pgaS/PS3sTyodRNL NFnVBZVt1/5EpMoOhxuPwuqv9hCJJDZq1xrBcMxFCTeaQuqaxufK/d9fuCe9dBcDZ66l 15MXEB+0virygKnS0nNp+rpFGPXL9tdxcp64pQ9V1zfEx2GzBFDd9nG/O1sObBod5RZF M6EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N7ZHDGfd; 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 t21si114851edd.145.2021.05.12.08.51.01; Wed, 12 May 2021 08:51:26 -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=N7ZHDGfd; 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 S237591AbhELPu6 (ORCPT + 99 others); Wed, 12 May 2021 11:50:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:40490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234780AbhELPZd (ORCPT ); Wed, 12 May 2021 11:25:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B96D9619C6; Wed, 12 May 2021 15:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832232; bh=jn2O8K8pwyjBmwgYvllvrLtifNuQlyc77vV+Gf+3RcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N7ZHDGfdb0MYZpIDFEn4YrbpB6f4rFvw4BE7rQSvTpXVb5zeLXsVeXUDFB9w9v7HJ o9wdakqWaoEBOkxEESp1yfHQeldUyJERZIGlBRJnbyz9EWrCrCKOXUEJoiA04uYGMu 9sIpgG2zDUMlqm4RtLcx4VYnJYPJ8oK/BuV3hd9I= 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.10 196/530] usb: gadget: aspeed: fix dma map failure Date: Wed, 12 May 2021 16:45:06 +0200 Message-Id: <20210512144826.278939840@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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