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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham 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 CB2B3C282DD for ; Tue, 23 Apr 2019 13:19:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4C6620645 for ; Tue, 23 Apr 2019 13:19:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbfDWNTu (ORCPT ); Tue, 23 Apr 2019 09:19:50 -0400 Received: from foss.arm.com ([217.140.101.70]:56088 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727703AbfDWNTu (ORCPT ); Tue, 23 Apr 2019 09:19:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B266DA78; Tue, 23 Apr 2019 06:19:49 -0700 (PDT) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB3EF3F706; Tue, 23 Apr 2019 06:19:47 -0700 (PDT) Subject: Re: [PATCH 1/7] genirq/msi: Add a new field in msi_desc to store an IOMMU cookie To: Marc Zyngier , Julien Grall , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org Cc: logang@deltatee.com, douliyangs@gmail.com, miquel.raynal@bootlin.com, jason@lakedaemon.net, tglx@linutronix.de, joro@8bytes.org, bigeasy@linutronix.de, linux-rt-users@vger.kernel.org References: <20190418172611.21561-1-julien.grall@arm.com> <20190418172611.21561-2-julien.grall@arm.com> <7e77331c-4adf-5bb4-0c23-4d01a6ac5ab4@arm.com> <1bcdb72f-2116-756b-b74d-a48f89870782@arm.com> <48d14d10-0484-a7dd-cd84-a933158906ff@arm.com> From: Robin Murphy Message-ID: <468df11c-fe2a-2584-7306-185531653331@arm.com> Date: Tue, 23 Apr 2019 14:19:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <48d14d10-0484-a7dd-cd84-a933158906ff@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/04/2019 12:46, Marc Zyngier wrote: > On 23/04/2019 11:51, Julien Grall wrote: >> On 4/23/19 11:23 AM, Marc Zyngier wrote: >>> Hi Julien, >> >> Hi Marc, >> >>> On 18/04/2019 18:26, Julien Grall wrote: >>>> When an MSI doorbell is located downstream of an IOMMU, it is required >>>> to swizzle the physical address with an appropriately-mapped IOVA for any >>>> device attached to one of our DMA ops domain. >>>> >>>> At the moment, the allocation of the mapping may be done when composing >>>> the message. However, the composing may be done in non-preemtible >>>> context while the allocation requires to be called from preemptible >>>> context. >>>> >>>> A follow-up patch will split the current logic in two functions >>>> requiring to keep an IOMMU cookie per MSI. >>>> >>>> This patch introduces a new field in msi_desc to store an IOMMU cookie >>>> when CONFIG_IOMMU_DMA is selected. >>>> >>>> Signed-off-by: Julien Grall >>>> --- >>>> include/linux/msi.h | 3 +++ >>>> 1 file changed, 3 insertions(+) >>>> >>>> diff --git a/include/linux/msi.h b/include/linux/msi.h >>>> index 7e9b81c3b50d..d7907feef1bb 100644 >>>> --- a/include/linux/msi.h >>>> +++ b/include/linux/msi.h >>>> @@ -77,6 +77,9 @@ struct msi_desc { >>>> struct device *dev; >>>> struct msi_msg msg; >>>> struct irq_affinity_desc *affinity; >>>> +#ifdef CONFIG_IOMMU_DMA >>>> + const void *iommu_cookie; >>>> +#endif >>>> >>>> union { >>>> /* PCI MSI/X specific data */ >>>> >>> >>> Given that this is the only member in this structure that is dependent >>> on a config option, you could also add a couple of accessors that would >>> do nothing when IOMMU_DMA is not selected (and use that in the DMA code). >> >> I haven't seen any use of the helpers so far because the DMA code is >> also protected by IOMMU_DMA. >> >> I can add the helpers in the next version if you see any use outside of >> the DMA code. > > There may not be any user user yet, but I'd surely like to see the > accessors. This isn't very different from the stub functions you add in > patch #2. If you foresee this being useful in general, do you reckon it would be worth decoupling it under its own irqchip-layer Kconfig which can then be selected by IOMMU_DMA? Robin.