From patchwork Sat Oct 22 07:29:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1108763wrr; Sat, 22 Oct 2022 01:45:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM711RxPMdq1cRk0ad7zfdQlHauCBX+oPOC2xm/I3lZ9eO+AavD2cHlEZvH0raz9eRSUFIsL X-Received: by 2002:a17:907:9625:b0:78d:bb06:9072 with SMTP id gb37-20020a170907962500b0078dbb069072mr19172032ejc.472.1666428357944; Sat, 22 Oct 2022 01:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428357; cv=none; d=google.com; s=arc-20160816; b=cxZt8kyQKAyC6hI3FzkJFBskKm00Ru0C93kQ/KuQwl3/Cznuj/qpu/ncXsextG84Dt lmhFrVIXlGE4TG6ECPRa62wknrvYdTnwWGJsWSl6PY2fhn0rtFYkFA+5gERl7gW+ZTul JYxbTsJCKjpdfPeCSW73qjzGhmKTjIQ+v4T5POOC7Uqw1/Rm5axX6KI5RQQbWubUDUgh rbGRuUxErYSTQoq4jNwUf+EVoZDkrWdAC/lkbhD57/BJKF9NjR/Hiy7lYkEqr7DnUD6Z OJxOGZpdOU2j4vzFEeEVTXrA2MMdAmbZHcsTEWBVYsSaw3e0bTSagq1u9zPa8ItLy2Cb n7qw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zfRt1IgQHQfzVWu8VMHJQfDrkPN25LJnWQhPCU2JvDM=; b=dw3MB1XcNP904ZEVmDUH1cdn6RmcDrr9YBfuosCfi1kunakl5ZcfC3AdbeJ0tZGgT8 2dI+xA801rX1dPbUEKg1oxyi8jFpWgWT/J1Od36VeDlj1YB/DOi8ur8Wk6AcydLhNPoK 8L5gP1+OUZYojkLLGsoY+f7HT5zb1syPxHfIyQ3c4vzM9yeP8QrQ9qqk/AJKLtQgS5UA fYIVbG9F1H5WBA0Ny1DMcECiSFmT1HpJP2gQVXM2wZ6yNaOKXqzGg5et14f0T7gf27cD FwDeU0lmhrosLoxkmlH2pZvuOvtViIcWN/AtawDQUHMTKI/gilCkCe2AIeK0y2i+L3sH h1Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E4BEEnO8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a170906854400b0077b287e3adesi17769187ejy.190.2022.10.22.01.45.32; Sat, 22 Oct 2022 01:45:57 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E4BEEnO8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234698AbiJVInf (ORCPT + 99 others); Sat, 22 Oct 2022 04:43:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234696AbiJVImW (ORCPT ); Sat, 22 Oct 2022 04:42:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C23492E7BB8; Sat, 22 Oct 2022 01:06:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9C63460B40; Sat, 22 Oct 2022 08:06:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B20A9C433D6; Sat, 22 Oct 2022 08:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666426015; bh=aZVzA0Fqpt2J+xf2p0wOtv5uyqkIk7yWq6pL5/lVCu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E4BEEnO8CFmXOmgHucZ0YQdcwUnQIzMWlwnWFZib0uXeNPCB90Xa31XNIA4dpuvoC eilOdcsl/8o0ungUUncqaWfYik63YbCw5AMXiqIPLXjGKxwldM28gBIl7bJaWTN+b0 J1BvCGR2NPsU5b3hmVTXY88VgWf1SzMd9v7yJ3S8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Yicong Yang , John Garry , Mathieu Poirier , Sasha Levin Subject: [PATCH 5.19 661/717] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Date: Sat, 22 Oct 2022 09:29:00 +0200 Message-Id: <20221022072527.636321501@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1747376781545571394?= X-GMAIL-MSGID: =?utf-8?q?1747376781545571394?= From: Yicong Yang [ Upstream commit 24b6c7798a0122012ca848ea0d25e973334266b0 ] The DMA operations of HiSilicon PTT device can only work properly with identical mappings. So add a quirk for the device to force the domain as passthrough. Acked-by: Will Deacon Signed-off-by: Yicong Yang Reviewed-by: John Garry Link: https://lore.kernel.org/r/20220816114414.4092-2-yangyicong@huawei.com Signed-off-by: Mathieu Poirier Signed-off-by: Sasha Levin --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 88817a3376ef..e119ff8396c9 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2839,6 +2839,26 @@ static int arm_smmu_dev_disable_feature(struct device *dev, } } +/* + * HiSilicon PCIe tune and trace device can be used to trace TLP headers on the + * PCIe link and save the data to memory by DMA. The hardware is restricted to + * use identity mapping only. + */ +#define IS_HISI_PTT_DEVICE(pdev) ((pdev)->vendor == PCI_VENDOR_ID_HUAWEI && \ + (pdev)->device == 0xa12e) + +static int arm_smmu_def_domain_type(struct device *dev) +{ + if (dev_is_pci(dev)) { + struct pci_dev *pdev = to_pci_dev(dev); + + if (IS_HISI_PTT_DEVICE(pdev)) + return IOMMU_DOMAIN_IDENTITY; + } + + return 0; +} + static struct iommu_ops arm_smmu_ops = { .capable = arm_smmu_capable, .domain_alloc = arm_smmu_domain_alloc, @@ -2856,6 +2876,7 @@ static struct iommu_ops arm_smmu_ops = { .sva_unbind = arm_smmu_sva_unbind, .sva_get_pasid = arm_smmu_sva_get_pasid, .page_response = arm_smmu_page_response, + .def_domain_type = arm_smmu_def_domain_type, .pgsize_bitmap = -1UL, /* Restricted during device attach */ .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops) {