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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 451DEC4332F for ; Wed, 13 Dec 2023 13:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Wrmg26vr3hFsOsSX0VzRQ23rJJOb78lfwa8oHYpx35w=; b=TsxHPvwdDT+yyu 5NXjILXT4asqXB1vcLLSbJHEoERY5ccfvzRgqBfPSbnbom4ftjZOH0S+VrA5kBgs6XDbaYgY+KdrO 6U28TxVIcj4zno4lCwpvkEmDItqBJaPuFkeK5puTYmyV+sDW2OqskkQZePPr0GcXoQTH63rqzK1HN 18oKis2y7IauPIPrKHf5K3W4Qmwbvk/BDCoq170YJr8XwU6pU+BKB7FYZktxfZ41xpTXQLe+xpBL2 92QZ5JlI4qfpqUuUZ17x/zdY8JqWjX1kITyw4j+WkWoz7eIgz3WEs54GJOU7tDYcEzAdHOXA56tQD 0/rwZKbYgKrQ0YAg/6pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDPGX-00Eni2-2B; Wed, 13 Dec 2023 13:27:09 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDPGV-00Enh2-06 for linux-arm-kernel@lists.infradead.org; Wed, 13 Dec 2023 13:27:08 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5201561D05; Wed, 13 Dec 2023 13:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B942AC433C8; Wed, 13 Dec 2023 13:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702474026; bh=Vu4tH6NoZiRIiSTSRBcXtGlXq8JD/ureEjJXGIWGJ2w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eljD2EsQSBnWdBWlRNT6j4/+o8diULNUE66pnBZNx8SgFxAt02x8tnEPVautxnAVz Uy9BPMct8QtnhYrQYXm1xbbIh63Q3PEXNTWSJXW+dHYcFs/PCqCvbVJ3o03M7UkT5e wjlw5C+sPqwlCi6+kVd5V1sI/GKLOfGkxjiW3TUrluADJU9ZOONc677/m4BalNM7y3 uTONBGoC/dJQefKCwsqCGv3oYduAruZk0/B6nSqy+/CMMV94HT+r00yxbquA1OJqf4 zx957K8Xyz73u13oZhBscG6+cztqDnwrab0ZDiDK07hYxO65uv2WfO4H4CK/IPMtRc UEDURCH+3ucvQ== Date: Wed, 13 Dec 2023 13:27:01 +0000 From: Will Deacon To: Jason Gunthorpe Cc: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Nicolin Chen Subject: Re: [PATCH v2 5/5] iommu/arm-smmu: Convert to domain_alloc_paging() Message-ID: <20231213132700.GC31729@willie-the-truck> References: <0-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com> <5-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com> <20231212132651.GA29569@willie-the-truck> <20231212140307.GD3014157@nvidia.com> <20231212141023.GA29699@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231212141023.GA29699@willie-the-truck> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_052707_110301_776C96F7 X-CRM114-Status: GOOD ( 15.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Dec 12, 2023 at 02:10:23PM +0000, Will Deacon wrote: > On Tue, Dec 12, 2023 at 10:03:07AM -0400, Jason Gunthorpe wrote: > > On Tue, Dec 12, 2023 at 01:26:51PM +0000, Will Deacon wrote: > > > Why do we need to handle the 'dev && !cfg' case here, instead g > > > returning NULL? > > > > dev && !cfg is impossible these days, so we can shuffle the if and > > then just crash on that case like the other drivers do. > > Thanks, that would simplify it a little. Folded in the diff below. Will --->8 diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 536e47e3a65a..b0a6b367d8a2 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -861,7 +861,6 @@ static void arm_smmu_destroy_domain_context(struct arm_smmu_domain *smmu_domain) static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev) { - struct arm_smmu_master_cfg *cfg = NULL; struct arm_smmu_domain *smmu_domain; /* @@ -876,13 +875,10 @@ static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev) mutex_init(&smmu_domain->init_mutex); spin_lock_init(&smmu_domain->cb_lock); - if (dev) - cfg = dev_iommu_priv_get(dev); - if (cfg) { - int ret; + if (dev) { + struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); - ret = arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev); - if (ret) { + if (arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev)) { kfree(smmu_domain); return NULL; } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel