Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3438626yba; Tue, 23 Apr 2019 03:58:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdOQmQXOwLGlcBFMjgiokB+AquJjCcIsIQBut4R7sB5rbjhLuVmcF9TOYZbR3W24kOX14t X-Received: by 2002:a63:af0a:: with SMTP id w10mr23989464pge.67.1556017127408; Tue, 23 Apr 2019 03:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556017127; cv=none; d=google.com; s=arc-20160816; b=GySKRekRN/GjbgykNgERh9naO8KWhOXxZFLHQf/h0WUXDPUfaGwrUX0hyo2Mzyb5EY Mwe1V+yzNdbaof/4hnGTe0vr0d2tOzBZ/aMqIu0yxz7DvQiasn/aOg1GMozXThFn0bbM HELlAyrSI5YaaVDiqvGXrmyjKfhpX3o0rqmFZFXFbfQBSzRC5fnks4iUBXZ7ZDyn8KHQ GN5yepdGOznYIu74OyE/NGO7tgqyBhfPN+sKd0tblpO+3T6kBw1vAHCeet58nK8luxJo rKz4Tw866iIRskxMAKpxGjSnslb/HpoR5ZWqSyDDRFe4DGWDZW98FMv6SQHcrXHUBJK4 XcHw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=MCHLeJ8JpLFx8ohljaCzntHvvjY8j5WxAajkj4GTizw=; b=0gl2E7yPODBqQnNbG10pz/+kYnW2d6fkEReilvZiRpZnGL/eFxiYfP1yhrDK/nR4ZF mE241LeMPLTjMqYuCktBVeV/MBGiZqKO3Nf9qn0W2uyZojgEvBJ35UxEROaGo7KWhVna arte6Ba3eiI+7BOsaekUOxiv6hwxhUh4eaxVHIdBy3/DNzSxY1H5kjTP8Ax5zcu/sGLR xMLBzzxI4oRY6PvhwAVXnxNK/ZZN/PytqlgKyl9YyPMWwAgdGvlnbT3WjhqhEBjYLF1g cTGQeEwZ5mOHV8C2zS+8UaPbFHIA+PE9C2oFtl7P9yUhlK6S8QUrIPLhQaeG+L+dxVIv UY0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si14231931pgp.185.2019.04.23.03.58.31; Tue, 23 Apr 2019 03:58:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727594AbfDWKzj (ORCPT + 99 others); Tue, 23 Apr 2019 06:55:39 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54268 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbfDWKzj (ORCPT ); Tue, 23 Apr 2019 06:55:39 -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 05D7A374; Tue, 23 Apr 2019 03:55:39 -0700 (PDT) Received: from [10.37.8.239] (unknown [10.37.8.239]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5470A3F557; Tue, 23 Apr 2019 03:55:36 -0700 (PDT) Subject: Re: [PATCH 2/7] iommu/dma-iommu: Split iommu_dma_map_msi_msg in two parts To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, logang@deltatee.com, douliyangs@gmail.com, miquel.raynal@bootlin.com, marc.zyngier@arm.com, jason@lakedaemon.net, tglx@linutronix.de, joro@8bytes.org, robin.murphy@arm.com, bigeasy@linutronix.de, linux-rt-users@vger.kernel.org References: <20190418172611.21561-1-julien.grall@arm.com> <20190418172611.21561-3-julien.grall@arm.com> <20190423070823.GA12114@infradead.org> From: Julien Grall Message-ID: <7af177e1-dfd9-2a91-3fd9-dfe53a6a9014@arm.com> Date: Tue, 23 Apr 2019 11:55:34 +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: <20190423070823.GA12114@infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 4/23/19 8:08 AM, Christoph Hellwig wrote: > On Thu, Apr 18, 2019 at 06:26:06PM +0100, Julien Grall wrote: >> +int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) >> { >> + struct device *dev = msi_desc_to_dev(desc); >> struct iommu_domain *domain = iommu_get_domain_for_dev(dev); >> struct iommu_dma_cookie *cookie; >> unsigned long flags; >> >> + if (!domain || !domain->iova_cookie) { >> + desc->iommu_cookie = NULL; >> + return 0; >> + } >> >> cookie = domain->iova_cookie; >> >> @@ -908,10 +908,33 @@ void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg) >> * of an MSI from within an IPI handler. >> */ >> spin_lock_irqsave(&cookie->msi_lock, flags); >> + desc->iommu_cookie = iommu_dma_get_msi_page(dev, msi_addr, domain); >> spin_unlock_irqrestore(&cookie->msi_lock, flags); >> >> + return (desc->iommu_cookie) ? 0 : -ENOMEM; > > No need for the braces. Also I personally find a: > > if (!desc->iommu_cookie) > return -ENOMEM; > return 0; > > much more readable, but that might just be personal preference. I am happy either way. I will use your suggestion in the next version. Cheers, -- Julien Grall