From patchwork Tue Apr 5 09:15:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 8748921 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 48E169F36E for ; Tue, 5 Apr 2016 09:16:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F3D720364 for ; Tue, 5 Apr 2016 09:16:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C04052035D for ; Tue, 5 Apr 2016 09:16:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757828AbcDEJQL (ORCPT ); Tue, 5 Apr 2016 05:16:11 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:15037 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757825AbcDEJQJ (ORCPT ); Tue, 5 Apr 2016 05:16:09 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie4.idc.renesas.com with ESMTP; 05 Apr 2016 18:16:07 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id D194D3F119; Tue, 5 Apr 2016 18:16:07 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id CE8658002E; Tue, 5 Apr 2016 18:16:07 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id C82838002D; Tue, 5 Apr 2016 18:16:07 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id UAA12643; Tue, 5 Apr 2016 18:16:07 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="208087330" Received: from mail-sg2apc01lp0246.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.246]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 05 Apr 2016 18:16:06 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YStdvuJh9PRNwPZysSm8a7lywFmI6+mSpQfN5zwztig=; b=HQcxkLXRpiwVD013mrnCzWTB513O7M+x6NvNNb0NxqWhcquTSYumHkV0ePaD9JS+3mGRx3mAkZERmuwubYuazdVitLsQ8tI2DJpZRqt9lHrEqImE5IZDm3UPeH8q1JOza/Fe6tOYGyha2AIW/UW7UtkERYIVenF3tEZjvhuwpWI= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from localhost (211.11.155.144) by TY1PR06MB0927.apcprd06.prod.outlook.com (10.164.99.153) with Microsoft SMTP Server (TLS) id 15.1.447.15; Tue, 5 Apr 2016 09:16:04 +0000 From: Yoshihiro Shimoda To: CC: , , , Yoshihiro Shimoda Subject: [PATCH/RFC 2/5] usb: gadget: udc: core: add usb_gadget_{un}map_request_by_dev() Date: Tue, 5 Apr 2016 18:15:46 +0900 Message-ID: <1459847749-5336-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1459847749-5336-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1459847749-5336-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0031.jpnprd01.prod.outlook.com (10.164.162.141) To TY1PR06MB0927.apcprd06.prod.outlook.com (10.164.99.153) X-MS-Office365-Filtering-Correlation-Id: 1143cc4a-baac-4c3b-ba47-08d35d32ea45 X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0927; 2:311r0gzEBIcgCQMPiFGS7MK71VKUIJWoQPOLvjGGIxrwHV6SemVw04lDDMeCOvPlsEY5hv5Nh3KsK61Ukh+x5y6fdiktVcIBb5ZeiCQUFZC4jb3hdMJZdVWbN+8w32IF30yab6AQMbC/coz7id83Ck1SpuGjHVJNjoV8P5AW35TBfQWxtJ9k4CdgYO56+yq3; 3:HaAwh4qQGVgtGjqzu30zpokTRHcqk5CVQS1xwcRG96iL6FkPSjyV8bXeKz/fC9/tW/xLUQL2+g/TnIhzlJfwh6V5qMxFZAGx0BP+dEHjXZr6gHL/NmhEVBrJ8XkSbDAy; 25:2OFR3GLJYSuwF4oT6gYB9IlxiVG0Y3u59DZJJHkiRHzZcve1qGx7GrnLpNdlYh9Tatunp0O23aeDFk4Gg7OVYW4tVrIK74YPSREr8vgXru2+y0bTACaVd6U8In5nvJjc/AGpATUpM5ygeZSH/jwIq6xy//5uYkvZ9SuDwn6d8nsByw5dKiI4aBkZPAhRHa4MBJzNWZWWjGEHYeEq8f3aykF//aZftf0j1JMLPYGS6FF9/ybpk6E71JKcaZT9Rtg3p97s8WQq+M+wUdWkCakJsrMWgK0BZcVxIk94IbiKwIrRVJXTmFtGQis0tUyM+SCEskH8RXCF1bejduIkktjQ3j6CoCLLEh86OD97/S0FoZU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:TY1PR06MB0927; X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0927; 20:jZ/qIjO2dHmSvtwO0p7D/7G/0u+Pejf+cESVg/wZZq0wE6QMvQ2WhHJ37cCxZVFnTXndrJXKrRJburGcHfbDWclDorig16k2hCgU1CiD4FjS/3pdVrMze+wf3y7HiaomW4nJn3gatFpX5Y3UvKcmpK8VqdFbboicvkcQfgy6IKFGv/nHOp9a9f0anhusblW19heDzNamWX/7cKSQdTNQLkrCN/wmtiP3aT159cObRdZ9ZzBxn5Sveq/cmXB34ROardnnyEdE/re1wpVdzO/tRENbueceZ0Qr+wwMACWnHO/5tSzAazKUT7w4G/dwEuH8Sirwb90nW9hOZZzxSkpIceon0g/7r7YA6UfCjOdgM3MqLDW1u9MOdeiBRS6J6kAS71wO5VqHR/prRT8f/ixh3Envir/DRcOy4REEugBKSsQJDRAB9Bxt08Dexj4flxJGZRdwr5ePCEsRiXCQ5KLJ0RzIhx7Kh5hllZB13hGrMiC6C67bkQ+CxBY8WHTeGpLK; 4:faxh3ExbxncvT0SSUtNF2kYhCemHvROWfsfqF6Q+K8KwOjGf58lyG+1S3OaqmveF/7JPKMv9Ar8mCrjlIMji7a8pG9CKoIWg4Cgdjz8/+t6OX3nK6lP+Fu3gRr8KEMe7Qbs3mVRs2PCt/6PB4UOk8d6CROVCJ/VoKHX1JssL7KZivNhPSPoQVyQ3iHte2DogWVxacU0/t6se0yWKcZTcMFSEBHMhk7GLk1R8zNPvhSS784dT0lT2norSL+GbdlDaPLrgFg1JiCJRySDj2oB710v/apHElwt5wsApO2osZfVvpczPVTWWeK/ha1nF+LLLBdwM2YfTWxLDQ7BRz1WSo47+l0X/ilhce1ftP/rfHa81NioztCD7zRD2weuoG1nv X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:TY1PR06MB0927; BCL:0; PCL:0; RULEID:; SRVR:TY1PR06MB0927; X-Forefront-PRVS: 0903DD1D85 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(66066001)(92566002)(50226001)(78352003)(110136002)(2950100001)(107886002)(81166005)(77096005)(36756003)(42382002)(189998001)(50986999)(2906002)(4326007)(6116002)(586003)(3846002)(19580395003)(1096002)(19580405001)(47776003)(50466002)(5008740100001)(5003940100001)(4001430100002)(42186005)(76506005)(229853001)(5004730100002)(48376002)(33646002)(2351001)(76176999); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR06MB0927; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; TY1PR06MB0927; 23:txqWPdpwIuN87aLZC4iCcvoHTrmyEZA+R5h/+iQOQ?= =?us-ascii?Q?W/6lB1WOM5BnswnO/JQpY5QY5c0YlAFz4S2KzFxfTxzX5K1jN6AmjGPwuiAu?= =?us-ascii?Q?4UtMfOjiOt065u/ykrQKRd10RULgZaChFJE+6g9ZwIMGiG2fp4rUN5rjcPgd?= =?us-ascii?Q?wpr8ndaEYF2fxfzQNEkOqDcOrlDMlLksI8Mikve35K+6SZKbxLCnmpOpcZ/9?= =?us-ascii?Q?/DcpwgoveY+kaa9lg8ZhIWS+0TgE2d1FBaOClcqaAYANQm01cMvBQausUYGv?= =?us-ascii?Q?X4VVI+FbcBf1hvOeoHLacOpOBgckQX/snaU6zBSx89P7fYiyOmgdp3vp5yqM?= =?us-ascii?Q?TpgG+rPsUYpnX3x1n3KTWsODXB12rtvk6TN4tno/N5z5kApEbq+d+iro6VLB?= =?us-ascii?Q?Ykd7CVY/vl3p7sOVjT5j85EkZztJ/rRysbVqdcpOQwz8b0XtQzsMJ4eoHLZE?= =?us-ascii?Q?kF8Efv7JzDBZ43dH+EObbw8LxFw5wuibgBkPBg03kTIn2vtZldsV2yLYofiZ?= =?us-ascii?Q?+bkmZweIf7cRitTJMeEzAyoiXokUv7VYv0/MU0r6tT0HcwUgmnh6ozfEZRlO?= =?us-ascii?Q?Y5tjlvTUCezCS10Zuw/oBkUUeQMAfqjQ2EwToMpZGC/NumsiFkL7xfE1vuUF?= =?us-ascii?Q?2t43lZqkT9JXdaR7nC6eTKTroN8wSYyogahqAoalo4pN1WxDDZYIOSp8/0Ld?= =?us-ascii?Q?NgitnqKj5p16Z97VAGMWDbV+QyYFk0SlUqjH9feWI3O3ZIge8xFABO28CpIV?= =?us-ascii?Q?LUwsVgzaDX0KbZk2uE9raOGr5lG1ZwbJlDeJ6VcfTxj1CrqTkt15rR5nQ0/y?= =?us-ascii?Q?BQfACbxrcMOdhEa+pfMJ8kb4fHzI3vcYCMEGIJq/CsbYYWMeN2upAAJZxI9S?= =?us-ascii?Q?QAVgA/Rf/alE16tYHNaag+C4MAMFkD9bFNep17ojFW0R0majMBIwX/+0Mvp5?= =?us-ascii?Q?92B0kTEz66lx04e1Y8RQLXdTKAqL+D/I+CN/lG8LbDggvR6ymHucnf1cfjVU?= =?us-ascii?Q?5MkIYs65JcrgUwepvuYdeWp?= X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0927; 5:Ud2qzArqeBDAPy0xAQ1O7S3QmKlTkqc1gs1S9ZxZLScTpzNIV9wUfAc2yfUpFMhVM4dtY/JHuXEFnccsIL+SUI7Kh1dlm/2gdwH6WaoGxImLcH2tcQ02vfm3JwZBg9yQtYmdfJ1hkIV5KbOIxTl11Q==; 24:qdBc/lFzvzxkrNHS+yzhYZ2awtDmsGO9Imvd2RG2pfp6F4cFZCJbrSiS/xP/+pLkXJP4CEJVkbkxeQFN+nXi4TmP4bcBFWNznSk2Tw2CFdU=; 20:qVLgTMD22vqmj4+aQjrx/7stzZiuy1yLJKzyOVGu8Ta9Ill/28ElOpc1kjTv1vkSRYbmlkStl9kCIa8ogYdkZnYEqZYjyQPhCjjmsdSlb0hClnBvb7hVV8aeE5ezRrRMfaUXzrjozRWN4ckEmMo6ANIQ1PTD5rQe6NvpWrCPBcA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 09:16:04.7370 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR06MB0927 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable 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 If the following environment, the first argument of DMA API should be set to a DMAC's device structure, not a udc controller's one. - A udc controller needs an external DMAC device (like a DMA Engine). - The external DMAC enables IOMMU. So, this patch add usb_gadget_{un}map_request_by_dev() API to set a DMAC's device structure by a udc controller driver. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/gadget/udc/udc-core.c | 24 ++++++++++++++++++------ include/linux/usb/gadget.h | 4 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index 2f9c9a0..9dbb3ee 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -61,11 +61,9 @@ static int udc_bind_to_driver(struct usb_udc *udc, #ifdef CONFIG_HAS_DMA -int usb_gadget_map_request(struct usb_gadget *gadget, +int usb_gadget_map_request_by_dev(struct device *dev, struct usb_request *req, int is_in) { - struct device *dev = gadget->dev.parent; - if (req->length == 0) return 0; @@ -92,24 +90,38 @@ int usb_gadget_map_request(struct usb_gadget *gadget, return 0; } +EXPORT_SYMBOL_GPL(usb_gadget_map_request_by_dev); + +int usb_gadget_map_request(struct usb_gadget *gadget, + struct usb_request *req, int is_in) +{ + return usb_gadget_map_request_by_dev(gadget->dev.parent, req, is_in); +} EXPORT_SYMBOL_GPL(usb_gadget_map_request); -void usb_gadget_unmap_request(struct usb_gadget *gadget, +void usb_gadget_unmap_request_by_dev(struct device *dev, struct usb_request *req, int is_in) { if (req->length == 0) return; if (req->num_mapped_sgs) { - dma_unmap_sg(gadget->dev.parent, req->sg, req->num_mapped_sgs, + dma_unmap_sg(dev, 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.parent, req->dma, req->length, + dma_unmap_single(dev, req->dma, req->length, is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); } } +EXPORT_SYMBOL_GPL(usb_gadget_unmap_request_by_dev); + +void usb_gadget_unmap_request(struct usb_gadget *gadget, + struct usb_request *req, int is_in) +{ + usb_gadget_unmap_request_by_dev(gadget->dev.parent, req, is_in); +} EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); #endif /* CONFIG_HAS_DMA */ diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 5d4e151..457651b 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -1223,9 +1223,13 @@ int usb_otg_descriptor_init(struct usb_gadget *gadget, /* utility to simplify map/unmap of usb_requests to/from DMA */ +extern int usb_gadget_map_request_by_dev(struct device *dev, + struct usb_request *req, int is_in); extern int usb_gadget_map_request(struct usb_gadget *gadget, struct usb_request *req, int is_in); +extern void usb_gadget_unmap_request_by_dev(struct device *dev, + struct usb_request *req, int is_in); extern void usb_gadget_unmap_request(struct usb_gadget *gadget, struct usb_request *req, int is_in);