From patchwork Thu Sep 14 17:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randy Li X-Patchwork-Id: 139942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp716285vqi; Thu, 14 Sep 2023 17:38:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9+1smVJAR+RXXi3zQahLy+0RSeOg/bKmAtK0kMi6VJSs8Sy9PSCD3t8jA0zq5FYnPwL90 X-Received: by 2002:a17:903:32cf:b0:1b8:8ff5:2cee with SMTP id i15-20020a17090332cf00b001b88ff52ceemr241096plr.64.1694738306942; Thu, 14 Sep 2023 17:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694738306; cv=none; d=google.com; s=arc-20160816; b=F68Tq1WCwHH8Trm617uFbdMpHUw6iFo9BXpWtAy2UCjdegR5IJVi8gjo4YVPQD4QFg Gn50V4dHT0Nikg8LK7ZCWe3WN4sb+dBjcJtlfFcReCRkUoDqNBnCZVijxGwMTTKJriBW 5HLUMcqFCiEpdSdHzbOfq34bGUhrc7v9/DwYsbALouCkKAOs8Gy2cEd6MjSOjxV/X2Er q0BA6sYi4XWF648DckwluUSQ/proC0bLoULZgcknZZuRZVnT1LUrSmlAKkjJO/sFJduw 15qfcNI9lcU7ns8I7iZY7VY1ZwmfKW6tf32UgLjKgM5X/EFmx840vpB+tTlrxyH28sUn 32Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=91ZYByAiQ0k1Ldqa97fT7yCCM4KmbxhRMMYPhoLTlgM=; fh=rsyPs5++zRWUdwBJjayAHO9UPSDbEr3GvAcE35ykOZ4=; b=AcYC1oqJAnYw1kK39wiYuEyfW/p5lrWWhWPP1jLFN24qBb1vJMM42AGVA1tkAdyQT1 S2VLF/JDw3oN+sF9JyG5/c7gHDs5LU2THLjxXcvignDELqkz35rA8caYJB4F1nw7ZSLM ztMq1FXXZru2VkXCjicxNu32lv0iF1KJ2ORaDkl0tNvfL/eefV4EXxkcOsp5YuqWaOuM d4mNdg4VxrZ/BKu3pbIAjOqMlGsnLtKM5riEgA/oT1uiRaIvDId8xOqJcOM0o6F4VxDq kZsm4c0ywQLlBMtDn0ZGMUdjJv6uQcL8aVO8WytG8cmsZyyg2dIYE4OWqT0Spq7cOIEM T5fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soulik.info header.s=mail header.b=QaeQ31BU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=soulik.info Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o5-20020a17090323c500b001bbc6846a21si2393835plh.429.2023.09.14.17.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 17:38:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@soulik.info header.s=mail header.b=QaeQ31BU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=soulik.info Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4D963806C34A; Thu, 14 Sep 2023 10:26:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239596AbjINRZT (ORCPT + 33 others); Thu, 14 Sep 2023 13:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232355AbjINRZI (ORCPT ); Thu, 14 Sep 2023 13:25:08 -0400 Received: from kozue.soulik.info (kozue.soulik.info [IPv6:2001:19f0:7000:8404:5400:ff:fe00:d7d6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC754685; Thu, 14 Sep 2023 10:23:55 -0700 (PDT) Received: from ritsuko.sh.sumomo.pri (unknown [10.0.12.132]) by kozue.soulik.info (Postfix) with ESMTPSA id 79D153001F1; Fri, 15 Sep 2023 02:23:42 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 kozue.soulik.info 79D153001F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soulik.info; s=mail; t=1694712223; bh=91ZYByAiQ0k1Ldqa97fT7yCCM4KmbxhRMMYPhoLTlgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QaeQ31BUa3hgH9EqcJMVDjhMF1p7mUjW6+gnxALzHwkStegEc0enCTVwcrlINIrl7 Nh0Eu0JvYi31Min0bJqQV6Crg0PsWN4bGY4FwaA7gOZpKpE93nVSH/mgjdFGhm6P32 ftSEVc2kUbJCE9XBJghXLYtCiZ2PnmgxH7iMdAps= From: Randy Li To: linux-usb@vger.kernel.org Cc: Randy Li , stern@rowland.harvard.edu, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org Subject: [PATCH 1/2] USB: dma: remove unused function prototype Date: Fri, 15 Sep 2023 01:23:23 +0800 Message-ID: <20230914172336.18761-2-ayaka@soulik.info> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230914172336.18761-1-ayaka@soulik.info> References: <20230914172336.18761-1-ayaka@soulik.info> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:26:15 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777061914906974999 X-GMAIL-MSGID: 1777061914906974999 usb_buffer_map_sg() and usb_buffer_unmap_sg() have no definition since the beginning of v5.4. The rest are gone from 2.6.12. Signed-off-by: Randy Li --- include/linux/usb.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/include/linux/usb.h b/include/linux/usb.h index a21074861f91..8c61643acd49 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1823,22 +1823,6 @@ void *usb_alloc_coherent(struct usb_device *dev, size_t size, void usb_free_coherent(struct usb_device *dev, size_t size, void *addr, dma_addr_t dma); -#if 0 -struct urb *usb_buffer_map(struct urb *urb); -void usb_buffer_dmasync(struct urb *urb); -void usb_buffer_unmap(struct urb *urb); -#endif - -struct scatterlist; -int usb_buffer_map_sg(const struct usb_device *dev, int is_in, - struct scatterlist *sg, int nents); -#if 0 -void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in, - struct scatterlist *sg, int n_hw_ents); -#endif -void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in, - struct scatterlist *sg, int n_hw_ents); - /*-------------------------------------------------------------------* * SYNCHRONOUS CALL SUPPORT * *-------------------------------------------------------------------*/ From patchwork Thu Sep 14 17:23:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randy Li X-Patchwork-Id: 140445 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1068752vqi; Fri, 15 Sep 2023 07:03:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHANKb12189McNWuqFDYeg0M8aXabDxhzkM57tY+QaQnLiS1wNn0e9AFGGsopLxnBDre292 X-Received: by 2002:a17:902:6806:b0:1c3:bc7b:8805 with SMTP id h6-20020a170902680600b001c3bc7b8805mr1707279plk.52.1694786600365; Fri, 15 Sep 2023 07:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694786600; cv=none; d=google.com; s=arc-20160816; b=KpCpOHAPRRF4U+uDjpXIYvpk6mCafOlNR5lPoJG22J85mRw7mGtcJJNVBia3vqrZx3 F/frM+SnLl8jzjn+LiJe+8G7ntwTVeqX6SIUQ/QE+B0L6aySyKcqsoaiDUirP/EVT5oW TQX70pvnGFRnyrNb8FoqA/+Qz1MlXAJ8dYBNgfrD9vcPImUkrk876sxpDQKTU4ADicdE N7YgrQJKxLdEI/TeNqLite82I3toLK4Pp55/UUx9jqmM9SNN27+tYquwMqaoKzl2KfkI aSNBtexa3seP1pv+Qcy/28vEH90nx+5IBR3lPm8xaNobZm0qrGUpc2I22dHVQVbhWfbP AavA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=j3cXdDXlXtGM24L87BIaZF4xE90ce3LP9T6Em1o+1lQ=; fh=rsyPs5++zRWUdwBJjayAHO9UPSDbEr3GvAcE35ykOZ4=; b=Q+YykLZgUAwwcdSrXO1DEsNL8AL6XlEuoAI3/VtPG4R8FukY18CGIKql5oDjAnH4Ng w5U5DRbymP6PEFL/uAm/ZeaEVoknna6/boQEgn2gXphp2+V1bjlYIyNUTL+RkBfCbWbw mc4P8cDJtdbjxvnlyXXVtXb6U0yCxd04MzcurbIxV+RH6xkJpKmfsISvZ7xGXEdhhqnG XoeHfLzPul7OI+SdI/vgh3VwBF9+0YyASiPO5h8lFbKVSgwcguDVHdCIt4ygPDOaJx6V tjKYa1i9d7lxHFjlmBjJlqIcFngrjWGvFEH/PeJR7cwp8ohDyY8uxahmEtVewVXvzpDu pI8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soulik.info header.s=mail header.b=f7HQiwHV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=soulik.info Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id kh13-20020a170903064d00b001b8698d28d4si3381768plb.512.2023.09.15.07.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 07:03:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@soulik.info header.s=mail header.b=f7HQiwHV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=soulik.info Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4B4518286E87; Thu, 14 Sep 2023 10:25:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240106AbjINRZ1 (ORCPT + 33 others); Thu, 14 Sep 2023 13:25:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239798AbjINRZM (ORCPT ); Thu, 14 Sep 2023 13:25:12 -0400 X-Greylist: delayed 80218 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 14 Sep 2023 10:23:59 PDT Received: from kozue.soulik.info (kozue.soulik.info [108.61.200.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54DBE30D2; Thu, 14 Sep 2023 10:23:59 -0700 (PDT) Received: from ritsuko.sh.sumomo.pri (unknown [10.0.12.132]) by kozue.soulik.info (Postfix) with ESMTPSA id 8A939300227; Fri, 15 Sep 2023 02:23:43 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 kozue.soulik.info 8A939300227 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soulik.info; s=mail; t=1694712224; bh=j3cXdDXlXtGM24L87BIaZF4xE90ce3LP9T6Em1o+1lQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f7HQiwHVtd/ry7I6rWuDVwqBBhIOJNqxgPOfm5OUGNQBvyUtJGWlR/GWnTxayr8jS 87hNlsfs/8WJRmeEhNfOtKNJYebCPtHmnpZ6V25MWweUUau2Do2oSpMQsHwFshOMdE pJ8Z1uvfTYn/EpR4KbSliash7sZsl23+qvtrtzNg= From: Randy Li To: linux-usb@vger.kernel.org Cc: Randy Li , stern@rowland.harvard.edu, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org Subject: [PATCH 2/2] docs: driver-api: usb: update dma info Date: Fri, 15 Sep 2023 01:23:24 +0800 Message-ID: <20230914172336.18761-3-ayaka@soulik.info> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230914172336.18761-1-ayaka@soulik.info> References: <20230914172336.18761-1-ayaka@soulik.info> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:25:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777112554085391021 X-GMAIL-MSGID: 1777112554085391021 We should not hide the recommend APIs in a obscure place. Signed-off-by: Randy Li --- Documentation/driver-api/usb/dma.rst | 48 +++++++--------------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/Documentation/driver-api/usb/dma.rst b/Documentation/driver-api/usb/dma.rst index d32c27e11b90..02f6825ff830 100644 --- a/Documentation/driver-api/usb/dma.rst +++ b/Documentation/driver-api/usb/dma.rst @@ -93,44 +93,18 @@ DMA address space of the device. However, most buffers passed to your driver can safely be used with such DMA mapping. (See the first section of Documentation/core-api/dma-api-howto.rst, titled "What memory is DMA-able?") -- When you're using scatterlists, you can map everything at once. On some - systems, this kicks in an IOMMU and turns the scatterlists into single - DMA transactions:: +- When you have the scatterlists which have been mapped for the USB controller, + you could use the new ``usb_sg_*()`` calls, which would turn scatterlist + into URBs:: - int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, - struct scatterlist *sg, int nents); + int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, + unsigned pipe, unsigned period, struct scatterlist *sg, + int nents, size_t length, gfp_t mem_flags); - void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, - struct scatterlist *sg, int n_hw_ents); + void usb_sg_wait(struct usb_sg_request *io); - void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, - struct scatterlist *sg, int n_hw_ents); + void usb_sg_cancel(struct usb_sg_request *io); - It's probably easier to use the new ``usb_sg_*()`` calls, which do the DMA - mapping and apply other tweaks to make scatterlist i/o be fast. - -- Some drivers may prefer to work with the model that they're mapping large - buffers, synchronizing their safe re-use. (If there's no re-use, then let - usbcore do the map/unmap.) Large periodic transfers make good examples - here, since it's cheaper to just synchronize the buffer than to unmap it - each time an urb completes and then re-map it on during resubmission. - - These calls all work with initialized urbs: ``urb->dev``, ``urb->pipe``, - ``urb->transfer_buffer``, and ``urb->transfer_buffer_length`` must all be - valid when these calls are used (``urb->setup_packet`` must be valid too - if urb is a control request):: - - struct urb *usb_buffer_map (struct urb *urb); - - void usb_buffer_dmasync (struct urb *urb); - - void usb_buffer_unmap (struct urb *urb); - - The calls manage ``urb->transfer_dma`` for you, and set - ``URB_NO_TRANSFER_DMA_MAP`` so that usbcore won't map or unmap the buffer. - They cannot be used for setup_packet buffers in control requests. - -Note that several of those interfaces are currently commented out, since -they don't have current users. See the source code. Other than the dmasync -calls (where the underlying DMA primitives have changed), most of them can -easily be commented back in if you want to use them. + When the USB controller doesn't support DMA, the ``usb_sg_init()`` would try + to submit URBs in PIO way as long as the page in scatterlists is not in the + Highmem, which could be very rare in modern architectures.