Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp20574ybg; Mon, 27 Jul 2020 22:03:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2TdLsePucTzy6DyYJCWzfMZL0DpKchOnNKQmqh2eyyUJf932hu0JgDngK8mMdw1x7CjEr X-Received: by 2002:a17:907:20af:: with SMTP id pw15mr25010290ejb.204.1595912581936; Mon, 27 Jul 2020 22:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595912581; cv=none; d=google.com; s=arc-20160816; b=0FOoWclAL5Ouxo45dAnTTdN5uWujp/fL7wklgpWdRCi5eJszsoWnbWwqKkYdwZUyWw GGbb3/9GNXgosvp/8ZpfG2vREwBOHtXYApFQQEOWaTNJmsSICY54ZYCcjerhAckEb9Bc qGcarbXAailAZCyW6O9E1o6MteygBJsm7FRW6tJNStW6aTLhse0JVV8sqvdUsUDlJEAr Joy9zQ8RIy8rlkf8aKpkuPjmHIwXw4SpFS5rSa5BiHkDXz2DAzQbMQZFqPpSesolJpyT z26AqyzQhXlnKXrzYOQtw79rhp2gYIvkRRp15JNlDW2OcnR/4A4EqOBKPhJQlNxMgYPI BgQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=quJpJ8MFVCXxN2uUe5uCTDrzupsmhmPuwJ3x/xpP/Nw=; b=1GkwaiRYPksfr+D8jZcTbytLQAjVHNFcLs4i+G6HDLQMHwkPd7yYXPB97agVIXxhob 3Aa/MgqdE6oXXAYj1JPS+ZSHD7BBtHMoUp3SdaErNi1bK9/NzTNgkNpI0nzlrQO+7O7v iNcgh9TKr6A/Bww9llo9f/3cMUsVFvd4twLsEsS9ZLmRS4lXO4RXOND6szwKd2JTyEmW LVDiyvbbYMK5BngXloKLdIescJIhEmiWxjDHsMteQt76rpNm2bfK27gaKseALIMfsGlI yzouZDaIMKbh6ufc9KBQJncmtGki+n/qc3hydo4E3OBIJci5Dmw3ZVLQIDvTTF5o3P74 kQ7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FFJEqir1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu20si3900744edb.537.2020.07.27.22.02.39; Mon, 27 Jul 2020 22:03:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FFJEqir1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726797AbgG1FCN (ORCPT + 99 others); Tue, 28 Jul 2020 01:02:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726942AbgG1FCH (ORCPT ); Tue, 28 Jul 2020 01:02:07 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE345C0619D2 for ; Mon, 27 Jul 2020 22:02:06 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id z5so11209684pgb.6 for ; Mon, 27 Jul 2020 22:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=quJpJ8MFVCXxN2uUe5uCTDrzupsmhmPuwJ3x/xpP/Nw=; b=FFJEqir1hVkStEtfk+rEgzo8ZUuB5JUH7sJuO0JVeZhFlRfq6eDnq0M4SOi7xAzJNL Lg/B3hHFlX31yqXoVUvS53JbUcgSOfKFc9jlDruvAYag4p2p8uxI5CayvTuyOTxTzb2Y CmbNlaHf7A4Fl7V3TquMd4DohiBBSI7zhVcCs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=quJpJ8MFVCXxN2uUe5uCTDrzupsmhmPuwJ3x/xpP/Nw=; b=BrzigtoeJRphYe4x3PkbPM4+n81MEOmTIhVMHciJD/Qx6TA10Da9Iz4kY5c0qxa+nn fqw1jCq4GLuVQpE5KBXU8+KdVkPsBQ4pNZjYNdCKPJIgSLHzj6keKcGmB2w+Wp8ZbDpK 8RliktJFHJBpH02nWbJ63DSRA9eknkUpwWRugSOtl8yUtFDT5V7yzQsi9IAorp7jwVUD IK22enrfyRjxrGTEW2v5g90wyxcepu5BNXDEOMip24SrVL819b3YXFpTe6Nails2r4AW zseKyKptd4lTSnqA+I2CAH/M8RPWoJ//x2LQlokoeXclAWffJhl5e1fXEBaKHoFcTd1n n55A== X-Gm-Message-State: AOAM530QcBDGDmHUrf57o9irJNOux2+m7fjj2ipMU7uL8t56EbdWDD0V ijk+OcICxLgb7Sz+RpGLeonscg== X-Received: by 2002:a65:428d:: with SMTP id j13mr23297111pgp.211.1595912526277; Mon, 27 Jul 2020 22:02:06 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:3e52:82ff:fe5e:cc9d]) by smtp.gmail.com with ESMTPSA id a26sm17578156pgm.20.2020.07.27.22.02.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Jul 2020 22:02:05 -0700 (PDT) From: Claire Chang To: robh+dt@kernel.org, frowand.list@gmail.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com Cc: treding@nvidia.com, gregkh@linuxfoundation.org, saravanak@google.com, suzuki.poulose@arm.com, dan.j.williams@intel.com, heikki.krogerus@linux.intel.com, bgolaszewski@baylibre.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, drinkcat@chromium.org, tfiga@chromium.org, tientzu@chromium.org Subject: [RFC v2 4/5] dt-bindings: of: Add plumbing for restricted DMA pool Date: Tue, 28 Jul 2020 13:01:39 +0800 Message-Id: <20200728050140.996974-5-tientzu@chromium.org> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728050140.996974-1-tientzu@chromium.org> References: <20200728050140.996974-1-tientzu@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce the new compatible string, device-swiotlb-pool, for restricted DMA. One can specify the address and length of the device swiotlb memory region by device-swiotlb-pool in the device tree. Signed-off-by: Claire Chang --- .../reserved-memory/reserved-memory.txt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt index 4dd20de6977f..78850896e1d0 100644 --- a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt +++ b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt @@ -51,6 +51,24 @@ compatible (optional) - standard definition used as a shared pool of DMA buffers for a set of devices. It can be used by an operating system to instantiate the necessary pool management subsystem if necessary. + - device-swiotlb-pool: This indicates a region of memory meant to be + used as a pool of device swiotlb buffers for a given device. When + using this, the no-map and reusable properties must not be set, so the + operating system can create a virtual mapping that will be used for + synchronization. Also, there must be a restricted-dma property in the + device node to specify the indexes of reserved-memory nodes. One can + specify two reserved-memory nodes in the device tree. One with + shared-dma-pool to handle the coherent DMA buffer allocation, and + another one with device-swiotlb-pool for regular DMA to/from system + memory, which would be subject to bouncing. The main purpose for + restricted DMA is to mitigate the lack of DMA access control on + systems without an IOMMU, which could result in the DMA accessing the + system memory at unexpected times and/or unexpected addresses, + possibly leading to data leakage or corruption. The feature on its own + provides a basic level of protection against the DMA overwriting buffer + contents at unexpected times. However, to protect against general data + leakage and system memory corruption, the system needs to provide a + way to restrict the DMA to a predefined memory region. - vendor specific string in the form ,[-] no-map (optional) - empty property - Indicates the operating system must not create a virtual mapping @@ -117,6 +135,16 @@ one for multimedia processing (named multimedia-memory@77000000, 64MiB). compatible = "acme,multimedia-memory"; reg = <0x77000000 0x4000000>; }; + + wifi_coherent_mem_region: wifi_coherent_mem_region { + compatible = "shared-dma-pool"; + reg = <0x50000000 0x400000>; + }; + + wifi_device_swiotlb_region: wifi_device_swiotlb_region { + compatible = "device-swiotlb-pool"; + reg = <0x50400000 0x4000000>; + }; }; /* ... */ @@ -135,4 +163,11 @@ one for multimedia processing (named multimedia-memory@77000000, 64MiB). memory-region = <&multimedia_reserved>; /* ... */ }; + + pcie_wifi: pcie_wifi@0,0 { + memory-region = <&wifi_coherent_mem_region>, + <&wifi_device_swiotlb_region>; + restricted-dma = <0>, <1>; + /* ... */ + }; }; -- 2.28.0.rc0.142.g3c755180ce-goog