From patchwork Wed Apr 19 10:03:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Tesarik X-Patchwork-Id: 85299 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp265750vqo; Wed, 19 Apr 2023 03:07:46 -0700 (PDT) X-Google-Smtp-Source: AKy350bEZ/f5BqU3PxoNSfCqP9gvccSnL0BWmo4S8eDhRzL1aDDIQ9Tl0XUvxG0sz3j7eKA1yMU0 X-Received: by 2002:a17:90a:7f92:b0:247:4877:2172 with SMTP id m18-20020a17090a7f9200b0024748772172mr2274532pjl.47.1681898865875; Wed, 19 Apr 2023 03:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681898865; cv=none; d=google.com; s=arc-20160816; b=WJ0PhxWukG73JoikAOvXaT4hwocPuHIRkLe1xRelMbK16kdtq0k2f2HDEGNDIWkrNd HHAwPRq0MCs1V6RkYKXSUDrxQBlpH1qNiv+MD2NQYarFwVq4y9f5o3zeUtHkiGM7kjWY /rR3hF6MV9JCjgE4AxUa9LiEiGHSpyKl6c0QPl8tQD0ZmqmoNPFgspogrdkCAP1n/0Wa N3APTNpT7OkeGe8fzMpL9H4aK9mEOYrLXIZdvebAIDDLbIatjI9QQdmFNSmnIZ+uaJsq Mwp4sEhBty7THdl0kur0QTNZHmB8rY+Y4FjwUFYH714W204m3pkVZRdK2Iw9RF5dSw3i R2kw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a17090aa41100b0023f000be67dsi1486599pjp.13.2023.04.19.03.07.31; Wed, 19 Apr 2023 03:07:45 -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 S233008AbjDSKGd (ORCPT + 99 others); Wed, 19 Apr 2023 06:06:33 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763598785449703468?= X-GMAIL-MSGID: =?utf-8?q?1763598785449703468?= 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