From patchwork Tue Aug 6 00:52:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 264822 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 34E2B2C0077 for ; Tue, 6 Aug 2013 10:53:20 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752043Ab3HFAxQ (ORCPT ); Mon, 5 Aug 2013 20:53:16 -0400 Received: from mail-pb0-f50.google.com ([209.85.160.50]:41585 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751876Ab3HFAxO (ORCPT ); Mon, 5 Aug 2013 20:53:14 -0400 Received: by mail-pb0-f50.google.com with SMTP id uo5so4053702pbc.37 for ; Mon, 05 Aug 2013 17:53:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=qflRHiznR7/9FekYuREaj9A9tTb6WtIiMdRcaWQDbLs=; b=i4T90HzSqNmBhWwYjYU4peX9Z448j8VfevqQ24VuPUqJrBZArCofWruO90/StOLcsY pE+OXtWV12jWVWMO8oqFZdlVSJugLYikKVCxNF+gq+m0lHAQgzAj7yYo/eRrhUeNslvY H2CM1PxAIADudS2aD755mtPJSvpB30vucko0kv5UuuczqU/6XfwtJLVexWsF57WrV0Y8 FmA0Zlku7bByFPv1JSMrt2ONXyLVgfSQ15HIXvs4mQMn3PXzY2cy768BM606c0d8j4fE 66Sgwrj/TzhyUhrsMivOxZLHif0cnlB66G2PQ0O4FmyPgnYulNRsOgLHB9Vx+aXdlbKU rjpg== X-Received: by 10.69.0.9 with SMTP id au9mr22999572pbd.62.1375750393823; Mon, 05 Aug 2013 17:53:13 -0700 (PDT) Received: from localhost ([183.37.198.249]) by mx.google.com with ESMTPSA id xe9sm467435pab.0.2013.08.05.17.53.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 05 Aug 2013 17:53:12 -0700 (PDT) From: Ming Lei To: "David S. Miller" , Greg Kroah-Hartman Cc: Oliver Neukum , Sarah Sharp , netdev@vger.kernel.org, linux-usb@vger.kernel.org, Ming Lei Subject: [PATCH v3 1/4] USB: introduce usb_device_no_sg_constraint() helper Date: Tue, 6 Aug 2013 08:52:46 +0800 Message-Id: <1375750370-18194-2-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1375750370-18194-1-git-send-email-ming.lei@canonical.com> References: <1375750370-18194-1-git-send-email-ming.lei@canonical.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some host controllers(such as xHCI) can support building packet from discontinuous buffers, so introduce one flag and helper for this kind of host controllers, then the feature can help some applications(such as usbnet) by supporting arbitrary length of sg buffers. Acked-by: Alan Stern Signed-off-by: Ming Lei --- drivers/usb/core/urb.c | 3 ++- include/linux/usb.h | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index e75115a..c77ec78 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -414,7 +414,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) urb->iso_frame_desc[n].status = -EXDEV; urb->iso_frame_desc[n].actual_length = 0; } - } else if (dev->speed != USB_SPEED_WIRELESS && urb->num_sgs) { + } else if (urb->num_sgs && !urb->dev->bus->no_sg_constraint && + dev->speed != USB_SPEED_WIRELESS) { struct scatterlist *sg; int i; diff --git a/include/linux/usb.h b/include/linux/usb.h index 84f14e2..bbd2c8d 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -337,6 +337,7 @@ struct usb_bus { * the ep queue on a short transfer * with the URB_SHORT_NOT_OK flag set. */ + unsigned no_sg_constraint:1; /* no sg constraint */ unsigned sg_tablesize; /* 0 or largest number of sg list entries */ int devnum_next; /* Next open device number in @@ -684,6 +685,11 @@ static inline bool usb_device_supports_ltm(struct usb_device *udev) return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT; } +static inline bool usb_device_no_sg_constraint(struct usb_device *udev) +{ + return udev && udev->bus && udev->bus->no_sg_constraint; +} + /*-------------------------------------------------------------------------*/ @@ -1249,7 +1255,7 @@ typedef void (*usb_complete_t)(struct urb *); * transfer_buffer. * @sg: scatter gather buffer list, the buffer size of each element in * the list (except the last) must be divisible by the endpoint's - * max packet size + * max packet size if no_sg_constraint isn't set in 'struct usb_bus' * @num_mapped_sgs: (internal) number of mapped sg entries * @num_sgs: number of entries in the sg list * @transfer_buffer_length: How big is transfer_buffer. The transfer may