Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3576619ybi; Fri, 5 Jul 2019 09:48:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5ud+FZgQiXpJuzvBJm+qwgj/OLAvLiKwBQf4YBUNE3BOMHrYtoZ6vYfRUGae3oBl7P8YT X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr6640508pjz.140.1562345333249; Fri, 05 Jul 2019 09:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562345333; cv=none; d=google.com; s=arc-20160816; b=pVVULWRhCpaNHVXXd4EcLVDnUJyYLs93UfC85hrweovC3NPQRi2BakkIkGesh/RbFK tHBN97ah8F+FDdaO5FzwgJw1XZibcjnFUKNo4QplfFW92tTrBcU69mXMe4dYNcpxjx9I xl7VOWiHTE8a38qonq6ihggaiMBKy6Z3Gtdb2D+o9KHXsX7JLm27OlAY4iV2w5I+Dl++ Tpv/Jdvom74h0pg2cUIK0YE5GOrWCwUZ6/jvHqEC9O9iaUj7AQooWXuyPmnQaXxxCBeH HepNosbXu0y0HXblZad+14a1nTyPRVeFDx9qayyEQcmyLtfKWiQX9KXOczKgGg49bKek 2mdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RIdsJBlUPjM8WHpD9LJ2+yFLP6iSJp64o+eyXmvQqGk=; b=kCu5mmdc17T/giu4hdCZn9SOzEH1RN7gqaJo1uF3F8e0J+oiYi4C47DMhTFJiaTVZy 5hW3CORr9ziMvAP3LDQbyZYgJvxdPT4EsdXL7zP97PMlP35uZNCSUScHR62tNULRL51p Z+9pgrOuhfqmf9KcGtCf98IAoMokm5WXF0i8sK9otFxQoSAXaVuv+wOcDPZnXrucu6dS yYCCu//mKGwDbaTb6FLYWaCrWWKGxMKQgywygfpKrygx1RSXI4AcV2WqkmtsZ+tcpP/w II1hzYGQT7eKZ6noRWqN47mKZhXsDO6dkSiCNRY9RSnlnMfOgOB5f9peL86RFfxwgE9D JQxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VR6sdkSX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si9482824pgd.347.2019.07.05.09.48.38; Fri, 05 Jul 2019 09:48:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VR6sdkSX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727358AbfGEQoe (ORCPT + 99 others); Fri, 5 Jul 2019 12:44:34 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42909 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725681AbfGEQoe (ORCPT ); Fri, 5 Jul 2019 12:44:34 -0400 Received: by mail-pf1-f195.google.com with SMTP id q10so4540250pff.9; Fri, 05 Jul 2019 09:44:33 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=RIdsJBlUPjM8WHpD9LJ2+yFLP6iSJp64o+eyXmvQqGk=; b=VR6sdkSXJEC5bHIKzOT/KyH1uGDpKv4JevF6CuhEF5ZY563whg1aSoBiDdF4lhwwBs CxL61+V7P51n/NS8Kz6seRGIbY2xdDKi766ERvLfgX6caEggG0Kwnrz5Pn84R7U1k/Mv MIP2XPw1ExNPRnDWkBcOBmu4xpflmw+JPeJU5ma7xdxcnDNw9Wbs1taWAPBORrY6IfWM 65NaADI888HDT/WvgQeQ9sJ52pXhP8swvbDPzLqcounLdRHbAQ4hg0VC94GdTsrjwbSL WAPL/YLFdAVcRiBprcI9FbaQj3XH1Du/aOxn+m9Mp6/7QyQY8FJm1A2r0WI+r+hV5H9i nDbg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=RIdsJBlUPjM8WHpD9LJ2+yFLP6iSJp64o+eyXmvQqGk=; b=lUUj+KcmxRVI4w/wZh1jKIz1RAChhb/delRAsYXaklvJo87m25Tp+hYgGbr15kplKt 2KE1jVE9V+/Iw/gMYgMUoEU5Q0fAsvvRRlDTlg5daBGqpMaGALiJjKmgvYUMvWjXmb2/ 29nI/xZ/1V9sds6D+3WrzgkuZ4GuMr7uUyT4E2boccLueLy5flAxgOB3g1oieZswQiRu Kt8V5HICmToY7CM/8fS63db1qAP5aunzO5ZHzXvQ1/ODM/r/Bx9GZTiALiymZqT8dz2+ N0RMxywwOoqRmwcKOPowmLYtVPw1CFromUOfCQR8Qzyg0obPKJfJMqTsFKwCVBznhp2l nE6g== X-Gm-Message-State: APjAAAVNoJORuYtfyfj3WmCk8j1aA6XeezIB5w1t6m4umAhhCzxjZdmz dIcr4NYqNz3GgoXOt/tM4uA= X-Received: by 2002:a17:90a:5884:: with SMTP id j4mr6992363pji.142.1562345073499; Fri, 05 Jul 2019 09:44:33 -0700 (PDT) Received: from localhost.localdomain ([125.142.23.13]) by smtp.googlemail.com with ESMTPSA id n89sm22033297pjc.0.2019.07.05.09.44.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 09:44:33 -0700 (PDT) From: Suwan Kim To: shuah@kernel.org, valentina.manea.m@gmail.com, stern@rowland.harvard.edu, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Suwan Kim Subject: [PATCH v2 1/2] usbip: Skip DMA mapping and unmapping for urb at vhci Date: Sat, 6 Jul 2019 01:43:54 +0900 Message-Id: <20190705164355.14025-2-suwan.kim027@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190705164355.14025-1-suwan.kim027@gmail.com> References: <20190705164355.14025-1-suwan.kim027@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vhci doesn’t do DMA for remote device. Actually, the real DMA operation is done by network card driver. vhci just passes virtual address of the buffer to the network stack, so vhci doesn’t use and need dma address of the buffer of the URB. When it comes to supporting SG for vhci, it is useful to use native SG list (urb->num_sgs) instead of mapped SG list because DMA mapping fnuction can adjust the number of SG list (urb->num_mapped_sgs). But HCD provides DMA mapping and unmapping function by default. Moreover, it causes unnecessary DMA mapping and unmapping which will be done again at the NIC driver and it wastes CPU cycles. So, implement map_urb_for_dma and unmap_urb_for_dma function for vhci in order to skip the DMA mapping and unmapping procedure. To support SG, vhci_map_urb_for_dma() sets URB_DMA_MAP_SG flag in urb->transfer_flags if URB has SG list and this flag will tell the stub driver to use SG list. Signed-off-by: Suwan Kim --- drivers/usb/usbip/vhci_hcd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 000ab7225717..14fc6d9f4e6a 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -1288,6 +1288,22 @@ static int vhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev, return 0; } +static int vhci_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, + gfp_t mem_flags) +{ + dev_dbg(hcd->self.controller, "vhci does not map urb for dma\n"); + + if (urb->num_sgs) + urb->transfer_flags |= URB_DMA_MAP_SG; + + return 0; +} + +static void vhci_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) +{ + dev_dbg(hcd->self.controller, "vhci does not unmap urb for dma\n"); +} + static const struct hc_driver vhci_hc_driver = { .description = driver_name, .product_desc = driver_desc, @@ -1304,6 +1320,9 @@ static const struct hc_driver vhci_hc_driver = { .get_frame_number = vhci_get_frame_number, + .map_urb_for_dma = vhci_map_urb_for_dma, + .unmap_urb_for_dma = vhci_unmap_urb_for_dma, + .hub_status_data = vhci_hub_status, .hub_control = vhci_hub_control, .bus_suspend = vhci_bus_suspend, -- 2.20.1