From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933041AbcFJMrD (ORCPT ); Fri, 10 Jun 2016 08:47:03 -0400 Received: from mail-lf0-f46.google.com ([209.85.215.46]:36440 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932435AbcFJMrA (ORCPT ); Fri, 10 Jun 2016 08:47:00 -0400 Subject: Re: [RFC PATCH v2 13/15] drivers: acpi: iort: introduce iort_iommu_configure To: Lorenzo Pieralisi , iommu@lists.linux-foundation.org References: <1465306270-27076-1-git-send-email-lorenzo.pieralisi@arm.com> <1465306270-27076-14-git-send-email-lorenzo.pieralisi@arm.com> Cc: Hanjun Guo , "Rafael J. Wysocki" , Will Deacon , Marc Zyngier , Robin Murphy , Joerg Roedel , Jon Masters , Sinan Kaya , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org From: Tomasz Nowicki Message-ID: <575AB6C0.4050808@semihalf.com> Date: Fri, 10 Jun 2016 14:46:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1465306270-27076-14-git-send-email-lorenzo.pieralisi@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07.06.2016 15:31, Lorenzo Pieralisi wrote: > +static int __get_pci_rid(struct pci_dev *pdev, u16 alias, void *data) > +{ > + u32 *rid = data; > + > + *rid = alias; > + return 0; > +} > + > +/** > + * iort_iommu_configure - Set-up IOMMU configuration for a device. > + * > + * @dev: device to configure > + * > + * Returns: iommu_ops pointer on configuration success > + * NULL on configuration failure > + */ > +const struct iommu_ops *iort_iommu_configure(struct device *dev) > +{ > + struct acpi_iort_node *node, *parent; > + const struct iort_ops_node *iort_ops; > + u32 rid = 0, devid = 0; > + > + if (dev_is_pci(dev)) { > + struct pci_bus *bus = to_pci_dev(dev)->bus; > + > + pci_for_each_dma_alias(to_pci_dev(dev), __get_pci_rid, > + &rid); I think we should find here the root bus which is connected to RC IORT node. > + > + node = iort_scan_node(ACPI_IORT_NODE_PCI_ROOT_COMPLEX, > + iort_find_dev_callback, &bus->dev); > + } else { > + node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, > + iort_find_dev_callback, dev); > + } > + > + if (!node) > + return NULL; > + > + parent = iort_find_parent_node(node); > + > + if (!parent) > + return NULL; > + > + iort_ops = iort_smmu_get_ops_node(parent); > + > + if (iort_ops && iort_ops->iommu_xlate) { > + iort_dev_map_rid(node, rid, &devid, parent->type); > + iort_ops->iommu_xlate(dev, devid, parent); > + return iort_ops->ops; > + } > + > + return NULL; > +} > + Thanks, Tomasz