Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp781664ybh; Sat, 3 Aug 2019 09:39:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIb9JjMNtMHR1z8s+0Q8fNqqrkqa3x5mYiS7PlLePsnIt3ub3M4Bv7DNxK2Ifel5p0w7nw X-Received: by 2002:a17:902:a413:: with SMTP id p19mr137773545plq.134.1564850382699; Sat, 03 Aug 2019 09:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564850382; cv=none; d=google.com; s=arc-20160816; b=auema548kZg2G8IYNv0MJLTQCUrfh2zwJyStccsa7fhB89UQMWDz2GUa/4AtbEWLsM xivP5im+6ELtM8JceHQO/U/BMpqUlewMmOgiWfoLEKbHrQJzvacHrU18OgtKOngr7amM 6KLSLtweTjlSYjbs6i2BXYsBYvFcOfz7nA48/j6R7S7LWuheC+aZDizOlfEPvqZGEeLM c0lH5sqFMSsK0adQ5HkU6EMRf5PUbHcJ43GISHdqM//NuB53lUiyPAIGZNlU7m+IgY4R 4gQjCJskKsMRYlFyDxjLBup42X1yJCiZ41BqXuKsUfQeIcwz+Ihs+IqD7EjUndxDBXOd zalQ== 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=me5T3lDP0XHqzPg3hsXbz18y3fE9lT7QG8JAwG3e6dw=; b=G4d+xzjSIwW+zqX784xaKSi8zlgEW0R0CyTzxLESo/aFybB3ITYOYLJpU5n2Lv0M/u gD/gVZqA608+wri2eEJMf8NM4L2EvjkBGJUrG2iDdHufZYIOfd0ZXmE8mcqf74HWQwgb u4qwbdF7015AJ0nm71eEfMCOf5nJHNnqxFwtRJzyGaUkBi4uAPoBZ9bN7rt+85x1MnXn wKsfyAXahN0kALk7OxNDewBp8I7RXn+G7stp+zWhRnGPWo054h2gaodZSye2QUy2p9ca 1hW4Y10j8N88ixN0hpu9X2o3yZgDnBFHzErscObzLshqPcAC6JsfPmZ54tqkTbtGXryT xnRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qFaE7hvZ; 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 s189si39197837pgb.272.2019.08.03.09.39.28; Sat, 03 Aug 2019 09:39:42 -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=qFaE7hvZ; 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 S2405581AbfHBRhG (ORCPT + 99 others); Fri, 2 Aug 2019 13:37:06 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36052 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729364AbfHBRhG (ORCPT ); Fri, 2 Aug 2019 13:37:06 -0400 Received: by mail-pl1-f193.google.com with SMTP id k8so33923776plt.3; Fri, 02 Aug 2019 10:37:05 -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=me5T3lDP0XHqzPg3hsXbz18y3fE9lT7QG8JAwG3e6dw=; b=qFaE7hvZGut8iWN8Jn/ffF/evZUbFkxFQPkMUm/ZfuX9YMYAGrrJYwIgTsg5tTPOIc E570f2F1IDetChqThDcmIX+Y6/5bpdaZLNitmRtDoOg8jM1ZSOBO3riucJAx7pXNz6Is 52247nXfRuRCeezPQJtU+xac9H03pGK2bSbjlRriPMt/xhqhron9+bXcCdMceOBOSSig 6YrTXwooSFEnbkfL6uMkZ39Nh9WhBEbI5rvfj0Z05tvaz9bfPIPVwcw+X+KwEjdzEzAY /9tVHVVyGjhtmvVqHrrZhQEpW67dAZyHhLW5I0+iteJyVZDUsQTfZAOFdD4w0IciW7+S d1pw== 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=me5T3lDP0XHqzPg3hsXbz18y3fE9lT7QG8JAwG3e6dw=; b=eLlF2C4L8toYJS6ppot5LbKE9UgTWI1NsoFYrvkHw5XaZZixHqqbOxmKyqrRWKntfm tvUcJxf3EuCDNv0Vc0nQWcIQPlDyPh0q2jD6CpjNiG8LzPiJ5aerbkLr3+s95fkTIyPe VutfzIGxzUZVPGSW0eLknqNKLp+EplTEBHoDTLG0xRrS1E+rwZx4aPDo7GAR6ilmBHk5 9aMAAoIC5N343gAERd1oaVY5+Kvo9o1ZA0GZXBjQa0QCQ+olFoviBdlbDRe6/8uYymd1 DAUTNlaqU+ajXDRRHedaCquE9iUggIKXDm0/3A50TwB8WyHqwOn0A/z+ifdBkquzp7mR bsRg== X-Gm-Message-State: APjAAAVsOH+JZxZscjvlmvmm0Rb8WH2qPhOCFt75fvrtCf9Z3iPo+oB8 UTWIOf1MraQt1FefOzjoiTo= X-Received: by 2002:a17:902:2a26:: with SMTP id i35mr130452561plb.315.1564767425535; Fri, 02 Aug 2019 10:37:05 -0700 (PDT) Received: from localhost.localdomain ([125.142.23.13]) by smtp.googlemail.com with ESMTPSA id a20sm7992911pjo.0.2019.08.02.10.37.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 10:37:05 -0700 (PDT) From: Suwan Kim To: shuah@kernel.org, valentina.manea.m@gmail.com, gregkh@linuxfoundation.org, stern@rowland.harvard.edu Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Suwan Kim Subject: [PATCH v3 1/2] usbip: Skip DMA mapping and unmapping for urb at vhci Date: Sat, 3 Aug 2019 02:36:50 +0900 Message-Id: <20190802173651.22247-2-suwan.kim027@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802173651.22247-1-suwan.kim027@gmail.com> References: <20190802173651.22247-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. 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. 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). And vhci_map_urb_for_dma() prevents isoc pipe from using SG as hcd_map_urb_for_dma() does. 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..c62f7fa8118c 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) +{ + if (usb_endpoint_xfer_isoc(&urb->ep->desc) && urb->num_sgs) { + WARN_ON(1); + return -EINVAL; + } + + 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