LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Logan Gunthorpe <email@example.com> To: Bjorn Helgaas <firstname.lastname@example.org>, Doug Meyer <email@example.com> Cc: firstname.lastname@example.org, email@example.com, linux-ntb <firstname.lastname@example.org>, Bjorn Helgaas <email@example.com>, Jon Mason <firstname.lastname@example.org>, "Jiang, Dave" <email@example.com>, Allen Hubbe <firstname.lastname@example.org>, email@example.com, Alex Williamson <firstname.lastname@example.org> Subject: Re: [PATCH 2/2] NTB: PCI Quirk to Enable Switchtec NT Functionality with IOMMU On Date: Tue, 22 May 2018 16:23:13 -0600 [thread overview] Message-ID: <email@example.com> (raw) In-Reply-To: <20180522215126.GA22385@bhelgaas-glaptop.roam.corp.google.com> On 22/05/18 03:51 PM, Bjorn Helgaas wrote: > I don't think the question of when the aliases need to be added is > quite closed. Logan said "it seems pci_add_dma_alias() must be called > before the driver is initialized and therefore in a quirk", but that > doesn't make clear *why* the alias needs to be added before the driver > is initialized. The alias shouldn't be needed until the device does a > DMA, and it shouldn't do that until after the driver initializes. No, Doug tried it in the driver first and it didn't work. The symbol is also not exported which was probably done because it can't be used in the driver. > I suspect the reason the existing quirks are in drivers/pci/quirks.c > is because the IOMMU driver is in the host OS, but the host may not > have a driver for the device if the device is passed through to a > guest OS. In that case, the only way to add the alias is by using a > quirk that is always built into the host OS. Digging into the code a bit, it's not because it must be done by the Host OS but because it must be done before the IOMMU groups are created. The IOMMU code registers a bus_notifier and creates the groups based on the dma_alias mask when it receives the BUS_NOTIFY_ADD_DEVICE event. This event is notified in device_add() just before a call to bus_probe_device(). Therefore, if a driver attempts to use pci_add_dma_alias() as part of it's probe routine, it will be too late as the IOMMU has already setup the groups based on the original version of the dma_alias_mask. I suspect this is by design as the groups must be created before and any dma_maps are done on the device and some drivers may create dma_maps during probe. Logan  https://elixir.bootlin.com/linux/v4.17-rc6/source/drivers/base/core.c#L1863
next prev parent reply other threads:[~2018-05-22 22:23 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-17 12:00 [PATCH 0/2] PCI Quirk Patchset for Microsemi Switchtec NTB dmeyer 2018-05-17 12:00 ` [PATCH 1/2] NTB: Migrate PCI Constants to Cannonical PCI Header dmeyer 2018-05-17 13:25 ` Bjorn Helgaas 2018-05-17 12:00 ` [PATCH 2/2] NTB: PCI Quirk to Enable Switchtec NT Functionality with IOMMU On dmeyer 2018-05-17 13:45 ` Bjorn Helgaas 2018-05-17 16:06 ` Logan Gunthorpe [not found] ` <CA+GK6en+g+T9H0sOMdVXv-_aD3rRcuzZ1JdfK0moEoTuuJnrqQ@mail.gmail.com> 2018-05-22 21:51 ` Bjorn Helgaas 2018-05-22 22:13 ` Alex Williamson 2018-05-22 22:23 ` Logan Gunthorpe [this message] 2018-05-23 13:33 ` Bjorn Helgaas 2018-05-23 20:21 ` Logan Gunthorpe 2018-05-17 15:48 ` Logan Gunthorpe 2018-05-22 21:08 ` Doug Meyer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).