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=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,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 3D207C4361B for ; Mon, 14 Dec 2020 12:53:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 D78D3206FB for ; Mon, 14 Dec 2020 12:53:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D78D3206FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=evg3i7e4Yk/wNgcwkr5P4mKcb0PeVMezElYbpUsyIa0=; b=0K799sB/PyUdK3Hl+OTW2srMg iO5uxJ0sNiNzNBjEb22ARmB50NxGNCQE+xWrrdizPA88uyNwzNy9O9hX47tGp6zE0GmMCWfFXjbLD NjfDEb/+Q71ihVjjadAS3gDQ8VQshtc+2kt4uFrEsM6rTLImqnhgtQexJjgskAHdmymW25lSGLxfA EgJfXE+aAhvoL9gV28h5dazbHi1lZmTA/klmKpn5Qu5S7b++gr4UjuCLeCadERUcX0QdO8ac2ALRu ZnUTiagplQFEbTG7/yOVeoMINhIWBzU2ePjmiilEyj21Q4Xz428Yn1J/dt4bo/eKD7OANf/Y1U3vg /UONBI3/g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1konKf-0008Gg-N8; Mon, 14 Dec 2020 12:52:05 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1konKc-0008GG-I6 for linux-arm-kernel@lists.infradead.org; Mon, 14 Dec 2020 12:52:03 +0000 Received: by mail-wm1-x344.google.com with SMTP id a6so13550512wmc.2 for ; Mon, 14 Dec 2020 04:52:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uA7Oxs/wyvYUE1Q5Z79HLkOoFQjgdYG73UpryFEtyeo=; b=A7JTYmymCT84foHfhEmNIHr/pEfSygaw0il7x05bSBXymRtmnEeQ9s8NImWZYvG1bR IJ7xCY9OfQNEa/YTNBx2CJk7Ipe6KY895wWjACUQcgcAwrrpE4Jqm8k7W/CzO6YM4aR/ dscM1fFxsl/sItEgQ3EkazFzVcCs2S7RTUHBTYW31rZbDmyyz0X1ZLZMoXi3UKDQySQH gyixWe2v4wPss1+mh04uaNzSADC1nZCcohSWb/6SDx4QQlplS7Ew13lBe+/dE6xkGvdS aiKO2/ys+HAjPf1PsTGTiBKRnGpAosT6yCiq3CWjYQaTagjjvEcyO/TG5vcVPGXf3plk kSpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uA7Oxs/wyvYUE1Q5Z79HLkOoFQjgdYG73UpryFEtyeo=; b=W+s+NfCeK2MQz5cyEw+6lJguEg9n+I/b8qVD9Yp0v2Om3kyq8OayOsT8GRsxUrEqQg Dxol1uIv2NZH2ULFSlxIlbWNtGh5cEYc76olqmf8kja8w0qSt5he4Mudjd+PzpjOvy88 H1r6Umdi7+HcPLib4binREnCz7Vs7hWZwm4OH6HIGp8ZkXpZlcx4NGQ7F8ntVgw3NrOw H2nLXrFiAYEvyXPYj7prM353cUCs2qF84Hrj3+GiZY7OkdzMnrbi6e3HqqCNSR+m0mt6 SLcJLg+jaGHSVhhzD/nYxM6DQTL6C/YiIaPl7+darvw39B0b1RXj89j7nytkhvbonR0Y 30Ag== X-Gm-Message-State: AOAM532bFIbwlxx7L4dZ9YVGFAokJg0iqwBxT9lVFYkCntzgnDtl2eJq YQkWAv/4fcox1mnhBHA6beiLGQ== X-Google-Smtp-Source: ABdhPJy7ckFB91jTR/PoEmgcekJEn+mvUgXVeEpBAXlu4Plmu8X+fq263Z3FizP3RlKSLXwiHojtUg== X-Received: by 2002:a1c:b7d4:: with SMTP id h203mr27925588wmf.59.1607950321431; Mon, 14 Dec 2020 04:52:01 -0800 (PST) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id j15sm31263649wrr.85.2020.12.14.04.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 04:52:00 -0800 (PST) Date: Mon, 14 Dec 2020 13:51:41 +0100 From: Jean-Philippe Brucker To: Robin Murphy Subject: Re: [PATCH v8 4/9] of/iommu: Support dma-can-stall property Message-ID: References: <20201112125519.3987595-1-jean-philippe@linaro.org> <20201112125519.3987595-5-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201214_075202_915895_41A9E43F X-CRM114-Status: GOOD ( 21.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, lorenzo.pieralisi@arm.com, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, joro@8bytes.org, guohanjun@huawei.com, rjw@rjwysocki.net, shameerali.kolothum.thodi@huawei.com, eric.auger@redhat.com, iommu@lists.linux-foundation.org, robh+dt@kernel.org, Jonathan.Cameron@huawei.com, sudeep.holla@arm.com, bhelgaas@google.com, zhangfei.gao@linaro.org, vivek.gautam@arm.com, baolu.lu@linux.intel.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, lenb@kernel.org 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 On Thu, Nov 26, 2020 at 06:09:26PM +0000, Robin Murphy wrote: > On 2020-11-12 12:55, Jean-Philippe Brucker wrote: > > Copy the dma-can-stall property into the fwspec structure. > > Can't we just handle this as a regular device property? It's not part of the > actual IOMMU specifier, it doesn't need to be translated in any way, and > AFAICS it's used a grand total of once, in a slow path. Simply treating it > as the per-device property that it is should require zero additional code > for DT, and a simple device_add_properties() call for IORT. > > TBH that appears to be true of pasid-num-bits as well. Right I think that's better, thanks for the pointer. I'll take care of pasid-num-bits too. The Huawei quirk (fake PCIe supporting stall) is a little worse this way, but it should work. Thanks, Jean --- Diff untested on ACPI: diff --git a/include/linux/iommu.h b/include/linux/iommu.h index e7b40e569488..ad5c55bc45b2 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -591,8 +591,6 @@ struct iommu_group *fsl_mc_device_group(struct device *dev); struct iommu_fwspec { const struct iommu_ops *ops; struct fwnode_handle *iommu_fwnode; - u32 num_pasid_bits; - bool can_stall; unsigned int num_ids; u32 ids[]; }; diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index aa76e775bd6d..1582f6585741 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -960,16 +960,19 @@ static int iort_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data) static void iort_named_component_init(struct device *dev, struct acpi_iort_node *node) { + struct property_entry props[3] = {}; struct acpi_iort_named_component *nc; - struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); - - if (!fwspec) - return; nc = (struct acpi_iort_named_component *)node->node_data; - fwspec->num_pasid_bits = FIELD_GET(ACPI_IORT_NC_PASID_BITS, - nc->node_flags); - fwspec->can_stall = (nc->node_flags & ACPI_IORT_NC_STALL_SUPPORTED); + + props[0] = PROPERTY_ENTRY_U32("pasid-num-bits", + FIELD_GET(ACPI_IORT_NC_PASID_BITS, + nc->node_flags)); + if (nc->node_flags & ACPI_IORT_NC_STALL_SUPPORTED) + props[1] = PROPERTY_ENTRY_BOOL("dma-can-stall"); + + if (device_add_properties(dev, props)) + dev_warn(dev, "Could not register device properties\n"); } static int iort_nc_iommu_map(struct device *dev, struct acpi_iort_node *node) 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 521ec7f0b2a0..571bd7c35a62 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2842,7 +2842,8 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev) if (ret) goto err_free_master; - master->ssid_bits = min(smmu->ssid_bits, fwspec->num_pasid_bits); + device_property_read_u32(dev, "pasid-num-bits", &master->ssid_bits); + master->ssid_bits = min(smmu->ssid_bits, master->ssid_bits); /* * Note that PASID must be enabled before, and disabled after ATS: @@ -2858,7 +2859,8 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev) master->ssid_bits = min_t(u8, master->ssid_bits, CTXDESC_LINEAR_CDMAX); - if ((smmu->features & ARM_SMMU_FEAT_STALLS && fwspec->can_stall) || + if ((smmu->features & ARM_SMMU_FEAT_STALLS && + device_property_read_bool(dev, "dma-can-stall")) || smmu->features & ARM_SMMU_FEAT_STALL_FORCE) master->stall_enabled = true; diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index d6255ca823d8..a9d2df001149 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -210,14 +210,6 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, of_pci_iommu_init, &info); } else { err = of_iommu_configure_device(master_np, dev, id); - - fwspec = dev_iommu_fwspec_get(dev); - if (!err && fwspec) { - of_property_read_u32(master_np, "pasid-num-bits", - &fwspec->num_pasid_bits); - fwspec->can_stall = of_property_read_bool(master_np, - "dma-can-stall"); - } } /* diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 324dbe55836c..13a43a3d6347 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1828,12 +1828,17 @@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, PCI_CLASS_BRIDGE_PCI static void quirk_huawei_pcie_sva(struct pci_dev *pdev) { - struct iommu_fwspec *fwspec; + struct property_entry properties[] = { + PROPERTY_ENTRY_BOOL("dma-can-stall"), + {}, + }; pdev->eetlp_prefix_path = 1; - fwspec = dev_iommu_fwspec_get(&pdev->dev); - if (fwspec) - fwspec->can_stall = 1; + + /* Device-tree can set the stall property */ + if (!pdev->dev.of_node && + device_add_properties(&pdev->dev, properties)) + pci_warn(pdev, "could not add stall property"); } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa250, quirk_huawei_pcie_sva); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel