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 0A413C7EE30 for ; Tue, 24 Jun 2025 13:39:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AAC18D000C; Tue, 24 Jun 2025 09:39:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 659B68D0001; Tue, 24 Jun 2025 09:39:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 522E58D000C; Tue, 24 Jun 2025 09:39:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 350538D0001 for ; Tue, 24 Jun 2025 09:39:40 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DADDC16083A for ; Tue, 24 Jun 2025 13:39:39 +0000 (UTC) X-FDA: 83590401678.14.C348DD6 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by imf14.hostedemail.com (Postfix) with ESMTP id 1037A10000B for ; Tue, 24 Jun 2025 13:39:37 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=JUHjNRV1; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf14.hostedemail.com: domain of ptesarik@suse.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=ptesarik@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750772378; a=rsa-sha256; cv=none; b=EVWiXRTyWKP9nqFurecN3RDM73DPYa4Km3OHn8iBOewMsq8Kl/DRujcSCrZt6800/bbW1A Ozr1SAjE7LEwAAYAWpQo8mPr/CBkzkteC5Dv1EVSkQjV+5ebE7U/G12VVYPWucmuz5enl5 5o0ZF1Nj2OF0URwHUHcunoFZXXs1MU0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=JUHjNRV1; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf14.hostedemail.com: domain of ptesarik@suse.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=ptesarik@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750772378; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tmoyTuVu4akx78qVJi6bTRvxekKYdC1/i6FSJLO9Fsw=; b=5MhHX1sBIjJ/C1Kf3O+RcPAk6LtWB8UskWo5asEyyyypEdBXh1mf7C4gc5eeQeGMwVdxLe W4pJiGfUJQ+Ca4NRhbkOBgCVZtn09JcQSGHAsOF1zEejeQUV7aD8bci22vZVs/9WFaMuia GvnxJvHLFU8+i84Zu1IcnHF+efrNMTk= Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3a4e62619afso688221f8f.1 for ; Tue, 24 Jun 2025 06:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1750772377; x=1751377177; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tmoyTuVu4akx78qVJi6bTRvxekKYdC1/i6FSJLO9Fsw=; b=JUHjNRV1tOCkRSA0/1rcKHTZzNMf4FOngwJjIdCvRpVVB59+E0pJNxEVctaji0LoIK 2mIOXGLxwpr7eDRGJCSe+ceGErw39q7Mky60e0CbTAhZzKZEIT3NxGoWuq3UvFrSdQD5 u/CgRKOIkwIdmqhvQn7sU+A7433ZROzXDoWq25ZpTFzpR+cqiJ55rD0U4VP7IOc1FHX5 YxC+5rMQyuTPLI2fAJg7PDu3KVn6OlKNqoEsucW51i2BAyVFIsl/xv9QKOaT3+5kX1tL c8U0ieOGqAQpdc0Q/VSmWfjhOqbvIkaJp11Ab9kxR1PNN+1tjEQ6iaceEHVTIhkSHKzK JwmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750772377; x=1751377177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tmoyTuVu4akx78qVJi6bTRvxekKYdC1/i6FSJLO9Fsw=; b=muSEGula9ZmhnP6qEUt2A7asa0Wtreh90WewyAvaU4wyiyaKJCMVNoh2Op36xb+eOb WJF4E/4nMj2VSPsRN7t4T/glXEoqiXhvv4w50aRGnKp60Fb5xR7RTHO7mzGdpTWHWxOc q+EAYZWXxtyOfabcLmQIqjafodz7ALz0802/6ovadzRhcIV+Ye02GF8+poQLjbzdYxLq /++vf8w5s1MKk8zJPl/5qyVBczctpdP9wvMnLeii8cZr2bGI99RbdhlL/+Rin+OpLhgv zwJKOrDeMi8zFKuUp9cPJZd0YgpD7kIfLgNdiKj+knJe/d8gRrN0aaDCHfHRt3WREF+o gxFg== X-Forwarded-Encrypted: i=1; AJvYcCVmNWnMoRMeo6FGEYMw8p1v/YD1TaUQzatlfYjNrbTOm7sLuSZt4FyMryv0h2M8BlUQxHGAHaDgGg==@kvack.org X-Gm-Message-State: AOJu0YwAXq2hJ91xcUisGtK39lnEn1OYtH64P5qw1hSKoDBv7Rd09zDZ 8IydpUS4+sZ+7UBfT9veGwcLGA3fMT15iQYrFm3JCDv/qqBfdb64fZau8QMtMEud5zs= X-Gm-Gg: ASbGnctCiF1mYIDtBIdmdW6NDKl1z0pJyzQDeE8xiujqOIenUy5J+w13oDA8BsOvKBl KGFl4sKIGPTucTDfN8X0utxCYOJDHQLgnyxcHyhknmoblk1/Bnq0XK835oUspPEOEn+Q6VwustF Hr+L0wMp2iP9IVeEavwG29qmP7WIMuvYjFbEusl39MbCpfK7UmlS51YDAm7hpIcpUwAx8HtB2QI 3fy+es7vvlH7CCZHlR4nUxre+IIEKxmhMyuwx6o9s4TDKH5fXUb6QvFy6kRlWYx760Hg4UhRP3A oQ9tkEi81OoKULv2KhC3Q93gm/WL6WttSVdQEb8Etm7iWax3erwD29CQz6YyL4a/zrveacHumSI LUF0/YnQj7HUoXr+mLJMDQXnmihsFOJOBW66swR/EZsYEEhTFhF7F X-Google-Smtp-Source: AGHT+IGkZrplpRBlcgMXcjw1DbH2uA7Xgft+a5isw/zKi2IcP2PXv5geqjz1FHC5se+KenSl4WGZcQ== X-Received: by 2002:a05:6000:4412:b0:3a5:7895:7f7e with SMTP id ffacd0b85a97d-3a6d12ebe7fmr3683192f8f.15.1750772376600; Tue, 24 Jun 2025 06:39:36 -0700 (PDT) Received: from localhost (dynamic-2a00-1028-83b8-1e7a-3010-3bd6-8521-caf1.ipv6.o2.cz. [2a00:1028:83b8:1e7a:3010:3bd6:8521:caf1]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a6e80f2274sm1961890f8f.48.2025.06.24.06.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jun 2025 06:39:35 -0700 (PDT) From: Petr Tesarik To: Jonathan Corbet , Morton Cc: Marek Szyprowski , Leon Romanovsky , Keith Busch , Caleb Sander Mateos , Sagi Grimberg , Jens Axboe , John Garry , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list), linux-mm@kvack.org (open list:MEMORY MANAGEMENT), Petr Tesarik Subject: [PATCH 6/8] docs: dma-api: clarify DMA addressing limitations Date: Tue, 24 Jun 2025 15:39:21 +0200 Message-ID: <20250624133923.1140421-7-ptesarik@suse.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250624133923.1140421-1-ptesarik@suse.com> References: <20250624133923.1140421-1-ptesarik@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1037A10000B X-Stat-Signature: tb5zmqzdzw17tdryxqjzy4xe7gqcagks X-Rspam-User: X-HE-Tag: 1750772377-6002 X-HE-Meta: U2FsdGVkX18ECJPOYT3i2j9n/AQ8H/wNhbwvXV5rRAa9g9BQLvBb1sKSbLVtSx0WEyQIwQPumQ8zaDsOL308+foKpx8XsFep5/QC8UFKUutUJSTBuGP4dfX47eee6CWOw7tEInnBdEbXN/Wmcjy8Gxt198vtj1OsCYfJcGxmRwSEVfaV8SlV/5MuOBvQSuHa82S79tETDalWiuaJbwXURJxUue8w17+n7x1PlJBsTK6uR1GpOb4+uNev9xdsB/mwRNosiCUIbCmcs8jJ1y5KmD3JO+LKrhyqFduFC4DrIj2Bpe+JxZ3B7IvkOJz/JgYhDZfVFwaSDHQs3NAJDTTojiVhKUqC9IKErRg4hZKaTK3viTRl3j8tI+xsNGuYGLV4kb+fcTT4NMslvR3EDSiIXFVk9XMSJw0uS4y4Th2bYeuQIEG16Eo2EV8nJUfY7f1M6O9bYzBr/ER9lq0AFitrAoVcjoU+g9sNRlyoRZ7HOod/ul+LbYPPeMZhjaOXiOmVJRVGhI6MmKPj21ObGcTtFj/DEkXHkQbhDP066C+W7mPjjiEjZ9T3sjo4HJwxw0B2k349Mq2Ai++RPf4jiz6C8ScACMIKxgMfmXpJGChxq+rgDy6W1j5IHExeBsdAdrqh0XYj38rxlyd4wgfmUboAOy30JG4GweVN/SzPWAs38lNFr4J5MxuP7opS+ThbZzhEiVhzS9p9oQY0Y7HTSip9OEi0qNFop8aziccbKw2AlzzJzQorHwfmsqy3XqmILA0wIWmPacLXxE7o0bf/wsOy0I671vOEdUVy+DiSsUFBnj4WKYdE+WPRTeguOlJXJAGBOE0Qbyt+4dtXLuARdpmfLSApl41MJunfraMN4dVZ7B7yBPoTIzHi59XUIJJ/5Oigx7UhaiiE0Yv9wku0N4I8/7qtdsQJdXFNowmgsAH/Fo5XN5IRlpwDd2GvzQ8yaY42GH6mzmbsRHaGYzoigZ7 qd71AdUP DsZyrxrgs9izkih3sjyKyGCZ0QA== 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: Move the description of DMA mask from the documentation of dma_map_single() to Part Ic - DMA addressing limitations and improve the wording. Explain when a mask setting function may fail, and do not repeat this explanation for each individual function. Clarify which device parameters are updated by each mask setting function. Signed-off-by: Petr Tesarik --- Documentation/core-api/dma-api.rst | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) 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 ------------------------------------ +DMA mask is a bit mask of the addressable region for the device. In other 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 mask +cannot be used with the device, or if the device is not capable of doing DMA. + :: int dma_set_mask_and_coherent(struct device *dev, u64 mask) -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. Returns: 0 if successful and a negative error if not. @@ -105,8 +112,7 @@ Returns: 0 if successful and a negative error if not. int dma_set_mask(struct device *dev, u64 mask) -Checks to see if the mask is possible and updates the device -parameters if it is. +Updates only the streaming DMA mask. Returns: 0 if successful and a negative error if not. @@ -115,8 +121,7 @@ Returns: 0 if successful and a negative error if not. int dma_set_coherent_mask(struct device *dev, u64 mask) -Checks to see if the mask is possible and updates the device -parameters if it is. +Updates only the coherent DMA mask. Returns: 0 if successful and a negative error if not. @@ -171,7 +176,7 @@ transfer memory ownership. Returns %false if those calls can be skipped. unsigned long dma_get_merge_boundary(struct device *dev); -Returns the DMA merge boundary. If the device cannot merge any the DMA address +Returns the DMA merge boundary. If the device cannot merge any DMA address segments, the function returns 0. 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). - 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). Note also that the above constraints on physical contiguity and dma_mask may not apply if the platform has an IOMMU (a device which -- 2.49.0