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 CAD7DC77B7C for ; Thu, 26 Jun 2025 01:47:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37F5D6B00D0; Wed, 25 Jun 2025 21:47:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 329236B00D1; Wed, 25 Jun 2025 21:47:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 266906B00D2; Wed, 25 Jun 2025 21:47:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 14CF76B00D0 for ; Wed, 25 Jun 2025 21:47:54 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8A1DC1A0867 for ; Thu, 26 Jun 2025 01:47:53 +0000 (UTC) X-FDA: 83595865626.21.EBC7A41 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf07.hostedemail.com (Postfix) with ESMTP id 947AB40004 for ; Thu, 26 Jun 2025 01:47:51 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ayQbmhNJ; spf=pass (imf07.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.214.170 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=1750902471; 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=oeEe2xDl4J3QKXU3s6+5yOfkNnMzI/iOfTI3SJ90Emg=; b=e7BcshdnPHBFv8qV7fWGWB2rfkoWghuTh33KVjq3ykvd+j5IVWFxkvni+VwHgrc7cwWBvY wrCvXJYM1xHelmxKMwNoeChmR0tCsYnLHJsI0QRqZhr+qxS4Xe9pfx6X1v4zvWMQU04624 PTayiRSZhpaWloJP7zKVBZUabejbE8g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750902471; a=rsa-sha256; cv=none; b=kBxwEW8dOY37giSDEYq6amGXU+4Fg8jdqA/xE8nLxndalEOUKJvGY1h+Mxw8AeH7unrhnn 0uR6aczXhRK30M6u+ItJH840B6ePVXKab50YmjWBNIzNnlq0/J6yAAcw4LOv6ABflImVPJ BATFE1jcxOTAW1e5oDvASC73qDQ+w3U= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ayQbmhNJ; spf=pass (imf07.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-23633a6ac50so7223545ad.2 for ; Wed, 25 Jun 2025 18:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750902470; x=1751507270; 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=oeEe2xDl4J3QKXU3s6+5yOfkNnMzI/iOfTI3SJ90Emg=; b=ayQbmhNJAHhsGSU2dmAfmLyMJdetTAuPEXrCN96ZcUIkmrsBguqx4MZyaG+NYtFW87 bcPrdNG+EeUYNmbc8rbWuD1/9aT2RYPSXd3/DzZBF6QLSK8SJDeajNY/dO2euNNbS5xe cO+xsFmYWVt2uL50ErHp3Cv1KE9sK3FjPJkRPYnL/VF8gUWpyufvXUuT49W/FMPwxsrm 2Igq6jLMxXm98gZbjVmuyHh9c2fw1QIA8AcQhDOqwNHg8n9Irfw/y8AiNl95wfMxc86Z SaCudCS+hPS4YuuRyRcIoIWiOnGdikkygwomg4q3fNKvvmcF4Z8/L48MVTv3GKPmxPcc BVOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750902470; x=1751507270; 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=oeEe2xDl4J3QKXU3s6+5yOfkNnMzI/iOfTI3SJ90Emg=; b=VB1fgvCAqRqw9BsU/lsjYYYbV5vYO1X/ZZ2XZA7IeioSTDrYKeMSg7azXi5O1WjvBx YFqzoYdP3jRkicEBx1NOHmDZBj7J1qjHGZYLJ0KBuu1G2BlJnL+DjIZcYzvxjLzCRNO8 2z27Y3rbqRLEdayA2JCMgGgr0tm2sc3rF0uE8i40bddJQ0Potny2BrK2l8KqL0MYz17g LO7jxT8gO8R5iSuguoBQrHlsZgrQeGghZWf2L50LRPZVkQ0e7xT3/FBi6UiY1B8hW3AM eF/EuxhTNOaGt+Z/69UVdTAe1KEXn2qKkEeL2D79nTz3Z6uN6lAXQxPgd7Zz9SmZCg3n rOWQ== X-Forwarded-Encrypted: i=1; AJvYcCXstUv3Ke7zPAI+HPJOHSJC3eXXe4UhzUWeSOoMjDOxx/zkoWOWMq8DWUKZ4kdVWs5ecyJnjVVrlw==@kvack.org X-Gm-Message-State: AOJu0Yyi4iuGZq4wpu2YNBbxJGuT0tL9qBGQpWtx+jYSyFjVUUtO2mrU bRaLUA8xaL9w4YTo+bXDPpHs4ABs0OQ6Aaf4CmtnNCFm32DNZV5gG+pe X-Gm-Gg: ASbGncsObPb6igPHaGBqh3isf2Pt54yzGYZL+ZcaZd+ras8UYSyG990MDrEReGi47Cr Q50aFzbsTP9KrSpxmfjlQX5AL9aI2xF3txfSqCvMshWq1m+QlsD+IUytkoVpr8e9fKqvuGKKPP6 Zk70kWtdgv13RKTCogetyEic7a5mFUTGFaPAt525LJOFM07TWdBg+RTchPnH+7X8hcoo9DxWkQ9 KR2x06FGgp5M0YsFQk1PbW4LLBz4hJzvdxjJ/pOWNNidkXv28rXS/mvv91VJHGpcuSUtxZ1Gwdo lk7lrqkOoyN8v+h8N58q4383gJUigR6xRDOUFzkhsy3vqwa840j6FfdeQw+x3g== X-Google-Smtp-Source: AGHT+IHUyuL8SGf3zYTOKdOAHOCLsm1QeirLg59dt/DDUrPTSwKLQ+Bt6deh6FLvwy83L6KVHx7/Qw== X-Received: by 2002:a17:902:dacf:b0:234:8e54:2d53 with SMTP id d9443c01a7336-2382406d49bmr84147085ad.45.1750902470390; Wed, 25 Jun 2025 18:47:50 -0700 (PDT) Received: from archie.me ([103.124.138.155]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-237d8398dcbsm143408545ad.48.2025.06.25.18.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 18:47:49 -0700 (PDT) Received: by archie.me (Postfix, from userid 1000) id BB6FC420A9A6; Thu, 26 Jun 2025 08:47:46 +0700 (WIB) Date: Thu, 26 Jun 2025 08:47:46 +0700 From: Bagas Sanjaya To: Petr Tesarik , Jonathan Corbet , Morton Cc: Marek Szyprowski , Leon Romanovsky , Keith Busch , Caleb Sander Mateos , Sagi Grimberg , Jens Axboe , John Garry , "open list:DOCUMENTATION" , open list , "open list:MEMORY MANAGEMENT" Subject: Re: [PATCH 6/8] docs: dma-api: clarify DMA addressing limitations Message-ID: References: <20250624133923.1140421-1-ptesarik@suse.com> <20250624133923.1140421-7-ptesarik@suse.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BITuZ8ddHLuJ6SPc" Content-Disposition: inline In-Reply-To: <20250624133923.1140421-7-ptesarik@suse.com> X-Rspamd-Queue-Id: 947AB40004 X-Stat-Signature: fd1jb5qfudkgit4fceh1q13mmejim1cn X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1750902471-201398 X-HE-Meta: U2FsdGVkX19/yYnLcKfJMzIj6YKKz9zmMI1OrRNu/7LIPbP+R+1Njjtxowuu6vtMa/Eg2GcSQI8QJV1pz4aiHDWEsYtpQDcr8VYhIqmo7gZLXYnZk7qTLFP0A01MXGqQbchIUsESZ+JkdC7iuS3UHfVHnqXRUCOOgpnwR+SZmlg4pOSlwpH+fPpkVQ8IhDfZ+vy3XY2M5Z6rH7CrnM6oRUhnVtRg+vf1eXWZ8unFC/Z0bqDzAroLpOzgk4VgBW213iaNbM1RI1X7FrDEq3lYO0bD9mnLCueyNH5mfZLfZIfN6SctcShW8AaZbulWLGYr/UhxO2Ma6pH92t8m6smmw4Htufg21lu4HaxCZpS0zcxNWwavvh7H+VXTR7F/ZQvLOfiyT50d8kV85Ljqx7eQRnUVJ95B5XelHAemRG+s4w371JDOTsu0/5068jtnD7fXfu1giRQCYX7bkVAgdmDvQgwtRQumgxFrCLp3CVtdETU+5bsRB6bEfBlIcwiU1TqpAESiybGLhLcFYG5AaDVtWHA/jjNdMKtQe8EFqJiH86HSzleNkakifJz8UsapuwbNsLOaNuFWRCtB1+Dp03dg5RDe45DlAD4EiZD+j7RBkrfXU2rDfV9Q+lYyJkjIr9ijuXaLmNkm/KZGBiezQvOsby+dzXasjeyC75VOoYTnEheZGz4byazduWCc3n/ZqPkFCpUWbzoMK3Dkt5dbm5dzH7zhMC5UISVYqJq10ksZ1VI9b5iv5brhPMmcBk5Dpyi9WyHIxgaUfZs8MZ8ZheJZ16kHlHcWv91j10Rz5S3kmQ5Nrbj8duPTh1HizTb/BJWR3KHUPaAv0bwYYVLdSJG5mrs4k3Ue9WerfGf1KC83SxwJQk9UetgeyZ0jFmcLhnbFrpnU5ujX7SkUe7XImXKqpp+8IKqQWf8SabMmtJH2BBttbUNZ/cUKLRpXCHBMo6+lLb293rI5Kfa4Zz37sh5 hRDedBfc kOn7oPP6SoX32HkJd6txrHmac3uyVRGOvnALKxx0zynaXPGysyERi6tq2iyL7/l4tlpWdlam6C9Zfi5mREYO0O+v+eeq4Vwls9UpUnZQVmGHSouHAefxVgvQ4HtaD6xdAmEqaha7ciKHMkGFv4mia++4MIcnjlpEgn59sCdF+9JxqMq8Tg7JS3HN9HeKN7Pqaxg8Ob3wylckKFR7Hid8OvOH8FIgwbU5d1YAjrxZnl+ftj7dXooWJaTN9+omr5yaAAxb4rXLaKXFFeMy4UffGn5/AWMQZfihfoskwjDE/wkGuaKSG949bYfsJkuwN49Ew5GCmf7xZWKNtK4qjoaX0QS2m/4FDrqgfY49La+BedlFQCqznyLF+txe3WOSRFgT/0M7VodKZQrrsFKeptnamqpjAsGhiPx2dc6MnMTAfyvxykMQBk45S9iw/wUN208mp50rT5aDcn3f27ppa9ei+4Rn0MZ8PLNYng055VnQ61L34v1jYdebcbdeIcijMSkiTDzOn1H0Tn+zDyo8= 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: --BITuZ8ddHLuJ6SPc Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 24, 2025 at 03:39:21PM +0200, Petr Tesarik wrote: > diff --git a/Documentation/core-api/dma-api.rst b/Documentation/core-api/= dma-api.rst > index f7fddaf7510c..cd432996949c 100644 > --- a/Documentation/core-api/dma-api.rst > +++ b/Documentation/core-api/dma-api.rst > @@ -90,13 +90,20 @@ description of the DMA pools API. > Part Ic - DMA addressing limitations > ------------------------------------ > =20 > +DMA mask is a bit mask of the addressable region for the device. In othe= r words, > +if applying the DMA mask (a bitwise AND operation) to the DMA address of= a > +memory region does not clear any bits in the address, then the device can > +perform DMA to that memory region. > + > +All the below functions which set a DMA mask may fail if the requested m= ask > +cannot be used with the device, or if the device is not capable of doing= DMA. > + > :: > =20 > int > dma_set_mask_and_coherent(struct device *dev, u64 mask) > =20 > -Checks to see if the mask is possible and updates the device > -streaming and coherent DMA mask parameters if it is. > +Updates both streaming and coherent DMA masks. > =20 > Returns: 0 if successful and a negative error if not. > =20 > @@ -105,8 +112,7 @@ Returns: 0 if successful and a negative error if not. > int > dma_set_mask(struct device *dev, u64 mask) > =20 > -Checks to see if the mask is possible and updates the device > -parameters if it is. > +Updates only the streaming DMA mask. > =20 > Returns: 0 if successful and a negative error if not. > =20 > @@ -115,8 +121,7 @@ Returns: 0 if successful and a negative error if not. > int > dma_set_coherent_mask(struct device *dev, u64 mask) > =20 > -Checks to see if the mask is possible and updates the device > -parameters if it is. > +Updates only the coherent DMA mask. > =20 > Returns: 0 if successful and a negative error if not. > =20 > @@ -171,7 +176,7 @@ transfer memory ownership. Returns %false if those c= alls can be skipped. > unsigned long > dma_get_merge_boundary(struct device *dev); > =20 > -Returns the DMA merge boundary. If the device cannot merge any the DMA a= ddress > +Returns the DMA merge boundary. If the device cannot merge any DMA addre= ss > segments, the function returns 0. > =20 > Part Id - Streaming DMA mappings > @@ -205,16 +210,12 @@ DMA_BIDIRECTIONAL direction isn't known > 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 (the dma_mask is a bit mask of the > - addressable region for the device, i.e., if the DMA address of > - the memory ANDed with the dma_mask is still equal to the DMA > - address, then the device can perform DMA to the memory). 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). > + 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). > =20 > Note also that the above constraints on physical contiguity and > dma_mask may not apply if the platform has an IOMMU (a device which =20 LGTM, thanks! Reviewed-by: Bagas Sanjaya --=20 An old man doll... just what I always wanted! - Clara --BITuZ8ddHLuJ6SPc Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSSYQ6Cy7oyFNCHrUH2uYlJVVFOowUCaFymwgAKCRD2uYlJVVFO o7rxAP0ZAy7lZM118PZvIR9Mzi0gfM5j+SZoiRLHRS/Zy5z1kAEAn7A9H4kowyXC g8MS770xUyWQOX9UL6zHv1qIaH95ZwA= =2Td5 -----END PGP SIGNATURE----- --BITuZ8ddHLuJ6SPc--