Message ID | 20230926152600.8749-1-laurentiu.tudor@nxp.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2037719vqu; Tue, 26 Sep 2023 09:21:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxPXPA6fjEj2pcDLq63TSNCN67bWYs9x3frEC7J4YsP78KyPtYIOy4SplCLPDrZsJbm8lc X-Received: by 2002:a05:6a00:2e9f:b0:692:6417:728a with SMTP id fd31-20020a056a002e9f00b006926417728amr5147980pfb.14.1695745306749; Tue, 26 Sep 2023 09:21:46 -0700 (PDT) Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id ay34-20020a056a00302200b00690fe11c9dbsi12657627pfb.97.2023.09.26.09.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 09:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=mo2G6uwe; arc=fail (DNS record missing); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 433338098B8D; Tue, 26 Sep 2023 08:26:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234878AbjIZP03 (ORCPT <rfc822;pwkd43@gmail.com> + 28 others); Tue, 26 Sep 2023 11:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235095AbjIZP0X (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 26 Sep 2023 11:26:23 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2041.outbound.protection.outlook.com [40.107.105.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDCF610E for <linux-kernel@vger.kernel.org>; Tue, 26 Sep 2023 08:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DsQY5lvKwNE1l7HaZb+yhT7IJDVp+UIvHzUvTZMZW1KSrCKAO9qsSgsa63F31GoQYmKEBgBfhe8KBl0Wcf7Kd6cAsM4eB1mpGomhEYosZoBF0DexbZDPTBUX9zX+k71iLWDjsQd0dUWofvrbeMwp+F6l0N59INc/7z2HB6LdzeOFwxQ1vRt7LW+t0yHJ00D6tEHSTJDJpgmIKuokOZdK2C5Bl/9/vahE4ram+MXFmZeC0gnjC37fYHchOREq5Z+0XLvLcYptXo9XTJkQsP92Y7Opaz1Mikm3DLU2ECyYOWP7w6gr7Cs7xyhD/gtUfx6bZWwVhWzzYH8JMnI8rb6f4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LjS2oc1G2xKWiWE4J4bNLWk15KU6ekD8lNB1EVGxXPM=; b=ZS9sPSP7hbjwlVrp1I9ro/BgJlU4QValXsTm9dDK6NuhwqWY8HEU/MD0v6XaqXCwm6PQ/ytWPTmHOCxVvyZ2oSVdcGlO7JCnsS0AUEYH0N6D/x/nvRqSBIL/5aE9AfYBUXMq+A0TGnJRDqb/7FOPa/603aYjaB6+zAwOV9tbOjN63HeAwW79RQZK7Nocp1tCoZ+RQiCBTtgALoFIy6CMH7Mebq4REenkh9ny7zkE6cvYdjU2zGeWH2gfoygjuzXmveUYHksCWpfyvDFthYrSB6oCS1+cE0s/1xazgNFU3dVa2tQcb5MSONVqvNRH2sNNMdKEqOdtTVwOmw3lDkPyQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LjS2oc1G2xKWiWE4J4bNLWk15KU6ekD8lNB1EVGxXPM=; b=mo2G6uweotZ+1U7kWSuYN0XWDCIz5bP3RbhnGqnS5OR+vajivnbFu90NurVAesj5jzL9LEJAjk9CIKBzoJOapBN1cvHYYMlXiZhNMR1RlJUwljENayTpzUnhPgmSreJkNYajW+WHcXhOL4/Uklz5NJmEr91vfMwaqX1qgq68J5o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9380.eurprd04.prod.outlook.com (2603:10a6:10:368::16) by AS8PR04MB7493.eurprd04.prod.outlook.com (2603:10a6:20b:293::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Tue, 26 Sep 2023 15:26:11 +0000 Received: from DB9PR04MB9380.eurprd04.prod.outlook.com ([fe80::425a:a4a9:17b3:cfe4]) by DB9PR04MB9380.eurprd04.prod.outlook.com ([fe80::425a:a4a9:17b3:cfe4%4]) with mapi id 15.20.6813.027; Tue, 26 Sep 2023 15:26:11 +0000 From: Laurentiu Tudor <laurentiu.tudor@nxp.com> To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, treding@nvidia.com, jgg@nvidia.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com> Subject: [PATCH v3] iommu: map reserved memory as cacheable if device is coherent Date: Tue, 26 Sep 2023 18:26:00 +0300 Message-Id: <20230926152600.8749-1-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: AM0PR02CA0225.eurprd02.prod.outlook.com (2603:10a6:20b:28f::32) To DB9PR04MB9380.eurprd04.prod.outlook.com (2603:10a6:10:368::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9380:EE_|AS8PR04MB7493:EE_ X-MS-Office365-Filtering-Correlation-Id: 372469d3-a7a4-45b2-a3f1-08dbbea4e9ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bk2SioSbhFoNIdCXj9QHnNHk1mffNr5povuf6jCTo/1YwShFaTEc3VMTzE7ff/V26R2qpFy8/CPnidU3bJXtRFZLixjhnsymp6Vrc0J8rex9tC2s8Yc+SzEsvdcaye1xVkwJbGGgjJkfiAGkXeQaGbKRqDubPDO19PozsxbmTKgrWDB2caOk5J6OFN+pjFX7U5vk7NC6UX+HD3FV3YyVRvwHh7FA4e9wSLg6hEDnbf9kZ++dX4Fzuh67uzrVqBmYp3gMYzPZ2kZ4uGWUIa5ufsvhLSBiTqN5zm77XpRkRC/ZMh3ekSmilLT22Z08T0nQUrwDFm64V9tJRiDtH920zAY8v7CeWGSKzeRKI8O7+Ncdg792o3dBgZ4smEc+m31l8yuc5sVm687GMU9TlPU6DBz0ZtB/mXOIJ4XP1Y+y1fci+EEYYaF54Aivdy59xZkFVZnPofiw2sTQ4X+iAEmlkN8X8+zzs9Uwj0TeO67h7O8cc8lXQ2VDQXGJD1iaceTQdN/mGHJKKk9NwRfXAxRcYmJxYn+cwj+r0x6d4VwJYZYz+EKWetxXnQ8YeBB5+ZGNRs5wUBuGVQGKVuxPJgVixQURqeVxf+auxSW/3YPCgMhDqL/yiAqLwMpvN30Md3S2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9380.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(39860400002)(396003)(376002)(136003)(346002)(230922051799003)(451199024)(186009)(1800799009)(5660300002)(316002)(83380400001)(44832011)(41300700001)(8676002)(8936002)(36756003)(2616005)(4326008)(66476007)(66946007)(66556008)(1076003)(6486002)(52116002)(6666004)(6512007)(6506007)(86362001)(26005)(38100700002)(2906002)(38350700002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6pY9MerhWsPfiAUGRhTAnPfgpZ2oSk5T1wXJlQHOXW+00AMvVke8HIK0c4OFSrfKWn7vKPRVzk+X6OdVOL4WZcEB4gopCXTkLDg9uHM/5DpGk7FthOgYqvMBL6vPYRhHPN/mUersq/UYAYt4XN5KroTqheO+K/touUlCqClKK2Dh3R4ZYxUqmEGRMWWSzvDWkPYsLIy3XO8IMMUBuD5RIE4vIp0lvTNaImyjvp71RU9ysvW3PyCZtBw0jZ1whOTyQJ1RmUpLXw5DNkAcZ2YA7LledzBRY5hP+KgrsM3RIFPadGlkSz7675deFChYcyhk3ed4n+1lC17ziO8T5Z3KXXU6hSjmjK6yqVICuyD1lqGSqK5ipStMsL65CT2WQ+AxYDyDSDml5J+ubr76zGdvnUGhPA8dHZScPkZ8wln2trtW0BmIwG+Tw9+qDJjHIkcVxSlLT+dAQuK5ihs92oHJk67nxJ20CZLx8JTFHMfAwy7KJ+NP2cggenY8x70YuV9+Ray4pGh+yMTsjFy/A7UFjEtn5UNTyA/f32Hus0Q2vCE8Arx18wDvhAo14BgqiHlksKA70s+fBIpGDtCMMB+IAoL1pgDZ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rossTenant-AuthSource: DB9PR04MB9380.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2023 15:26:11.2055 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hKOP1zIQzMySyOrWlfOnAc01301Elw8NqJEKEY50oa/XQiNIjktT8gXH/DWO5R2gpmS0N0k9kOlEecHb9DXsTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7493 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 26 Sep 2023 08:26:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778117830878530193 X-GMAIL-MSGID: 1778117830878530193 |
Series |
[v3] iommu: map reserved memory as cacheable if device is coherent
|
|
Commit Message
Laurentiu Tudor
Sept. 26, 2023, 3:26 p.m. UTC
Check if the device is marked as DMA coherent in the DT and if so, map its reserved memory as cacheable in the IOMMU. This fixes the recently added IOMMU reserved memory support which uses IOMMU_RESV_DIRECT without properly building the PROT for the mapping. Fixes: a5bf3cfce8cb ("iommu: Implement of_iommu_get_resv_regions()") Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Acked-by: Thierry Reding <treding@nvidia.com> --- Changes in v3: - added Acked-by tag (Thierry) Changes in v2: - added Reviewed-by tag (Jason) drivers/iommu/of_iommu.c | 3 +++ 1 file changed, 3 insertions(+)
Comments
Hello, Any chance of having this picked up? It is the last missing bit to fix booting vanilla images on some NXP platforms (Layerscape LX2160A, LS2088A, LS1088A) given that the bootloader side of things [1] was accepted. Thank you! [1] https://patchwork.ozlabs.org/project/uboot/list/?series=375154&state=* --- Best Regards, Laurentiu On 9/26/2023 6:26 PM, Laurentiu Tudor wrote: > Check if the device is marked as DMA coherent in the DT and if so, > map its reserved memory as cacheable in the IOMMU. > This fixes the recently added IOMMU reserved memory support which > uses IOMMU_RESV_DIRECT without properly building the PROT for the > mapping. > > Fixes: a5bf3cfce8cb ("iommu: Implement of_iommu_get_resv_regions()") > Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> > Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> > Acked-by: Thierry Reding <treding@nvidia.com> > --- > Changes in v3: > - added Acked-by tag (Thierry) > > Changes in v2: > - added Reviewed-by tag (Jason) > > drivers/iommu/of_iommu.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index 157b286e36bf..5b3631ba5a45 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -254,6 +254,9 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list) > phys_addr_t iova; > size_t length; > > + if (of_dma_is_coherent(dev->of_node)) > + prot |= IOMMU_CACHE; > + > maps = of_translate_dma_region(np, maps, &iova, &length); > type = iommu_resv_region_get_type(dev, &phys, iova, length); >
On Tue, Sep 26, 2023 at 06:26:00PM +0300, Laurentiu Tudor wrote: > drivers/iommu/of_iommu.c | 3 +++ > 1 file changed, 3 insertions(+) Applied, thanks.
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 157b286e36bf..5b3631ba5a45 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -254,6 +254,9 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list) phys_addr_t iova; size_t length; + if (of_dma_is_coherent(dev->of_node)) + prot |= IOMMU_CACHE; + maps = of_translate_dma_region(np, maps, &iova, &length); type = iommu_resv_region_get_type(dev, &phys, iova, length);