Thx Will, On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: > > I'll keep my system use the same ASID for SMP + IOMMU :P > > You will want a separate allocator for that: > > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.brucker@arm.com Yes, it is hard to maintain ASID between IOMMU and CPUMMU or different system, because it's difficult to synchronize the IO_ASID when the CPU ASID is rollover. But we could still use hardware broadcast TLB invalidation instruction to uniformly manage the ASID and IO_ASID, or OTHER_ASID in our IOMMU. Welcome to join our disscusion: "Introduce an implementation of IOMMU in linux-riscv" 9 Sep 2019, 10:45 Jade-room-I&II (Corinthia Hotel Lisbon) RISC-V MC -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: > On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: > > > I'll keep my system use the same ASID for SMP + IOMMU :P > > > > You will want a separate allocator for that: > > > > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.brucker@arm.com > > Yes, it is hard to maintain ASID between IOMMU and CPUMMU or different > system, because it's difficult to synchronize the IO_ASID when the CPU > ASID is rollover. > But we could still use hardware broadcast TLB invalidation instruction > to uniformly manage the ASID and IO_ASID, or OTHER_ASID in our IOMMU. That's probably a bad idea, because you'll likely stall execution on the CPU until the IOTLB has completed invalidation. In the case of ATS, I think an endpoint ATC is permitted to take over a minute to respond. In reality, I suspect the worst you'll ever see would be in the msec range, but that's still an unacceptable period of time to hold a CPU. > Welcome to join our disscusion: > "Introduce an implementation of IOMMU in linux-riscv" > 9 Sep 2019, 10:45 Jade-room-I&II (Corinthia Hotel Lisbon) RISC-V MC I attended this session, but it unfortunately raised many more questions than it answered. Will _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Thx Will for reply. On Thu, Sep 12, 2019 at 3:03 PM Will Deacon <will@kernel.org> wrote: > > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: > > On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: > > > > I'll keep my system use the same ASID for SMP + IOMMU :P > > > > > > You will want a separate allocator for that: > > > > > > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.brucker@arm.com > > > > Yes, it is hard to maintain ASID between IOMMU and CPUMMU or different > > system, because it's difficult to synchronize the IO_ASID when the CPU > > ASID is rollover. > > But we could still use hardware broadcast TLB invalidation instruction > > to uniformly manage the ASID and IO_ASID, or OTHER_ASID in our IOMMU. > > That's probably a bad idea, because you'll likely stall execution on the > CPU until the IOTLB has completed invalidation. In the case of ATS, I think > an endpoint ATC is permitted to take over a minute to respond. In reality, I > suspect the worst you'll ever see would be in the msec range, but that's > still an unacceptable period of time to hold a CPU. Just as I've said in the session that IOTLB invalidate delay is another topic, My main proposal is to introduce stage1.pgd and stage2.pgd as address space identifiers between different TLB systems based on vmid, asid. My last part of sildes will show you how to translate stage1/2.pgd to as/vmid in PCI ATS system and the method could work with SMMU-v3 and intel Vt-d. (It's regret for me there is no time to show you the whole slides.) In our light IOMMU implementation, there's no IOTLB invalidate delay problem. Becasue IOMMU is very close to CPU MMU and interconnect's delay is the same with SMP CPUs MMU (no PCI, VM supported). To solve the problem, we could define a async mode in sfence.vma.b to slove the problem and finished with per_cpu_irq/exception. -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[-- Attachment #1.1: Type: text/plain, Size: 2641 bytes --] Another idea is seperate remote TLB invalidate into two instructions: - sfence.vma.b.asyc - sfence.vma.b.barrier // wait all async TLB invalidate operations finished for all harts. (I remember who mentioned me separate them into two instructions after session. Anup? Is the idea right ?) Actually, I never consider asyc TLB invalidate before, because current our light iommu did not need it. Thx all people attend the session :) Let's continue the talk. Guo Ren <guoren@kernel.org> 于 2019年9月12日周四 22:59写道: > Thx Will for reply. > > On Thu, Sep 12, 2019 at 3:03 PM Will Deacon <will@kernel.org> wrote: > > > > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: > > > On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: > > > > > I'll keep my system use the same ASID for SMP + IOMMU :P > > > > > > > > You will want a separate allocator for that: > > > > > > > > > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.brucker@arm.com > > > > > > Yes, it is hard to maintain ASID between IOMMU and CPUMMU or different > > > system, because it's difficult to synchronize the IO_ASID when the CPU > > > ASID is rollover. > > > But we could still use hardware broadcast TLB invalidation instruction > > > to uniformly manage the ASID and IO_ASID, or OTHER_ASID in our IOMMU. > > > > That's probably a bad idea, because you'll likely stall execution on the > > CPU until the IOTLB has completed invalidation. In the case of ATS, I > think > > an endpoint ATC is permitted to take over a minute to respond. In > reality, I > > suspect the worst you'll ever see would be in the msec range, but that's > > still an unacceptable period of time to hold a CPU. > Just as I've said in the session that IOTLB invalidate delay is > another topic, My main proposal is to introduce stage1.pgd and > stage2.pgd as address space identifiers between different TLB systems > based on vmid, asid. My last part of sildes will show you how to > translate stage1/2.pgd to as/vmid in PCI ATS system and the method > could work with SMMU-v3 and intel Vt-d. (It's regret for me there is > no time to show you the whole slides.) > > In our light IOMMU implementation, there's no IOTLB invalidate delay > problem. Becasue IOMMU is very close to CPU MMU and interconnect's > delay is the same with SMP CPUs MMU (no PCI, VM supported). > > To solve the problem, we could define a async mode in sfence.vma.b to > slove the problem and finished with per_cpu_irq/exception. > > -- > Best Regards > Guo Ren > > ML: https://lore.kernel.org/linux-csky/ > [-- Attachment #1.2: Type: text/html, Size: 3733 bytes --] [-- Attachment #2: Type: text/plain, Size: 156 bytes --] _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Here is the presentation, any comments is welcome. https://docs.google.com/presentation/d/1sc295JznVAfDIPieAqzjcyUkcHnNFQsK8FFqdoCY854/edit?usp=sharing On Fri, Sep 13, 2019 at 3:13 PM Guo Ren <guoren@kernel.org> wrote: > > Another idea is seperate remote TLB invalidate into two instructions: > > - sfence.vma.b.asyc > - sfence.vma.b.barrier // wait all async TLB invalidate operations finished for all harts. > > (I remember who mentioned me separate them into two instructions after session. Anup? Is the idea right ?) > > Actually, I never consider asyc TLB invalidate before, because current our light iommu did not need it. > > Thx all people attend the session :) Let's continue the talk. > > > Guo Ren <guoren@kernel.org> 于 2019年9月12日周四 22:59写道: >> >> Thx Will for reply. >> >> On Thu, Sep 12, 2019 at 3:03 PM Will Deacon <will@kernel.org> wrote: >> > >> > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: >> > > On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: >> > > > > I'll keep my system use the same ASID for SMP + IOMMU :P >> > > > >> > > > You will want a separate allocator for that: >> > > > >> > > > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.brucker@arm.com >> > > >> > > Yes, it is hard to maintain ASID between IOMMU and CPUMMU or different >> > > system, because it's difficult to synchronize the IO_ASID when the CPU >> > > ASID is rollover. >> > > But we could still use hardware broadcast TLB invalidation instruction >> > > to uniformly manage the ASID and IO_ASID, or OTHER_ASID in our IOMMU. >> > >> > That's probably a bad idea, because you'll likely stall execution on the >> > CPU until the IOTLB has completed invalidation. In the case of ATS, I think >> > an endpoint ATC is permitted to take over a minute to respond. In reality, I >> > suspect the worst you'll ever see would be in the msec range, but that's >> > still an unacceptable period of time to hold a CPU. >> Just as I've said in the session that IOTLB invalidate delay is >> another topic, My main proposal is to introduce stage1.pgd and >> stage2.pgd as address space identifiers between different TLB systems >> based on vmid, asid. My last part of sildes will show you how to >> translate stage1/2.pgd to as/vmid in PCI ATS system and the method >> could work with SMMU-v3 and intel Vt-d. (It's regret for me there is >> no time to show you the whole slides.) >> >> In our light IOMMU implementation, there's no IOTLB invalidate delay >> problem. Becasue IOMMU is very close to CPU MMU and interconnect's >> delay is the same with SMP CPUs MMU (no PCI, VM supported). >> >> To solve the problem, we could define a async mode in sfence.vma.b to >> slove the problem and finished with per_cpu_irq/exception. >> >> -- >> Best Regards >> Guo Ren >> >> ML: https://lore.kernel.org/linux-csky/ -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
On Thu, 12 Sep 2019 07:02:56 PDT (-0700), will@kernel.org wrote: > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: >> On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: >> > > I'll keep my system use the same ASID for SMP + IOMMU :P >> > >> > You will want a separate allocator for that: >> > >> > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.brucker@arm.com >> >> Yes, it is hard to maintain ASID between IOMMU and CPUMMU or different >> system, because it's difficult to synchronize the IO_ASID when the CPU >> ASID is rollover. >> But we could still use hardware broadcast TLB invalidation instruction >> to uniformly manage the ASID and IO_ASID, or OTHER_ASID in our IOMMU. > > That's probably a bad idea, because you'll likely stall execution on the > CPU until the IOTLB has completed invalidation. In the case of ATS, I think > an endpoint ATC is permitted to take over a minute to respond. In reality, I > suspect the worst you'll ever see would be in the msec range, but that's > still an unacceptable period of time to hold a CPU. > >> Welcome to join our disscusion: >> "Introduce an implementation of IOMMU in linux-riscv" >> 9 Sep 2019, 10:45 Jade-room-I&II (Corinthia Hotel Lisbon) RISC-V MC > > I attended this session, but it unfortunately raised many more questions > than it answered. Ya, we're a long way from figuring this out. _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
> -----Original Message----- > From: linux-kernel-owner@vger.kernel.org <linux-kernel- > owner@vger.kernel.org> On Behalf Of Palmer Dabbelt > Sent: Saturday, September 14, 2019 7:31 PM > To: will@kernel.org > Cc: guoren@kernel.org; Will Deacon <will.deacon@arm.com>; > julien.thierry@arm.com; aou@eecs.berkeley.edu; james.morse@arm.com; > Arnd Bergmann <arnd@arndb.de>; suzuki.poulose@arm.com; > marc.zyngier@arm.com; catalin.marinas@arm.com; Anup Patel > <Anup.Patel@wdc.com>; linux-kernel@vger.kernel.org; > rppt@linux.ibm.com; Christoph Hellwig <hch@infradead.org>; Atish Patra > <Atish.Patra@wdc.com>; julien.grall@arm.com; gary@garyguo.net; Paul > Walmsley <paul.walmsley@sifive.com>; christoffer.dall@arm.com; linux- > riscv@lists.infradead.org; kvmarm@lists.cs.columbia.edu; linux-arm- > kernel@lists.infradead.org; iommu@lists.linux-foundation.org > Subject: Re: [PATCH RFC 11/14] arm64: Move the ASID allocator code in a > separate file > > On Thu, 12 Sep 2019 07:02:56 PDT (-0700), will@kernel.org wrote: > > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: > >> On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: > >> > > I'll keep my system use the same ASID for SMP + IOMMU :P > >> > > >> > You will want a separate allocator for that: > >> > > >> > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.bruck > >> > er@arm.com > >> > >> Yes, it is hard to maintain ASID between IOMMU and CPUMMU or > >> different system, because it's difficult to synchronize the IO_ASID > >> when the CPU ASID is rollover. > >> But we could still use hardware broadcast TLB invalidation > >> instruction to uniformly manage the ASID and IO_ASID, or OTHER_ASID in > our IOMMU. > > > > That's probably a bad idea, because you'll likely stall execution on > > the CPU until the IOTLB has completed invalidation. In the case of > > ATS, I think an endpoint ATC is permitted to take over a minute to > > respond. In reality, I suspect the worst you'll ever see would be in > > the msec range, but that's still an unacceptable period of time to hold a > CPU. > > > >> Welcome to join our disscusion: > >> "Introduce an implementation of IOMMU in linux-riscv" > >> 9 Sep 2019, 10:45 Jade-room-I&II (Corinthia Hotel Lisbon) RISC-V MC > > > > I attended this session, but it unfortunately raised many more > > questions than it answered. > > Ya, we're a long way from figuring this out. For everyone's reference, here is our first attempt at RISC-V ASID allocator: http://archive.lwn.net:8080/linux-kernel/20190329045111.14040-1-anup.patel@wdc.com/T/#u Regards, Anup _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Hi, On 13/09/2019 09:13, Guo Ren wrote: > Another idea is seperate remote TLB invalidate into two instructions: > > - sfence.vma.b.asyc > - sfence.vma.b.barrier // wait all async TLB invalidate operations > finished for all harts. It's not clear to me how this helps, but I probably don't have the whole picture. If you have a place where it is safe to wait for the barrier to complete, why not do the whole invalidate there? > (I remember who mentioned me separate them into two instructions after > session. Anup? Is the idea right ?) > > Actually, I never consider asyc TLB invalidate before, because current our > light iommu did not need it. > > Thx all people attend the session :) Let's continue the talk. > > > Guo Ren <guoren@kernel.org <mailto:guoren@kernel.org>> 于 2019年9月12日周 > 四 22:59写道: > > Thx Will for reply. > > On Thu, Sep 12, 2019 at 3:03 PM Will Deacon <will@kernel.org > <mailto:will@kernel.org>> wrote: > > > > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: > > > On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org > <mailto:will@kernel.org>> wrote: > > > > > I'll keep my system use the same ASID for SMP + IOMMU :P > > > > > > > > You will want a separate allocator for that: > > > > > > > > > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.brucker@arm.com > > > > > > Yes, it is hard to maintain ASID between IOMMU and CPUMMU or different > > > system, because it's difficult to synchronize the IO_ASID when the CPU > > > ASID is rollover. > > > But we could still use hardware broadcast TLB invalidation instruction > > > to uniformly manage the ASID and IO_ASID, or OTHER_ASID in our IOMMU. > > > > That's probably a bad idea, because you'll likely stall execution on the > > CPU until the IOTLB has completed invalidation. In the case of ATS, > I think > > an endpoint ATC is permitted to take over a minute to respond. In > reality, I > > suspect the worst you'll ever see would be in the msec range, but that's > > still an unacceptable period of time to hold a CPU. > Just as I've said in the session that IOTLB invalidate delay is > another topic, My main proposal is to introduce stage1.pgd and > stage2.pgd as address space identifiers between different TLB systems > based on vmid, asid. My last part of sildes will show you how to > translate stage1/2.pgd to as/vmid in PCI ATS system and the method > could work with SMMU-v3 and intel Vt-d. (It's regret for me there is > no time to show you the whole slides.) > > In our light IOMMU implementation, there's no IOTLB invalidate delay > problem. Becasue IOMMU is very close to CPU MMU and interconnect's > delay is the same with SMP CPUs MMU (no PCI, VM supported). > > To solve the problem, we could define a async mode in sfence.vma.b to > slove the problem and finished with per_cpu_irq/exception. The solution I had to this problem is pinning the ASID [1] used by the IOMMU, to prevent the CPU from recycling the ASID on rollover. This way the CPU doesn't have to wait for IOMMU invalidations to complete, when scheduling a task that might not even have anything to do with the IOMMU. In the Arm SMMU, ASID and IOASID (PASID) are separate identifiers. IOASID indexes an entry in the context descriptor table, which contains the ASID. So with unpinned shared ASID you don't need to invalidate the ATC on rollover, since the IOASID doesn't change, but you do need to modify the context descriptor and invalidate cached versions of it. Once you have pinned ASIDs, you could also declare that IOASID = ASID. I don't remember finding an argument to strictly forbid it, even though ASID and IOASID have different sizes on Arm (respectively 8/16 and 20 bits). Thanks, Jean [1] https://lore.kernel.org/linux-iommu/20180511190641.23008-17-jean-philippe.brucker@arm.com/ _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
On Sun, Sep 15, 2019 at 05:03:38AM +0000, Anup Patel wrote: > > > > -----Original Message----- > > From: linux-kernel-owner@vger.kernel.org <linux-kernel- > > owner@vger.kernel.org> On Behalf Of Palmer Dabbelt > > Sent: Saturday, September 14, 2019 7:31 PM > > To: will@kernel.org > > Cc: guoren@kernel.org; Will Deacon <will.deacon@arm.com>; > > julien.thierry@arm.com; aou@eecs.berkeley.edu; james.morse@arm.com; > > Arnd Bergmann <arnd@arndb.de>; suzuki.poulose@arm.com; > > marc.zyngier@arm.com; catalin.marinas@arm.com; Anup Patel > > <Anup.Patel@wdc.com>; linux-kernel@vger.kernel.org; > > rppt@linux.ibm.com; Christoph Hellwig <hch@infradead.org>; Atish Patra > > <Atish.Patra@wdc.com>; julien.grall@arm.com; gary@garyguo.net; Paul > > Walmsley <paul.walmsley@sifive.com>; christoffer.dall@arm.com; linux- > > riscv@lists.infradead.org; kvmarm@lists.cs.columbia.edu; linux-arm- > > kernel@lists.infradead.org; iommu@lists.linux-foundation.org > > Subject: Re: [PATCH RFC 11/14] arm64: Move the ASID allocator code in a > > separate file > > > > On Thu, 12 Sep 2019 07:02:56 PDT (-0700), will@kernel.org wrote: > > > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: > > >> On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: > > >> > > I'll keep my system use the same ASID for SMP + IOMMU :P > > >> > > > >> > You will want a separate allocator for that: > > >> > > > >> > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.bruck > > >> > er@arm.com > > >> > > >> Yes, it is hard to maintain ASID between IOMMU and CPUMMU or > > >> different system, because it's difficult to synchronize the IO_ASID > > >> when the CPU ASID is rollover. > > >> But we could still use hardware broadcast TLB invalidation > > >> instruction to uniformly manage the ASID and IO_ASID, or OTHER_ASID in > > our IOMMU. > > > > > > That's probably a bad idea, because you'll likely stall execution on > > > the CPU until the IOTLB has completed invalidation. In the case of > > > ATS, I think an endpoint ATC is permitted to take over a minute to > > > respond. In reality, I suspect the worst you'll ever see would be in > > > the msec range, but that's still an unacceptable period of time to hold a > > CPU. > > > > > >> Welcome to join our disscusion: > > >> "Introduce an implementation of IOMMU in linux-riscv" > > >> 9 Sep 2019, 10:45 Jade-room-I&II (Corinthia Hotel Lisbon) RISC-V MC > > > > > > I attended this session, but it unfortunately raised many more > > > questions than it answered. > > > > Ya, we're a long way from figuring this out. > > For everyone's reference, here is our first attempt at RISC-V ASID allocator: > http://archive.lwn.net:8080/linux-kernel/20190329045111.14040-1-anup.patel@wdc.com/T/#u With a reply stating that the patch "absolutely does not work" ;) What exactly do you want people to do with that? It's an awful lot of effort to review this sort of stuff and given that Guo Ren is talking about sharing page tables between the CPU and an accelerator, maybe you're better off stabilising Linux for the platforms that you can actually test rather than getting so far ahead of yourselves that you end up with a bunch of wasted work on patches that probably won't get merged any time soon. Seriously, they say "walk before you can run", but this is more "crawl before you can fly". What's the rush? Will _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
On Mon, 16 Sep 2019 11:18:00 PDT (-0700), will@kernel.org wrote: > On Sun, Sep 15, 2019 at 05:03:38AM +0000, Anup Patel wrote: >> >> >> > -----Original Message----- >> > From: linux-kernel-owner@vger.kernel.org <linux-kernel- >> > owner@vger.kernel.org> On Behalf Of Palmer Dabbelt >> > Sent: Saturday, September 14, 2019 7:31 PM >> > To: will@kernel.org >> > Cc: guoren@kernel.org; Will Deacon <will.deacon@arm.com>; >> > julien.thierry@arm.com; aou@eecs.berkeley.edu; james.morse@arm.com; >> > Arnd Bergmann <arnd@arndb.de>; suzuki.poulose@arm.com; >> > marc.zyngier@arm.com; catalin.marinas@arm.com; Anup Patel >> > <Anup.Patel@wdc.com>; linux-kernel@vger.kernel.org; >> > rppt@linux.ibm.com; Christoph Hellwig <hch@infradead.org>; Atish Patra >> > <Atish.Patra@wdc.com>; julien.grall@arm.com; gary@garyguo.net; Paul >> > Walmsley <paul.walmsley@sifive.com>; christoffer.dall@arm.com; linux- >> > riscv@lists.infradead.org; kvmarm@lists.cs.columbia.edu; linux-arm- >> > kernel@lists.infradead.org; iommu@lists.linux-foundation.org >> > Subject: Re: [PATCH RFC 11/14] arm64: Move the ASID allocator code in a >> > separate file >> > >> > On Thu, 12 Sep 2019 07:02:56 PDT (-0700), will@kernel.org wrote: >> > > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: >> > >> On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> wrote: >> > >> > > I'll keep my system use the same ASID for SMP + IOMMU :P >> > >> > >> > >> > You will want a separate allocator for that: >> > >> > >> > >> > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.bruck >> > >> > er@arm.com >> > >> >> > >> Yes, it is hard to maintain ASID between IOMMU and CPUMMU or >> > >> different system, because it's difficult to synchronize the IO_ASID >> > >> when the CPU ASID is rollover. >> > >> But we could still use hardware broadcast TLB invalidation >> > >> instruction to uniformly manage the ASID and IO_ASID, or OTHER_ASID in >> > our IOMMU. >> > > >> > > That's probably a bad idea, because you'll likely stall execution on >> > > the CPU until the IOTLB has completed invalidation. In the case of >> > > ATS, I think an endpoint ATC is permitted to take over a minute to >> > > respond. In reality, I suspect the worst you'll ever see would be in >> > > the msec range, but that's still an unacceptable period of time to hold a >> > CPU. >> > > >> > >> Welcome to join our disscusion: >> > >> "Introduce an implementation of IOMMU in linux-riscv" >> > >> 9 Sep 2019, 10:45 Jade-room-I&II (Corinthia Hotel Lisbon) RISC-V MC >> > > >> > > I attended this session, but it unfortunately raised many more >> > > questions than it answered. >> > >> > Ya, we're a long way from figuring this out. >> >> For everyone's reference, here is our first attempt at RISC-V ASID allocator: >> http://archive.lwn.net:8080/linux-kernel/20190329045111.14040-1-anup.patel@wdc.com/T/#u > > With a reply stating that the patch "absolutely does not work" ;) > > What exactly do you want people to do with that? It's an awful lot of effort > to review this sort of stuff and given that Guo Ren is talking about sharing > page tables between the CPU and an accelerator, maybe you're better off > stabilising Linux for the platforms that you can actually test rather than > getting so far ahead of yourselves that you end up with a bunch of wasted > work on patches that probably won't get merged any time soon. > > Seriously, they say "walk before you can run", but this is more "crawl > before you can fly". What's the rush? I agree, and I think I've been pretty clear here: we're not merging this ASID stuff until we have a platform we can test on, particularly as the platforms we have now already need some wacky hacks around TLB flushing that we haven't gotten to the bottom of. > Will _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
> -----Original Message----- > From: linux-kernel-owner@vger.kernel.org <linux-kernel- > owner@vger.kernel.org> On Behalf Of Will Deacon > Sent: Monday, September 16, 2019 11:48 PM > To: Anup Patel <Anup.Patel@wdc.com> > Cc: Palmer Dabbelt <palmer@sifive.com>; guoren@kernel.org; Will Deacon > <will.deacon@arm.com>; julien.thierry@arm.com; aou@eecs.berkeley.edu; > james.morse@arm.com; Arnd Bergmann <arnd@arndb.de>; > suzuki.poulose@arm.com; marc.zyngier@arm.com; > catalin.marinas@arm.com; linux-kernel@vger.kernel.org; > rppt@linux.ibm.com; Christoph Hellwig <hch@infradead.org>; Atish Patra > <Atish.Patra@wdc.com>; julien.grall@arm.com; gary@garyguo.net; Paul > Walmsley <paul.walmsley@sifive.com>; christoffer.dall@arm.com; linux- > riscv@lists.infradead.org; kvmarm@lists.cs.columbia.edu; linux-arm- > kernel@lists.infradead.org; iommu@lists.linux-foundation.org > Subject: Re: [PATCH RFC 11/14] arm64: Move the ASID allocator code in a > separate file > > On Sun, Sep 15, 2019 at 05:03:38AM +0000, Anup Patel wrote: > > > > > > > -----Original Message----- > > > From: linux-kernel-owner@vger.kernel.org <linux-kernel- > > > owner@vger.kernel.org> On Behalf Of Palmer Dabbelt > > > Sent: Saturday, September 14, 2019 7:31 PM > > > To: will@kernel.org > > > Cc: guoren@kernel.org; Will Deacon <will.deacon@arm.com>; > > > julien.thierry@arm.com; aou@eecs.berkeley.edu; > james.morse@arm.com; > > > Arnd Bergmann <arnd@arndb.de>; suzuki.poulose@arm.com; > > > marc.zyngier@arm.com; catalin.marinas@arm.com; Anup Patel > > > <Anup.Patel@wdc.com>; linux-kernel@vger.kernel.org; > > > rppt@linux.ibm.com; Christoph Hellwig <hch@infradead.org>; Atish > > > Patra <Atish.Patra@wdc.com>; julien.grall@arm.com; gary@garyguo.net; > > > Paul Walmsley <paul.walmsley@sifive.com>; christoffer.dall@arm.com; > > > linux- riscv@lists.infradead.org; kvmarm@lists.cs.columbia.edu; > > > linux-arm- kernel@lists.infradead.org; > > > iommu@lists.linux-foundation.org > > > Subject: Re: [PATCH RFC 11/14] arm64: Move the ASID allocator code > > > in a separate file > > > > > > On Thu, 12 Sep 2019 07:02:56 PDT (-0700), will@kernel.org wrote: > > > > On Sun, Sep 08, 2019 at 07:52:55AM +0800, Guo Ren wrote: > > > >> On Mon, Jun 24, 2019 at 6:40 PM Will Deacon <will@kernel.org> > wrote: > > > >> > > I'll keep my system use the same ASID for SMP + IOMMU :P > > > >> > > > > >> > You will want a separate allocator for that: > > > >> > > > > >> > https://lkml.kernel.org/r/20190610184714.6786-2-jean-philippe.b > > > >> > ruck > > > >> > er@arm.com > > > >> > > > >> Yes, it is hard to maintain ASID between IOMMU and CPUMMU or > > > >> different system, because it's difficult to synchronize the > > > >> IO_ASID when the CPU ASID is rollover. > > > >> But we could still use hardware broadcast TLB invalidation > > > >> instruction to uniformly manage the ASID and IO_ASID, or > > > >> OTHER_ASID in > > > our IOMMU. > > > > > > > > That's probably a bad idea, because you'll likely stall execution > > > > on the CPU until the IOTLB has completed invalidation. In the case > > > > of ATS, I think an endpoint ATC is permitted to take over a minute > > > > to respond. In reality, I suspect the worst you'll ever see would > > > > be in the msec range, but that's still an unacceptable period of > > > > time to hold a > > > CPU. > > > > > > > >> Welcome to join our disscusion: > > > >> "Introduce an implementation of IOMMU in linux-riscv" > > > >> 9 Sep 2019, 10:45 Jade-room-I&II (Corinthia Hotel Lisbon) RISC-V > > > >> MC > > > > > > > > I attended this session, but it unfortunately raised many more > > > > questions than it answered. > > > > > > Ya, we're a long way from figuring this out. > > > > For everyone's reference, here is our first attempt at RISC-V ASID allocator: > > http://archive.lwn.net:8080/linux-kernel/20190329045111.14040-1-anup.p > > atel@wdc.com/T/#u > > With a reply stating that the patch "absolutely does not work" ;) This patch was tested on existing HW (which does not have ASID implementation) and tested on QEMU (which has very simplistic Implementation of ASID). When I asked Gary Guo about way to get access to their HW (in same patch email thread), I did not get any reply. After so many months passed, I now doubt the his comment "absolutely does not work". > > What exactly do you want people to do with that? It's an awful lot of effort to > review this sort of stuff and given that Guo Ren is talking about sharing page > tables between the CPU and an accelerator, maybe you're better off > stabilising Linux for the platforms that you can actually test rather than > getting so far ahead of yourselves that you end up with a bunch of wasted > work on patches that probably won't get merged any time soon. The intention of the ASID patch was to encourage RISC-V implementations having ASID in HW and also ensure that things don't break on existing HW. I don't see our efforts being wasted in trying to make Linux RISC-V feature complete and encouraging more feature rich RISC-V CPUs. Delays in merging patches are fine as long as people have something to try on their RISC-V CPU implementations. > > Seriously, they say "walk before you can run", but this is more "crawl before > you can fly". What's the rush? > > Will Regards, Anup _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Hi, On Mon, Sep 16, 2019 at 8:57 PM Jean-Philippe Brucker <jean-philippe@linaro.org> wrote: > On 13/09/2019 09:13, Guo Ren wrote: > > Another idea is seperate remote TLB invalidate into two instructions: > > > > - sfence.vma.b.asyc > > - sfence.vma.b.barrier // wait all async TLB invalidate operations > > finished for all harts. > > It's not clear to me how this helps, but I probably don't have the whole > picture. If you have a place where it is safe to wait for the barrier to > complete, why not do the whole invalidate there? > > > (I remember who mentioned me separate them into two instructions after > > session. Anup? Is the idea right ?) Forget it, I still use irq signal in my formal proposal [1]. I also couldn't image the whole picture :P > > To solve the problem, we could define a async mode in sfence.vma.b to > > slove the problem and finished with per_cpu_irq/exception. > > The solution I had to this problem is pinning the ASID [1] used by the > IOMMU, to prevent the CPU from recycling the ASID on rollover. This way > the CPU doesn't have to wait for IOMMU invalidations to complete, when > scheduling a task that might not even have anything to do with the IOMMU. > > In the Arm SMMU, ASID and IOASID (PASID) are separate identifiers. IOASID > indexes an entry in the context descriptor table, which contains the ASID. > So with unpinned shared ASID you don't need to invalidate the ATC on > rollover, since the IOASID doesn't change, but you do need to modify the > context descriptor and invalidate cached versions of it. The terminology confused me a lot. I perfer use PASID for IOMMU and ASID is for CPU. Arm's entry of the context descriptor table contains a "IOASID" IOASID != ASID for CPU_TLB and IOMMU_TLB. When you say "since the IOASID doesn't change",Is it PASID or my IOASID ? -_*! PASID in PCI-sig was used to determine transfer address space. For intel, the entry which is indexed by PASID also contain S1/S2.PGD and DID(VMID). For arm, the entry which is indexed by PASID only contain S1.PGD and IOASID. Compare to Intel Vt-d Scalable mode, arm's design can't support PCI Virtual Function. > > Once you have pinned ASIDs, you could also declare that IOASID = ASID. I > don't remember finding an argument to strictly forbid it, even though ASID > and IOASID have different sizes on Arm (respectively 8/16 and 20 bits). ASID and IOASID are hard to keep the same between CPU system and IOMMU system. So I introduce S1/S2.PGD.PPN as a bridge between CPUs and IOMMUs. See my proposal [1] 1: https://lore.kernel.org/linux-csky/1568896556-28769-1-git-send-email-guoren@kernel.org/T/#u -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Hi, On Tue, Sep 17, 2019 at 11:42 AM Anup Patel <Anup.Patel@wdc.com> wrote: > > > > With a reply stating that the patch "absolutely does not work" ;) > > This patch was tested on existing HW (which does not have ASID implementation) > and tested on QEMU (which has very simplistic Implementation of ASID). > > When I asked Gary Guo about way to get access to their HW (in same patch > email thread), I did not get any reply. After so many months passed, I now > doubt the his comment "absolutely does not work". > > > > What exactly do you want people to do with that? It's an awful lot of effort to > > review this sort of stuff and given that Guo Ren is talking about sharing page > > tables between the CPU and an accelerator, maybe you're better off > > stabilising Linux for the platforms that you can actually test rather than > > getting so far ahead of yourselves that you end up with a bunch of wasted > > work on patches that probably won't get merged any time soon. > > The intention of the ASID patch was to encourage RISC-V implementations > having ASID in HW and also ensure that things don't break on existing HW. > > I don't see our efforts being wasted in trying to make Linux RISC-V feature > complete and encouraging more feature rich RISC-V CPUs. > > Delays in merging patches are fine as long as people have something to try > on their RISC-V CPU implementations. > I'm the supporter of that patch: http://archive.lwn.net:8080/linux-kernel/20190329045111.14040-1-anup.patel@wdc.com/T/#u Because it implicit hw broadcast tlb invalidation optimization. Honestly it's not suitable for remote tlb flush with software IPI, but it's still much better than current RISC-V's. I'll try it on our hardware: 910. wait a moment :) -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
On Thu, Sep 19, 2019 at 09:07:15PM +0800, Guo Ren wrote: > > The solution I had to this problem is pinning the ASID [1] used by the > > IOMMU, to prevent the CPU from recycling the ASID on rollover. This way > > the CPU doesn't have to wait for IOMMU invalidations to complete, when > > scheduling a task that might not even have anything to do with the IOMMU. > > > > > In the Arm SMMU, ASID and IOASID (PASID) are separate identifiers. IOASID > > indexes an entry in the context descriptor table, which contains the ASID. > > So with unpinned shared ASID you don't need to invalidate the ATC on > > rollover, since the IOASID doesn't change, but you do need to modify the > > context descriptor and invalidate cached versions of it. > The terminology confused me a lot. I perfer use PASID for IOMMU and > ASID is for CPU. > Arm's entry of the context descriptor table contains a "IOASID" The terminology I've been using so far is different: * IOASID is PASID * The entry in the context descriptor table contains an ASID, which is either "shared" with CPUs or "private" to the SMMU (the SMMU spec says "shared" or "non-shared"). * So the CPU and SMMU TLBs use ASIDs, and the PCI ATC uses IOASID > IOASID != ASID for CPU_TLB and IOMMU_TLB. > > When you say "since the IOASID doesn't change",Is it PASID or my IOASID ? -_*! I was talking about PASID. Maybe we can drop "IOASID" and talk only about ASID and PASID :) > PASID in PCI-sig was used to determine transfer address space. > For intel, the entry which is indexed by PASID also contain S1/S2.PGD > and DID(VMID). > For arm, the entry which is indexed by PASID only contain S1.PGD and > IOASID. Compare to Intel Vt-d Scalable mode, arm's design can't > support PCI Virtual Function. The SMMU does support PCI Virtual Function - an hypervisor can assign a VF to a guest, and let that guest partition the VF into smaller contexts by using PASID. What it can't support is assigning partitions of a PCI function (VF or PF) to multiple Virtual Machines, since there is a single S2 PGD per function (in the Stream Table Entry), rather than one S2 PGD per PASID context. Thanks, Jean > > Once you have pinned ASIDs, you could also declare that IOASID = ASID. I > > don't remember finding an argument to strictly forbid it, even though ASID > > and IOASID have different sizes on Arm (respectively 8/16 and 20 bits). > ASID and IOASID are hard to keep the same between CPU system and IOMMU > system. So I introduce S1/S2.PGD.PPN as a bridge between CPUs and > IOMMUs. > See my proposal [1] > > 1: https://lore.kernel.org/linux-csky/1568896556-28769-1-git-send-email-guoren@kernel.org/T/#u > -- > Best Regards > Guo Ren > > ML: https://lore.kernel.org/linux-csky/ _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
On Thu, Sep 19, 2019 at 11:18 PM Jean-Philippe Brucker <jean-philippe@linaro.org> wrote: > > The SMMU does support PCI Virtual Function - an hypervisor can assign a > VF to a guest, and let that guest partition the VF into smaller contexts > by using PASID. What it can't support is assigning partitions of a PCI > function (VF or PF) to multiple Virtual Machines, since there is a > single S2 PGD per function (in the Stream Table Entry), rather than one > S2 PGD per PASID context. > In my concept, the two sentences "The SMMU does support PCI Virtual Functio" v.s. "What it can't support is assigning partitions of a PCI function (VF or PF) to multiple Virtual Machines" are conflict and I don't want to play naming game :) -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
On Fri, Sep 20, 2019 at 08:07:38AM +0800, Guo Ren wrote: > On Thu, Sep 19, 2019 at 11:18 PM Jean-Philippe Brucker > <jean-philippe@linaro.org> wrote: > > > > > The SMMU does support PCI Virtual Function - an hypervisor can assign a > > VF to a guest, and let that guest partition the VF into smaller contexts > > by using PASID. What it can't support is assigning partitions of a PCI > > function (VF or PF) to multiple Virtual Machines, since there is a > > single S2 PGD per function (in the Stream Table Entry), rather than one > > S2 PGD per PASID context. > > > In my concept, the two sentences "The SMMU does support PCI Virtual > Functio" v.s. "What it can't support is assigning partitions of a PCI > function (VF or PF) to multiple Virtual Machines" are conflict and I > don't want to play naming game :) That's fine. But to prevent the spread of misinformation: Arm SMMU supports PCI Virtual Functions. Thanks, Jean _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu