Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp39666rwr; Wed, 19 Apr 2023 03:07:20 -0700 (PDT) X-Google-Smtp-Source: AKy350biFScRx2ZiWaC8I0DuPWDNwSZBYNvGrzxpuLHJ+2c9Qy+AxOkfY+jC4MyPaLJ+lrd3JvOj X-Received: by 2002:a17:902:db01:b0:1a6:d46b:dfb5 with SMTP id m1-20020a170902db0100b001a6d46bdfb5mr5559066plx.26.1681898840539; Wed, 19 Apr 2023 03:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681898840; cv=none; d=google.com; s=arc-20160816; b=QnzJUqSnKpbYq/coVIymzV/MWwQB1xrKECu7v6uinoH8zvT9c30YruAMd+TSbGetyi H0ehJmj4SZW8P/OQuKrHhw1nhbBAcSlIfMSlx8wJaRneQZA2UbV66Vb33TSAg3XwRtsE xNMJEyP6c0zbTut34qRz+Aydq/F5ty0TrV7BnmNjnzJjUquc4jqEH7ysjSS8qIk78G3E 8Zke5aKcMBcuuwv4WgDtrYW4OTdexmooWehwRImeyGPZJ7zEstg05O6x9TiiQkH/Oyc1 uErkjbOaV/ins4dp8dB7wcAaH8ERwUdK7K0XbrKbGUfuF+d0rsadCs4+P9dVBxaAOVCU gWsA== 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; bh=Y45VeXFx+dKJiHYvCdPStPPQMCBgSu0eRYMwrvbrj/o=; b=xk+GIt/fwuqEejZCcdq4zGAqDOKqUCPTD6LmqE3qC83iEvC+fSvazTumsV3Qn+ud9i s7MSpQZ5CI4lMBhOSedQrGC/Wci8/tZPDNWB5k5ZeMMc9pubpim73b2HeQssM73WFCJM uhYHqUFb16x+h+EZpo1XF1dr2qoVSHFuurXd3OcAGwhSCTI9nEkMKin98ubaYU1nrQbR VLV+77VyKpYIPp7IvAS76gleMARCXYnPk/6D8nmPu/KrKos1VVJix/sEbTGAQwU4jSve azuoMGPciDLlsKRaP9EfFJwg5uebr38I5N55RredFY5MSWKSmvNJGADoL953Xz76iy1L 1u0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t16-20020a170902b21000b001a68270e55asi13330818plr.526.2023.04.19.03.07.06; Wed, 19 Apr 2023 03:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232982AbjDSKGc (ORCPT + 99 others); Wed, 19 Apr 2023 06:06:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233007AbjDSKGU (ORCPT ); Wed, 19 Apr 2023 06:06:20 -0400 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 180A0B746; Wed, 19 Apr 2023 03:06:10 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.227]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4Q1bm42MkWz9v7GZ; Wed, 19 Apr 2023 17:56:36 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.45.152.239]) by APP1 (Coremail) with SMTP id LxC2BwAXi_aYvD9k7TY6Ag--.1944S5; Wed, 19 Apr 2023 11:05:26 +0100 (CET) From: Petr Tesarik To: Jonathan Corbet , Greg Kroah-Hartman , "Rafael J. Wysocki" , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Borislav Petkov , "Paul E. McKenney" , Catalin Marinas , Will Deacon , Zhen Lei , Randy Dunlap , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Muchun Song , Ondrej Zary , "Jason A. Donenfeld" , Petr Tesarik , Hans de Goede , Dan Williams , Andy Shevchenko , Kees Cook , Thomas Gleixner , Won Chung , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), iommu@lists.linux.dev (open list:DMA MAPPING HELPERS) Cc: Roberto Sassu , Kefeng Wang , petr@tesarici.cz Subject: [PATCH v2 3/7] dma-mapping: introduce the DMA_ATTR_MAY_SLEEP attribute Date: Wed, 19 Apr 2023 12:03:55 +0200 Message-Id: <5116beca58c18b73611a88063c290e56f38bb441.1681898595.git.petr.tesarik.ext@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: LxC2BwAXi_aYvD9k7TY6Ag--.1944S5 X-Coremail-Antispam: 1UD129KBjvJXoW7ZF17ur1rGrWUZw18GFy5XFb_yoW8Cw48p3 ZagFyfGrZ2gr1xCr1kG3W29r4UXa18u345GF40vr1rZFW5A3Z29rZ8Kw1Yq3s8XryxCFWF vrW29ry5CryqyrDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmGb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7 AKxVWUtVW8ZwCY1x0264kExVAvwVAq07x20xyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC 6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWw C2zVAF1VAY17CE14v26rWY6r4UJwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j 6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rV WUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWx JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8D5r7UUUUU== X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Petr Tesarik Introduce a DMA attribute to tell the DMA-mapping subsystem that the operation is allowed to sleep. This patch merely adds the flag, but it does not do anything at the moment. Signed-off-by: Petr Tesarik --- Documentation/core-api/dma-attributes.rst | 10 ++++++++++ include/linux/dma-mapping.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/Documentation/core-api/dma-attributes.rst b/Documentation/core-api/dma-attributes.rst index 1887d92e8e92..9ce00926455f 100644 --- a/Documentation/core-api/dma-attributes.rst +++ b/Documentation/core-api/dma-attributes.rst @@ -130,3 +130,13 @@ accesses to DMA buffers in both privileged "supervisor" and unprivileged subsystem that the buffer is fully accessible at the elevated privilege level (and ideally inaccessible or at least read-only at the lesser-privileged levels). + +DMA_ATTR_MAY_SLEEP +------------------ + +This tells the DMA-mapping subsystem that it is allowed to sleep. For example, +if mapping needs a bounce buffer, software IO TLB may use CMA for the +allocation if this flag is given. + +This attribute is not used for dma_alloc\* functions. Instead, the provided +GFP flags are used to determine whether the allocation may sleep. diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 0ee20b764000..7a75c503ac38 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -61,6 +61,12 @@ */ #define DMA_ATTR_PRIVILEGED (1UL << 9) +/* + * DMA_ATTR_MAY_SLEEP: This tells the DMA-mapping subsystem that it is allowed + * to sleep. + */ +#define DMA_ATTR_MAY_SLEEP (1UL << 10) + /* * A dma_addr_t can hold any valid DMA or bus address for the platform. It can * be given to a device to use as a DMA source or target. It is specific to a -- 2.25.1