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 X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D248AC433F5 for ; Fri, 17 Sep 2021 11:29:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 979AF610E9 for ; Fri, 17 Sep 2021 11:29:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 979AF610E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qhPqo8V677Cud8gg7SSWI9UdnRsYbmQYwJR1TD404qo=; b=lyphx/uYHAEnQX IzJT3OhB/dLqB/d/sXsBtf87UMWBlQpVYkPT1sQ/8OPeWfkyqA67dzdSGBRETC8s7HijOstcJdZmh 0EDKKcAsEb5isg8FHcDhf0tGmNu3LNlg097XXTjjApjtEtKB3LadvMMr6BXl280wz435qRwQns/g2 W29RDc2mY3VLDdJ2XtYbbnq3668UIwc76jQdzETSjYYXWJ0/SH8yvfkAK4T+DwFEVTNg1OfJkMjUO 9R91l+bh1YH/mrLP0fL/YnPQXZkMXPdDRfnTN4m4Vqvd44yQtr6L56MzymaIvIULkMTUsFVKds5mS 0rAqXuljuDYLhAtooCwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mRC1P-00Driw-NB; Fri, 17 Sep 2021 11:27:11 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mRC1L-00DrhY-1J for linux-arm-kernel@lists.infradead.org; Fri, 17 Sep 2021 11:27:09 +0000 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4H9s4s6L3YzRDwD; Fri, 17 Sep 2021 19:22:53 +0800 (CST) Received: from dggema722-chm.china.huawei.com (10.3.20.86) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Fri, 17 Sep 2021 19:27:01 +0800 Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by dggema722-chm.china.huawei.com (10.3.20.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Fri, 17 Sep 2021 19:27:01 +0800 Received: from lhreml710-chm.china.huawei.com ([169.254.81.184]) by lhreml710-chm.china.huawei.com ([169.254.81.184]) with mapi id 15.01.2308.008; Fri, 17 Sep 2021 12:26:59 +0100 From: Shameerali Kolothum Thodi To: Jon Nettleton CC: Robin Murphy , Lorenzo Pieralisi , Laurentiu Tudor , linux-arm-kernel , "ACPI Devel Maling List" , Linux IOMMU , Joerg Roedel , "Will Deacon" , wanghuiqiang , "Guohanjun (Hanjun Guo)" , Steven Price , Sami Mujawar , Eric Auger , yangyicong Subject: RE: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing Thread-Topic: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing Thread-Index: AQHXidEiKr58723PTUGGkSglF1QKPatlAmqAgDJmwoCAACN+gIAO55oggAAG1QCAABhrQIAAILeAgAGklSA= Date: Fri, 17 Sep 2021 11:26:59 +0000 Message-ID: <534a04a9fe9941b28670f00222f58ec3@huawei.com> References: <20210805080724.480-1-shameerali.kolothum.thodi@huawei.com> <20210805080724.480-3-shameerali.kolothum.thodi@huawei.com> <20210805160319.GB23085@lpieralisi> <5d9bebdf-6eb5-49a0-2e8f-490df2d6754d@arm.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.47.90.205] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210917_042707_465446_6D446C3C X-CRM114-Status: GOOD ( 43.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > -----Original Message----- > From: Jon Nettleton [mailto:jon@solid-run.com] > Sent: 16 September 2021 12:17 > To: Shameerali Kolothum Thodi > Cc: Robin Murphy ; Lorenzo Pieralisi > ; Laurentiu Tudor ; > linux-arm-kernel ; ACPI Devel Maling > List ; Linux IOMMU > ; Joerg Roedel ; Will > Deacon ; wanghuiqiang ; > Guohanjun (Hanjun Guo) ; Steven Price > ; Sami Mujawar ; Eric > Auger ; yangyicong > Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing > > On Thu, Sep 16, 2021 at 10:26 AM Shameerali Kolothum Thodi > wrote: > > > > > > > > > -----Original Message----- > > > From: Jon Nettleton [mailto:jon@solid-run.com] > > > Sent: 16 September 2021 08:52 > > > To: Shameerali Kolothum Thodi > > > > Cc: Robin Murphy ; Lorenzo Pieralisi > > > ; Laurentiu Tudor > > > ; linux-arm-kernel > > > ; ACPI Devel Maling List > > > ; Linux IOMMU > > > ; Joerg Roedel ; > > > Will Deacon ; wanghuiqiang > > > ; Guohanjun (Hanjun Guo) > > > ; Steven Price ; Sami > > > Mujawar ; Eric Auger > ; > > > yangyicong > > > Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node > > > parsing > > > > > > On Thu, Sep 16, 2021 at 9:26 AM Shameerali Kolothum Thodi > > > wrote: > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > From: Jon Nettleton [mailto:jon@solid-run.com] > > > > > Sent: 06 September 2021 20:51 > > > > > To: Robin Murphy > > > > > Cc: Lorenzo Pieralisi ; Shameerali > > > > > Kolothum Thodi ; Laurentiu > > > > > Tudor ; linux-arm-kernel > > > > > ; ACPI Devel Maling List > > > > > ; Linux IOMMU > > > > > ; Linuxarm > > > > > ; Joerg Roedel ; Will > > > > > Deacon ; wanghuiqiang > > > > > ; Guohanjun (Hanjun Guo) > > > > > ; Steven Price ; > > > > > Sami Mujawar ; Eric Auger > > > ; > > > > > yangyicong > > > > > Subject: Re: [PATCH v7 2/9] ACPI/IORT: Add support for RMR node > > > > > parsing > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > On the prot value assignment based on the remapping flag, > > > > > > > I'd like to hear Robin/Joerg's opinion, I'd avoid being in a > > > > > > > situation where "normally" this would work but then we have > > > > > > > to quirk > > > it. > > > > > > > > > > > > > > Is this a valid assumption _always_ ? > > > > > > > > > > > > No. Certainly applying IOMMU_CACHE without reference to the > > > > > > device's _CCA attribute or how CPUs may be accessing a shared > > > > > > buffer could lead to a loss of coherency. At worst, applying > > > > > > IOMMU_MMIO to a device-private buffer *could* cause the device > > > > > > to lose coherency with itself if the memory underlying the RMR > > > > > > may have allocated into system caches. Note that the expected > > > > > > use for non-remappable RMRs is the device holding some sort of > > > > > > long-lived private data in system RAM - the MSI doorbell trick > > > > > > is far more of a niche > > > hack really. > > > > > > > > > > > > At the very least I think we need to refer to the device's > > > > > > memory access properties here. > > > > > > > > > > > > Jon, Laurentiu - how do RMRs correspond to the EFI memory map > > > > > > on your firmware? I'm starting to think that as long as the > > > > > > underlying memory is described appropriately there then we > > > > > > should be able to infer correct attributes from the EFI memory type > and flags. > > > > > > > > > > The devices are all cache coherent and marked as _CCA, 1. The > > > > > Memory regions are in the virt table as > > > ARM_MEMORY_REGION_ATTRIBUTE_DEVICE. > > > > > > > > > > The current chicken and egg problem we have is that during the > > > > > fsl-mc-bus initialization we call > > > > > > > > > > error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT, > > > > > &mc_stream_id); > > > > > > > > > > which gets deferred because the SMMU has not been initialized yet. > > > > > Then we initialize the RMR tables but there is no device > > > > > reference there to be able to query device properties, only the stream > id. > > > > > After the IORT tables are parsed and the SMMU is setup, on the > > > > > second device probe we associate everything based on the stream > > > > > id and the fsl-mc-bus device is able to claim its 1-1 DMA mappings. > > > > > > > > Can we solve this order problem by delaying the > > > > iommu_alloc_resv_region() to the > > > > iommu_dma_get_rmr_resv_regions(dev, > > > > list) ? We could invoke > > > > device_get_dma_attr() from there which I believe will return the > > > > _CCA > > > attribute. > > > > > > > > Or is that still early to invoke that? > > > > > > That looks like it should work. Do we then also need to parse > > > through the VirtualMemoryTable matching the start and end addresses > > > to determine the other memory attributes like MMIO? > > > > Yes. But that looks tricky as I can't find that readily available on > > Arm, like the efi_mem_attributes(). I will take a look. > > > > Please let me know if there is one or any other easy way to retrieve it. > > maybe we don't need to. Maybe it is enough to just move > iommu_alloc_resv_regions and then set the IOMMU_CACHE flag if type = > IOMMU_RESV_DIRECT_RELAXABLE and _CCN=1? It looks like we could simply call efi_mem_type() and check for EFI_MEMORY_MAPPED_IO. I have updated the code to set the RMR prot value based on _CCA and EFI md type. Please see the last commit on this branch here(not tested), https://github.com/hisilicon/kernel-dev/commits/private-v5.14-rc4-rmr-v7-ext Please take a look and let me know if this is good enough to solve this problem. Thanks, Shameer _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel