Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp845454imm; Thu, 4 Oct 2018 04:26:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV63CeeHKEBNAWrj56IfjQh3F2OCqCwPLh+Uk9lYsY5e/1v5mtLHGZi6RHt9A09TohkBnyysm X-Received: by 2002:a63:ea0e:: with SMTP id c14-v6mr5049593pgi.361.1538652374647; Thu, 04 Oct 2018 04:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538652374; cv=none; d=google.com; s=arc-20160816; b=bjDcfFYDTsRrVsZUHwYv/W7aE9nUPU+YKj9L7IhAQfnODGXItdAEBowYtZvIS1QfTa Xnd+tBxPkyRl3TEVNgJMjn4h6P9l62ftTcw5/jXcxa4celU2yly2tpk8ie7UQAbmJnv4 qtHehaioy/v++LIqbePHZ/tlstWQh4We1s0fBbpwGt5BhIacuz4hRc/7sHuHaNAxVVbW /hD8DVg4M1JeTnCEjL+3HojfXGXjjgRKQUPKFfBQUFUYnZAj6PyVGa/HNJLyP8LS919v HaljFaRDZmYFXAfmeuYorBqMNLKy7SQv0zLzqhM1hIH8yM9K8roI9hPoCiwWHOkGcpVj 7xng== 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=i67h5RoFP2OF+8xkB5vMxLSIuW9qp2gsVhyVysQAjKM=; b=A4+Ine8FOF9d/WE94rw/YEBM6f/fZYtKnuu8vXxUzGCpkwwV6nz7xLlgzIGxSflpqv N3IQsheb4nxI22r/jFUwFq4GQef7eCVMRDkfNl0+rkQ40h32YQhDw6m7VPC1Q0ZNAfpW L3O58RIsdSbnnuAyQy5C32CnHJd3p6z2L4oUFQcB6kMCJ0NUO6tcYBbHdIdxE+ebsCbd HvV+QZo+UTAuQsgV396vlGyBk7AzgnmRhXWm35CkWltfv///SCTsWW5Sid52wW2hnBxc 8IVrllv3mGr14qkplHgORJuv/BgSXa48jTUPPcAQt3eLlag8JmZbiedXaUUAgE0rkz3h 6Jew== 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 v11-v6si5373930plg.18.2018.10.04.04.25.55; Thu, 04 Oct 2018 04:26:14 -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 S1727318AbeJDSSk (ORCPT + 99 others); Thu, 4 Oct 2018 14:18:40 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34846 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727188AbeJDSSk (ORCPT ); Thu, 4 Oct 2018 14:18:40 -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 505D37A9; Thu, 4 Oct 2018 04:25:50 -0700 (PDT) Received: from [10.4.12.131] (e110467-lin.emea.arm.com [10.4.12.131]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 036B03F5A0; Thu, 4 Oct 2018 04:25:48 -0700 (PDT) Subject: Re: [PATCH] dma-direct: Fix return value of dma_direct_supported To: Alexander Duyck , iommu@lists.linux-foundation.org Cc: benh@kernel.crashing.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, linuxppc-dev@lists.ozlabs.org, linux@roeck-us.net References: <20181003234746.3586.42014.stgit@localhost.localdomain> From: Robin Murphy Message-ID: <5329f992-d3aa-c16c-1218-c26d758889b8@arm.com> Date: Thu, 4 Oct 2018 12:25:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181003234746.3586.42014.stgit@localhost.localdomain> 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 04/10/18 00:48, Alexander Duyck wrote: > It appears that in commit 9d7a224b463e ("dma-direct: always allow dma mask > <= physiscal memory size") the logic of the test was changed from a "<" to > a ">=" however I don't see any reason for that change. I am assuming that > there was some additional change planned, specifically I suspect the logic > was intended to be reversed and possibly used for a return. Since that is > the case I have gone ahead and done that. Bah, seems I got hung up on the min_mask code above it and totally overlooked that the condition itself got flipped. It probably also can't help that it's an int return type, but treated as a bool by callers rather than "0 for success" as int tends to imply in isolation. Anyway, paying a bit more attention this time, I think this looks like the right fix - cheers Alex. Robin. > This addresses issues I had on my system that prevented me from booting > with the above mentioned commit applied on an x86_64 system w/ Intel IOMMU. > > Fixes: 9d7a224b463e ("dma-direct: always allow dma mask <= physiscal memory size") > Signed-off-by: Alexander Duyck > --- > kernel/dma/direct.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > index 5a0806b5351b..65872f6c2e93 100644 > --- a/kernel/dma/direct.c > +++ b/kernel/dma/direct.c > @@ -301,9 +301,7 @@ int dma_direct_supported(struct device *dev, u64 mask) > > min_mask = min_t(u64, min_mask, (max_pfn - 1) << PAGE_SHIFT); > > - if (mask >= phys_to_dma(dev, min_mask)) > - return 0; > - return 1; > + return mask >= phys_to_dma(dev, min_mask); > } > > int dma_direct_mapping_error(struct device *dev, dma_addr_t dma_addr) > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu >