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 B2594C4332F for ; Tue, 12 Dec 2023 14:11:09 +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=V4vBGfo6CfKMfgXbahQdMhln3c5tNuWirm6fZi2IPp8=; b=OHlXXvwX8ZJ/O9 NATdLgx5to1AqwfPy5K28Qznc634imrID5xH4xMqQFLjav7yAVO6hhUY49LQylzKyOqtn+LfyGcYA k4SqS1275tcMmRUoGU/Xv07E087zPpRqclSvhPkQnlUKFS1g8NZhszNXAzQILOCJNd1Ld3vh31RG5 avxfqFMBnU4ACT2zSECV7aqSwSXr7YjPfaye9Y/eEPfU+ieh20nKxMw4D3wCd45+q+wuVPuHpo/Bi lVoBJmMUuAwkvA1hZoWb3SW3U+cQG4OSxZyQoE2D7+GQNUI0MxZKziiSTfrIODRh70I8cRFZeVkiN s7bAVY+cBuUA234YdiwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rD3T0-00BsJL-26; Tue, 12 Dec 2023 14:10:34 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rD3Sx-00BsIb-1Q for linux-arm-kernel@lists.infradead.org; Tue, 12 Dec 2023 14:10:32 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 202B8CE1A55; Tue, 12 Dec 2023 14:10:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 082AAC433C7; Tue, 12 Dec 2023 14:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702390228; bh=Mgf9tmDd9obDgc8sUwhx24QZ/UIZ542eteF5w4D0TZI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KSemSIX0AGgLz4topDgQARmfUIqtZuYAEz3Eq2iqANC7zs9h2PAPkcpjDn1nGAVZe kjAYzJgEx06UAUPRvEnSeme6qHrAHhIpOqpbP4Vn+PsXXQZ2qjTwwJYcJYPZIhR/pZ 09UgYVZO4dgvrLnX77uebCzvo1byNKTpSUxlvg9RfQ9Y4h72l7odEHGuzgn9ScOUj7 6qK29O1ZRGqaPZJxf22Zb+pJkR2Y249P+nB6h2pwo4GHCmJqhYRIYtFuoUcYN4wpob MJyF/cs9hDOk/5SNeAkwSvR5Yd8ZdwWZM986+RhlRUlx6RkRIiiLpcf1jX4oE6vRSl xBShp6LPMPuag== Date: Tue, 12 Dec 2023 14:10:23 +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: <20231212141023.GA29699@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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231212140307.GD3014157@nvidia.com> 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-20231212_061031_738323_32E2A8B5 X-CRM114-Status: GOOD ( 16.67 ) 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 10:03:07AM -0400, Jason Gunthorpe wrote: > On Tue, Dec 12, 2023 at 01:26:51PM +0000, Will Deacon wrote: > > > @@ -862,6 +859,18 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) > > > 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; > > > + > > > + ret = arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev); > > > + if (ret) { > > > + kfree(smmu_domain); > > > + return NULL; > > > > If we're just returning NULL, can we drop 'ret'? > > It is waiting to be changed to ERR_PTR. The dependent patches are > merged to rc5 now, so I can fix it in v3. Sorry, I missed that. You can leave it as-is, since my SMMU branch is based on -rc3. > > > + } > > > + } > > > + > > > return &smmu_domain->domain; > > > > 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. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel