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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 718AAC433F5 for ; Tue, 16 Nov 2021 10:58:45 +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 3B8D063213 for ; Tue, 16 Nov 2021 10:58:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3B8D063213 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sneuGCCAZI6LYYwWTKXhyb2h2cXsxddFRL+MAhfjNBA=; b=4Dayif6EQhXi7g v0DDUOxqZhBmcSC606lraG0Bm5mpDqHqhuruj6v99WjwbOu1E6otwEdte3i93A+Bi5ZDyHmperM7t yUjAYMbrYVJNTZIIe+SyCQAcZdtN6la+/Lkl55p+PC86y/P4LTNuK/BxbG1yL0VQ8FCgrBcj9Rqth vJP3NDptrzpPBXvjuGGpe+cqvYPiT4/NvpWXLc0oMXnCXWhsxS3UW53xqXi3b+dVIOcs+0gtenyfz dKQ9AMdH8ibqymOtpFv7v0MKXG5+yS03V8tLJMVQ6aX7WgmtczX7A9+xxY3k55UjXsWePWbuuZjOu W1TlZaj3haBRLDRm07tg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmw94-001ITm-Bl; Tue, 16 Nov 2021 10:56:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmw8x-001ISe-Ab for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 10:56:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5F3E01FB; Tue, 16 Nov 2021 02:56:49 -0800 (PST) Received: from [10.57.82.45] (unknown [10.57.82.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3E2673F766; Tue, 16 Nov 2021 02:56:45 -0800 (PST) Message-ID: <0b67745c-13dd-1fea-1b8b-d55212bad232@arm.com> Date: Tue, 16 Nov 2021 10:56:39 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH v2 2/6] hwtracing: Add trace function support for HiSilicon PCIe Tune and Trace device Content-Language: en-GB To: Yicong Yang , gregkh@linuxfoundation.org, helgaas@kernel.org, alexander.shishkin@linux.intel.com, lorenzo.pieralisi@arm.com, will@kernel.org, mark.rutland@arm.com, mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, jonathan.cameron@huawei.com, daniel.thompson@linaro.org, joro@8bytes.org, john.garry@huawei.com, shameerali.kolothum.thodi@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-pci@vger.kernel.org, linux-perf-users@vger.kernel.org, iommu@lists.linux-foundation.org Cc: prime.zeng@huawei.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, liuqi115@huawei.com References: <20211116090625.53702-1-yangyicong@hisilicon.com> <20211116090625.53702-3-yangyicong@hisilicon.com> From: Robin Murphy In-Reply-To: <20211116090625.53702-3-yangyicong@hisilicon.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211116_025651_460834_BD6C8705 X-CRM114-Status: GOOD ( 14.04 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-11-16 09:06, Yicong Yang via iommu wrote: [...] > +/* > + * Get RMR address if provided by the firmware. > + * Return 0 if the IOMMU doesn't present or the policy of the > + * IOMMU domain is passthrough or we get a usable RMR region. > + * Otherwise a negative value is returned. > + */ > +static int hisi_ptt_get_rmr(struct hisi_ptt *hisi_ptt) > +{ > + struct pci_dev *pdev = hisi_ptt->pdev; > + struct iommu_domain *iommu_domain; > + struct iommu_resv_region *region; > + LIST_HEAD(list); > + > + /* > + * Use direct DMA if IOMMU does not present or the policy of the > + * IOMMU domain is passthrough. > + */ > + iommu_domain = iommu_get_domain_for_dev(&pdev->dev); > + if (!iommu_domain || iommu_domain->type == IOMMU_DOMAIN_IDENTITY) > + return 0; > + > + iommu_get_resv_regions(&pdev->dev, &list); > + list_for_each_entry(region, &list, list) > + if (region->type == IOMMU_RESV_DIRECT && > + region->length >= HISI_PTT_TRACE_BUFFER_SIZE) { > + hisi_ptt->trace_ctrl.has_rmr = true; > + hisi_ptt->trace_ctrl.rmr_addr = region->start; > + hisi_ptt->trace_ctrl.rmr_length = region->length; > + break; > + } > + > + iommu_put_resv_regions(&pdev->dev, &list); > + return hisi_ptt->trace_ctrl.has_rmr ? 0 : -ENOMEM; > +} No. The whole point of RMRs is for devices that are already configured to access the given address range in a manner beyond the kernel's control. If you can do this, it proves that you should not have an RMR in the first place. The notion of a kernel driver explicitly configuring its device to DMA into any random RMR that looks big enough is so egregiously wrong that I'm almost lost for words... Robin. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel