From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEA10C83026 for ; Mon, 30 Jun 2025 01:32:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 430076B009C; Sun, 29 Jun 2025 21:32:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E0886B009D; Sun, 29 Jun 2025 21:32:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F6DD6B009E; Sun, 29 Jun 2025 21:32:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 144BA6B009C for ; Sun, 29 Jun 2025 21:32:32 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C097B1402AF for ; Mon, 30 Jun 2025 01:32:30 +0000 (UTC) X-FDA: 83610342060.25.4806DD3 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf14.hostedemail.com (Postfix) with ESMTP id C75BE100004 for ; Mon, 30 Jun 2025 01:32:28 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SVXHnyA4; spf=pass (imf14.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751247148; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Gwxo+Mz3IvrzaosTpE+nrtogxa++aPCEgx5JYVoi1DE=; b=aupYHkeGjbssaYPj8zLz0EU0ZvZKCzyu44zxHvgajclejf7VqW7mmuuSlMnYzO48xM5UeF Ats192N42yakzXB+U8n2SrpOD0ZJu/M166G+FEeEWUCw2iUCD71TtDwTXLpxiQXtfFoO9e NY1dMl0EH00AEDAarnzjJ3Kw8d7dMJU= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SVXHnyA4; spf=pass (imf14.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751247148; a=rsa-sha256; cv=none; b=QCVHy93BdCXU0AHMPlFcJpOxTsQ/Sqilz8gURKURnJCWJfi4RN5y3a9M4CAL3WOBzwka4Z KLIBAiJJwWIOxBKsdSie/mv1he8ycB4099AtyWtphrFMVjylxllNv1EmKrdH2YedoupLpT h8kT0G7GHMwzaveJ1fEMgHLq/9GQyd8= Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-311d5fdf1f0so1065013a91.1 for ; Sun, 29 Jun 2025 18:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751247145; x=1751851945; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Gwxo+Mz3IvrzaosTpE+nrtogxa++aPCEgx5JYVoi1DE=; b=SVXHnyA4cc1eSS39ZxN8q+S/pE1bdji9ZNXRJ+LRlK2Bx2o+cluad0GtYlZxN4Lrkl vQ0bQECaUGaNy7nBjt0aPggNmWGM2XZT80aDS4eif4TMMphrZ7wIrvd10oc2U+sM5Qv8 J0RigV0SBxhZ4seXnB/VP//v2rmSdc/TABdmSsEOFzDPw8lDI4A4KMXKlS48adxtZ5FF BSn7L04HPiBji3+jGuq74EJPyOS1/RpoUISrgmX6iN6/Ill/VSep1pUYMeMmbJOk92Hn N5zzARMtoXN+YQrPRbJnV1eezlVh9sBxIc32vhLjwrLUiuhMRc5Ziad23nyU9ITaMMWE GYIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751247145; x=1751851945; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Gwxo+Mz3IvrzaosTpE+nrtogxa++aPCEgx5JYVoi1DE=; b=p2nKpAKMsCUeq/Rl4LPKL03vRpVX9DPmw+KMLI8RoOKYHtrpoRTg2bS6QODqak3i7e EptEi96YGkRdfn7wVoX0ECg109lTnZyAkJeySTPxFViki5mbj9JGOERbc8sXPWfUCMTn R0j/KQARgl1uJ3gTR1HWqgnt6koUT7IUw/YZgDs34nXoQNx820GR755Hui5MI9RLfgnz dqHozsp4zRB8m+OqBAU9PrdWysbxor2QN2j2WDwgTuen/w+drx1HFlM5cyu/FAd8CdFo N4jEOZh6iieC4xESYo2BtnhMha2bHaBZ1QiDtJIdZfPiTsDsIeHwuFchAloweeOevy4w YVaA== X-Forwarded-Encrypted: i=1; AJvYcCWeUYXwS7dC6M6bsKVHE4m9IPwb1hSB4GDzZ5DkZP8y2ILnRTXIh0b/LtWvZVN3q8YgvfO8mTfXfQ==@kvack.org X-Gm-Message-State: AOJu0YyE+rQvmxG/CNbj8d+UgH0ktIpoomJc5MtxP+eRuI2DjtULQ2yt nE2lYhiV5WwjXCpeRB/zhLylGNd3qfTD+iN7JTjN+TkCCkxzjvVw8mHu X-Gm-Gg: ASbGncudAk5NB8GxGLaiESmPOYWHmDuMec9aA8hSf5x1X/zftd7leSq4kN4ZDirs/Kx pv3g4xqhi7L9gWspfEO6AjaF6knCq/rUu+qaAVInB5pnatPdgjO9iUXPLggkZPhRh/aNmu5KmNc UWi4Ikkj6+BENL76CUlPXKWkpR0YsO1dw5tTjZ5eyD6Gr7jqX432SXTE2vS1Vey4hjkg6MqJyY6 z8mZBzdeXwqG6basbixEM+G2+oDowfKHDPdJNuQDbKhAU3eK6H4TMQIWf7PjyhLDnKHo9B1AlCh GRrAvT3tzfn/UvJ0I10rluEcWJSVLQ4YOACgaaQISrQ+WJwSxIImX4IQe4FkgTlB/KQLM986 X-Google-Smtp-Source: AGHT+IFZCO9JUwt3uc3yB0stvOczNjE1Z46dM+SWxPKuf+S1ol8ZiAtkuzHavPc/X4mafB35eylK+Q== X-Received: by 2002:a17:90b:1dd2:b0:311:b0ec:1360 with SMTP id 98e67ed59e1d1-318c92f26abmr15843348a91.29.1751247144552; Sun, 29 Jun 2025 18:32:24 -0700 (PDT) Received: from archie.me ([103.124.138.155]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-315edcfd75dsm3332769a91.1.2025.06.29.18.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 18:32:23 -0700 (PDT) Received: by archie.me (Postfix, from userid 1000) id 951B5420A813; Mon, 30 Jun 2025 08:32:18 +0700 (WIB) Date: Mon, 30 Jun 2025 08:32:18 +0700 From: Bagas Sanjaya To: Petr Tesarik , Jonathan Corbet , Randy Dunlap , Robin Murphy , Marek Szyprowski Cc: Andrew Morton , Keith Busch , Jens Axboe , "open list:DOCUMENTATION" , open list , "open list:MEMORY MANAGEMENT" , iommu@lists.linux.dev Subject: Re: [PATCH v2 7/8] docs: dma-api: update streaming DMA physical address constraints Message-ID: References: <20250627101015.1600042-1-ptesarik@suse.com> <20250627101015.1600042-8-ptesarik@suse.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HrIK/LW9hGVtLpKi" Content-Disposition: inline In-Reply-To: <20250627101015.1600042-8-ptesar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DRUQkYgCHU95dixBlIjUALPm+9ieO3E sypl5+96 izhuX1rvsUGDW7evGRWnOb3ZGnelrLkQ3YJgr9Pw0KjnCiQoRm/8k2RTzX9uuYl+Xwmas6E86G1ivS3vMD2ulrtdmngF0/GpQyx64nK3keSRxbBjzS65mMAx9cgtgnSXI+HEh3pNDWTNjIveuaRd3jOyjb7HUhhA1mH7XimumHR/dHXbNrzipMAjND37uao+oDdLm62T3prC8OuSi2ETCXdGPaW1De71/aq2JECWQb5v3YHJyRcyRcT7q8AUHjCCJrCcr/2xNqZASka+3+SYgcD3DJnAgOe4fUs0vpELYKmYhw7HRoVXOKVMh7c13KBC3IbZldZgzfrb252fEHFpJUa9EE9+fdIwwuokbLJm560vD0R/wWZGD9SC+2dXtdzBtFchBHcSufSc3WLmMCjcAYCpiGn/CZvrip478xsyQSyHTJw4iFpJ7f1orfpR/2a20x+1DNqtcCbnzd1ZDMKTtAHQ+YCoP1DC37hC8W+WDIe5I3trQZLFCvxZAA/it6UXpqh+E6gELF+zdQcQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: --HrIK/LW9hGVtLpKi Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 27, 2025 at 12:10:14PM +0200, Petr Tesarik wrote: > diff --git a/Documentation/core-api/dma-api.rst b/Documentation/core-api/= dma-api.rst > index 9fcdb160638e0..a075550ebbb54 100644 > --- a/Documentation/core-api/dma-api.rst > +++ b/Documentation/core-api/dma-api.rst > @@ -184,6 +184,26 @@ segments, the function returns 0. > Part Id - Streaming DMA mappings > -------------------------------- > =20 > +Streaming DMA allows to map an existing buffer for DMA transfers and then > +unmap it when finished. Map functions are not guaranteed to succeed, so= the > +return value must be checked. > + > +.. note:: > + > + In particular, mapping may fail for memory not addressable by the > + device, e.g. if it is not within the DMA mask of the device and/or a > + connecting bus bridge. Streaming DMA functions try to overcome such > + addressing constraints, either by using an IOMMU (a device which maps > + I/O DMA addresses to physical memory addresses), or by copying the > + data to/from a bounce buffer if the kernel is configured with a > + :doc:`SWIOTLB `. However, these methods are not always > + available, and even if they are, they may still fail for a number of > + reasons. > + > + In short, a device driver may need to be wary of where buffers are > + located in physical memory, especially if the DMA mask is less than 32 > + bits. > + > :: > =20 > dma_addr_t > @@ -204,27 +224,13 @@ DMA_BIDIRECTIONAL direction isn't known > =20 > .. note:: > =20 > - Not all memory regions in a machine can be mapped by this API. > - Further, contiguous kernel virtual space may not be contiguous as > + Contiguous kernel virtual space may not be contiguous as > physical memory. Since this API does not provide any scatter/gather > capability, it will fail if the user tries to map a non-physically > contiguous piece of memory. For this reason, memory to be mapped by > this API should be obtained from sources which guarantee it to be > physically contiguous (like kmalloc). > =20 > - Further, the DMA address of the memory must be within the dma_mask of > - the device. To ensure that the memory allocated by kmalloc is within > - the dma_mask, the driver may specify various platform-dependent flags > - to restrict the DMA address range of the allocation (e.g., on x86, > - GFP_DMA guarantees to be within the first 16MB of available DMA > - addresses, as required by ISA devices). > - > - Note also that the above constraints on physical contiguity and > - dma_mask may not apply if the platform has an IOMMU (a device which > - maps an I/O DMA address to a physical memory address). However, to be > - portable, device driver writers may *not* assume that such an IOMMU > - exists. > - > .. warning:: > =20 > Memory coherency operates at a granularity called the cache The wording looks good, thanks! Reviewed-by: Bagas Sanjaya --=20 An old man doll... just what I always wanted! - Clara --HrIK/LW9hGVtLpKi Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSSYQ6Cy7oyFNCHrUH2uYlJVVFOowUCaGHpHQAKCRD2uYlJVVFO o7BTAQD2guhFoVk0F3IFsbTS/6Ol/17jQ8zJ8Y1DrFSsn2CrUgD8ChTz5+jY2xNj g3nM93NHjiM4P2S06XM2BOx7i7nPXgc= =aOWE -----END PGP SIGNATURE----- --HrIK/LW9hGVtLpKi--