From patchwork Mon Jul 13 09:10:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 6776391 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A7A529F380 for ; Mon, 13 Jul 2015 09:10:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9D222063C for ; Mon, 13 Jul 2015 09:10:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96AAC2068F for ; Mon, 13 Jul 2015 09:10:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751256AbbGMJKn (ORCPT ); Mon, 13 Jul 2015 05:10:43 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:40341 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751501AbbGMJKl (ORCPT ); Mon, 13 Jul 2015 05:10:41 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie2.idc.renesas.com with ESMTP; 13 Jul 2015 18:10:40 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 7810C480A0; Mon, 13 Jul 2015 18:10:40 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 72BFB8002D; Mon, 13 Jul 2015 18:10:40 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 7124C8002F; Mon, 13 Jul 2015 18:10:40 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id UAB25896; Mon, 13 Jul 2015 18:10:40 +0900 X-IronPort-AV: E=Sophos;i="5.15,461,1432566000"; d="scan'";a="190219319" Received: from mail-pu1apc01lp0017.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.17]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 13 Jul 2015 18:10:39 +0900 Authentication-Results: linuxfoundation.org; dkim=none (message not signed) header.d=none; Received: from localhost (211.11.155.144) by TY1PR06MB0926.apcprd06.prod.outlook.com (10.164.99.152) with Microsoft SMTP Server (TLS) id 15.1.213.14; Mon, 13 Jul 2015 09:10:38 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda Subject: [PATCH/RFC] usb: gadget: udc: core: Fix argument of dma_map_single for IOMMU Date: Mon, 13 Jul 2015 18:10:05 +0900 Message-ID: <1436778605-5576-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS2PR01CA0035.jpnprd01.prod.outlook.com (25.164.161.145) To TY1PR06MB0926.apcprd06.prod.outlook.com (25.164.99.152) X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0926; 2:DLv1drGh+nH/Vh13e0HvFORGC297BS43UqZp0Qr3jx2CUg74mXmA4xATMnoVLEpj; 3:eg+IGEhoRj22/BVSSv5Ahaw5PyCukg7bqkWnKCzBiB2B3cNzMXeyJpVzxB9NF3JLVHT97uPCatyHXjVlWNDnT3Fzz42PdR6ORdF8F3/82aSKPfLcojnIiATAHOLbXBpjPsSZMdOsy7v7tuiXQSSRZw==; 25:f+nQbUEsccK0QST8YWY9ccFCldv8mwhOdQrim2Fn+aD9DLGVW0+5UFyA/4fTBHvDK18VAjlvwTMBIzYy5rzLlSJpzlW4Er2zUseBrmf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X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:TY1PR06MB0926; BCL:0; PCL:0; RULEID:; SRVR:TY1PR06MB0926; X-Forefront-PRVS: 0636271852 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(87976001)(42382002)(19580405001)(19580395003)(47776003)(5001770100001)(575784001)(46102003)(76506005)(78352002)(33646002)(66066001)(50986999)(189998001)(42186005)(50226001)(229853001)(77096005)(107886002)(5001960100002)(92566002)(40100003)(48376002)(122386002)(50466002)(5003940100001)(62966003)(77156002)(36756003)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR06MB0926; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0926; 23:+/N39N2TI+B3WMjhZBVhdPM9xfRd0OJzx2pRXrWgFgV5xVr2k+JjpH2+Nr7a7255UGAuOUiUkv27LO9jZAzc7V5EyFk8oQVrQBmJF5bzJ55lmFvURC/2FC1o2AS87cEyvuwnLVoEfpAVY18pZ7Vppieb3vsGMOnVLV5py5OZWq2ULA3doXg+ZGr78obVesSarm+Ht7ESubI8bDUHTYiLYeoNjY2hc7m1T854Tj+NvXgK1mBwipBstskcY81MYs6r8XlCu2DE3eCg9Nj1SBw4iGUpLyBS4cbg4PAF6rJY/GCOHwC2XNE+xuWBjN1G57kCEqyB/+p0+2FL7GCPmQ9DLVKPvOBRk/hKFM5nMklfTr9YbRd+j9Ua4oh55MyZWKjj3ppdlHJIHkkn5jMT9c+q+GK3WBNrXTCTpVNMWqeZumV7bAIqXQg9j3qcja6YXEf++GNxPHHsLovQ6flfoH8R4bNKORMe7WlKGouqsXPpj1ODRhdJweSE85PxoRmlFqwmUV7dHu9HY8jI21m4qTKk5AH+KaHkMdKpAJn+K84i733E0+eImLxVfSYsd20IN5hx6xJkxU1fa51mYzfKvHrFZPzYyT1DP9iSabSHw2U5fZF5PTwJQ54HCHk34S6UW0DSHjPvoHEO3rTK0r0NYACIxIiqq/3G8QQdqlotsfeBD/2BvjAMpKlG5Dngpnn/sUzC/9PDxCab6QCRMGa/0+mp01iHhVofxiVE6YQlsS+Zzjq9Lh+B+iW7aUXsxcVqdUXvQsi0bTQMKmFBdKdxbDOL47WQIF1D3MCBspJiScZhVbgRaYFy+D+DvG9ZDyjPXfAPw5KaN4xzZcJlvMPV8vlPMUl+zsXg97FEaZQZ32VbVZyauKgHRRV9bVEBJbxaZi5HK//gTt7yogwMe3ka564ejA== X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0926; 5:hG3OtnbYDhiucJnoCzROYQuVQXp2nxHmahSYk9ZogiyU1d7bBj2+3QXCYUXAdFCdUXXAb1Qa7rAPKi/MpmN8QIZcc/paAR3bPdix3bsPZaA1267ldKHNOo55pdZRPSeN0ljVNsI7F+jyvQNp2ENyWA==; 24:DBfDTC6PV5/x3fRDkpmVbHX1/byTwyXdgsj7V31iu/iQmAUusdfttnEODg+nvmRh1W8PYwFhnbCNV70VagaDWchy+vIygZAax9YvlJhljbc=; 20:fVHB7I5pw9p1PoYRpQ+GrNX55YzhKnG+VqW9MlrQGxkpLfOYNSoSabOg+VTkge9zSMxMZKJBxS3evoKZSxhWsjLmKEst5PZ07QkZgiE7r3wdCYI1b/oIeFOD9SKX/6lZmbc40Mehld2HJGtHnJaDc8I//f0tlAjKvPQqv6J5s3M= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2015 09:10:38.1315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR06MB0926 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The dma_map_single and dma_unmap_single should set "gadget->dev.parent" instead of "&gadget->dev" in the first argument because the parent has a udc controller's device pointer. Otherwise, iommu functions are not called in ARM environment. Signed-off-by: Yoshihiro Shimoda --- This patch is based on the Felipe's usb.git / testing/next branch. commit id = 298623983e74d935fc241d0eb1d0740cf4c32599 drivers/usb/gadget/udc/udc-core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index d69c355..362ee8a 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -60,13 +60,15 @@ static DEFINE_MUTEX(udc_lock); int usb_gadget_map_request(struct usb_gadget *gadget, struct usb_request *req, int is_in) { + struct device *dev = gadget->dev.parent; + if (req->length == 0) return 0; if (req->num_sgs) { int mapped; - mapped = dma_map_sg(&gadget->dev, req->sg, req->num_sgs, + mapped = dma_map_sg(dev, req->sg, req->num_sgs, is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); if (mapped == 0) { dev_err(&gadget->dev, "failed to map SGs\n"); @@ -75,11 +77,11 @@ int usb_gadget_map_request(struct usb_gadget *gadget, req->num_mapped_sgs = mapped; } else { - req->dma = dma_map_single(&gadget->dev, req->buf, req->length, + req->dma = dma_map_single(dev, req->buf, req->length, is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); - if (dma_mapping_error(&gadget->dev, req->dma)) { - dev_err(&gadget->dev, "failed to map buffer\n"); + if (dma_mapping_error(dev, req->dma)) { + dev_err(dev, "failed to map buffer\n"); return -EFAULT; } } @@ -95,12 +97,12 @@ void usb_gadget_unmap_request(struct usb_gadget *gadget, return; if (req->num_mapped_sgs) { - dma_unmap_sg(&gadget->dev, req->sg, req->num_mapped_sgs, + dma_unmap_sg(gadget->dev.parent, req->sg, req->num_mapped_sgs, is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); req->num_mapped_sgs = 0; } else { - dma_unmap_single(&gadget->dev, req->dma, req->length, + dma_unmap_single(gadget->dev.parent, req->dma, req->length, is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); } }