From patchwork Fri Nov 22 10:49:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 180033 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp66658ilf; Fri, 22 Nov 2019 03:16:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwh+QYbJI/vKpjRVFMMkS8UVok7gDxgrUlRW+W7iQ2227KnikJwWsjQ/DG+MuTegoGJXmuG X-Received: by 2002:a50:930c:: with SMTP id m12mr373703eda.132.1574421372210; Fri, 22 Nov 2019 03:16:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574421372; cv=none; d=google.com; s=arc-20160816; b=AfJqQUhWA+IabFUCIRQSUwZgjjB5F3yOjhDfOkYJgK/bVnOcG3Exd+oSHFrxAahBA7 qnbeYr9kkFFQqr9Uur4Mw9QIIK+mo0PQN5Pq+UDkMP05yvJKU7/GvZuDItgBMeOLHIKj TD1qcbC8LIVhQcx6YZE7sRDslNE7C8epXMHHjlJPNdaVI3v+V3sYDrWwQYsVNU4L3A+Z GM5D34eWzK5LVwMGtT8WCR+Ze1Ko5esX4dsDkn8enzTuPyEGwLxT0nJ/AZyToUr4K9Qi Ti6E2zV9RuLNR56a+wWNfPS916UV19XZ46cLp02iOzlUaNRexSnla32M1wApCbdmMONu gWTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GmQroTy0ZSrB9+ytyBw658P0+bfjBqqeFkyQrRlY2fc=; b=p6mbQfkCMn1ZlJcpX9dsJukLwxITlSWSarw+wK+98TENeQGYBv5w4idF7Qlmp4dqhQ 4497qE7T37ma3YfTPuJkPtipgaM5wr0Tuqh5vwMmcHsJO628QUyUYNbJEj6s4IpRAt04 8LlnxvQlPpgS9piVKUfvUDNJ+mFNUz5g0fupdoGxQCkPjPQLQCQxaPN5NsaS+pU0nMJV rlHjrF4dHCeDPjPINkmpt9EWIglcKv7xYnsqiERxIUJNlXk2RITV4XwbmIx926xRjr0V kMCCwcZ4Ixa+4zVURSUSVmN7RnG6R8MnIl4SXhiT9uxRxXr2EFQOr/RXOvi0eiwXYRvh RJow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="R/GX7Gpn"; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si3801343ejb.419.2019.11.22.03.16.12; Fri, 22 Nov 2019 03:16:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="R/GX7Gpn"; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728529AbfKVLQK (ORCPT + 7 others); Fri, 22 Nov 2019 06:16:10 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51144 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729527AbfKVKvD (ORCPT ); Fri, 22 Nov 2019 05:51:03 -0500 Received: by mail-wm1-f68.google.com with SMTP id l17so6945970wmh.0 for ; Fri, 22 Nov 2019 02:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GmQroTy0ZSrB9+ytyBw658P0+bfjBqqeFkyQrRlY2fc=; b=R/GX7GpncHdtpCGTNb9LZDYyir4t0PAmFjI7FlT5nol5eGqh3g9UoW1PBFoTNplogC SVaBaD4hexSWM3jfSYqGTKlvokoECPyser6aGFmjBzeKT2/KrCawSXcvu8mgYtMRxIMj tjqCar++xgaYfLYaRy3XdgFwRtpRlR7HYSWpL7hpbcrnKLQ/CT50WIpJ4qwVNNF+zNZc UXwNi6d2mNmRLawPvPUm7CP8glqP2G8DYGV8VDXJ3clmTzacXVLkJQNgq1AhzYbkUbhk G7dh/PVGzK1sEon1bwZfxl1rMOZ3neP3I9WNi3BrtVhqN5GNfDY+HDZVheLdZIq1uKyx Bdyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GmQroTy0ZSrB9+ytyBw658P0+bfjBqqeFkyQrRlY2fc=; b=Ct9B8Jv9VF17GZzXjRcRAMBWzlExtW1gOGS0ZRK+BDWxe73ZmrTcl56DH3SqFvTxIl y++QFmtphDR/ke9zyI2QT0c/b1ZsLzsjPIoRY4TYEv8AWVZivnt6P7fJ+JmqA8pJlygI ByYk121HxseykUJpg9qbGGpkx2DSxg8DeKfIfd6tXwQj6vCazPYjBg3Cur5wDPtL8n8/ XywodlNQNa7kBoKzQqa6k6kdGNGRqKricCtbGc7HDZHGn6mptsc5pl0GnBJc962VIWRc R5+F+VDk5GkYoaRZjdUYJzSQ3IOvJjguBS4PfDd3thzSoS6Z5x9qfRd3Ll68k3qbPY6F 6JIQ== X-Gm-Message-State: APjAAAVm6EByMjXjiicqHaxU9rV4ZyCGzr/tdpsOpR7bIVCjuSegcal/ yqLc+sF9JL8BbVTGG+4g1P62l5jV/zw= X-Received: by 2002:a1c:f702:: with SMTP id v2mr8729559wmh.157.1574419861629; Fri, 22 Nov 2019 02:51:01 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-204-106.adslplus.ch. [188.155.204.106]) by smtp.gmail.com with ESMTPSA id o133sm2088197wmb.4.2019.11.22.02.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2019 02:51:01 -0800 (PST) From: Jean-Philippe Brucker To: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, linux-pci@vger.kernel.org, virtio-dev@lists.oasis-open.org Cc: rjw@rjwysocki.net, lenb@kernel.org, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, gregkh@linuxfoundation.org, joro@8bytes.org, bhelgaas@google.com, mst@redhat.com, jasowang@redhat.com, jacob.jun.pan@intel.com, eric.auger@redhat.com, sebastien.boeuf@intel.com, kevin.tian@intel.com Subject: [RFC 08/13] ACPI/IORT: Add callback to update a device's fwnode Date: Fri, 22 Nov 2019 11:49:55 +0100 Message-Id: <20191122105000.800410-9-jean-philippe@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122105000.800410-1-jean-philippe@linaro.org> References: <20191122105000.800410-1-jean-philippe@linaro.org> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org For a PCI-based IOMMU, IORT isn't in charge of allocating a fwnode. Let the IOMMU driver update the fwnode associated to an IORT node when available. Signed-off-by: Jean-Philippe Brucker --- drivers/acpi/iort.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/acpi_iort.h | 4 ++++ 2 files changed, 42 insertions(+) -- 2.24.0 diff --git a/drivers/acpi/iort.c b/drivers/acpi/iort.c index f08f72d8af78..8263ab275b2b 100644 --- a/drivers/acpi/iort.c +++ b/drivers/acpi/iort.c @@ -1038,11 +1038,49 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) return ops; } + +/** + * iort_iommu_update_fwnode - update fwnode of a PCI IOMMU + * @dev: the IOMMU device + * @fwnode: the fwnode, or NULL to remove an existing fwnode + * + * A PCI device isn't instantiated by the IORT driver. The IOMMU driver sets or + * removes its fwnode using this function. + */ +void iort_iommu_update_fwnode(struct device *dev, struct fwnode_handle *fwnode) +{ + struct pci_dev *pdev; + struct iort_fwnode *curr; + struct iort_pci_devid *devid; + + if (!dev_is_pci(dev)) + return; + + pdev = to_pci_dev(dev); + + spin_lock(&iort_fwnode_lock); + list_for_each_entry(curr, &iort_fwnode_list, list) { + devid = curr->pci_devid; + if (devid && + pci_domain_nr(pdev->bus) == devid->segment && + pdev->bus->number == devid->bus && + pdev->devfn == devid->devfn) { + WARN_ON(fwnode && curr->fwnode); + curr->fwnode = fwnode; + break; + } + } + spin_unlock(&iort_fwnode_lock); +} +EXPORT_SYMBOL_GPL(iort_iommu_update_fwnode); #else int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head) { return 0; } const struct iommu_ops *iort_iommu_configure(struct device *dev) { return NULL; } +static void iort_iommu_update_fwnode(struct device *dev, + struct fwnode_handle *fwnode) +{ } #endif static int nc_dma_get_range(struct device *dev, u64 *size) diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h index f4db5fff07cf..840635e40d9d 100644 --- a/include/linux/acpi_iort.h +++ b/include/linux/acpi_iort.h @@ -43,6 +43,7 @@ int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id); void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *size); const struct iommu_ops *iort_iommu_configure(struct device *dev); int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head); +void iort_iommu_update_fwnode(struct device *dev, struct fwnode_handle *fwnode); #else static void acpi_iort_register_table(struct acpi_table_header *table, enum iort_table_source source) @@ -63,6 +64,9 @@ static inline const struct iommu_ops *iort_iommu_configure( static inline int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head) { return 0; } +static void iort_iommu_update_fwnode(struct device *dev, + struct fwnode_handle *fwnode) +{ } #endif #endif /* __ACPI_IORT_H__ */