Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1104317imm; Thu, 4 Oct 2018 08:14:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV607WA8qP7uQteyNkY7lFBQkyGtDN0XKkIr3AQdVVR5SeVZ4l4ffqauXphLcTWkaJQIiTQbj X-Received: by 2002:a62:898d:: with SMTP id n13-v6mr7296301pfk.57.1538666072276; Thu, 04 Oct 2018 08:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538666072; cv=none; d=google.com; s=arc-20160816; b=AnBpzhy5S7audOKkePD3g/su3GGxeHEwDjvcdaAgjnedD+orPZJykOQWu9cESXj5VU +NVg0/FAuzNXoCTobAKQ7h0lq1lZmV44sQbNBTlZqQfQaDqfHorcvTcWYEBA2hyak2H1 k4XuMCHPowasvp0iqvrrTizZKBfy+FGD48n1Ivt9zFoswodXU+/fUZI9B8E1Yh7hIizQ px8sTZwNYPG1NVHdMV3N73oHkxdCt0jnVY05+UG7+F4Cbri8Np5d2+vEa8PfFEVnw5ju mtpQvnxjGahrLYzGeDGJunnJE6z54FFJ6WFuC5tbGX7YyWbZng81ff7tU7qDrCgsXSZs ARww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aFkA/0wrykNoe/6zOrHUhGlT+Q7Jx6eOGkCxdr4cYdk=; b=Q0kaXVwBuddO6qrUquJlwv5voWK+6uzvo4D48GIMkAS/ot9sSzaPTK3DnQ7Jcb/r4X Vqynz+Dn/cTCq3GXGYe+yWkbx1n5cjP3JurABd+YKtyFz93lPztfhOSc2nWmGaQVUQgV xEICTGQ4i1SLoMolxyEO8ai0eRUPmqFrqPIXmCVSgUoDbBKITSkZK674N4mojFAhtYLp pMQPIzb+3i0xIc7Pcw+wg2DUkwCCRK9X9P3R5jO0uvRQq1CxCpfNwqAn4lRqKxgLAGaU jl1NWJgghXIyXRs/UckO6VBzYTHdwYBQRbZV3ZP60UU/Dpu3ev/jLjt8VCMJjkxG82pB bDAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FFxCmYry; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x128-v6si5120199pgb.129.2018.10.04.08.14.16; Thu, 04 Oct 2018 08:14:32 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FFxCmYry; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727836AbeJDWHV (ORCPT + 99 others); Thu, 4 Oct 2018 18:07:21 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:37571 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727561AbeJDWHV (ORCPT ); Thu, 4 Oct 2018 18:07:21 -0400 Received: by mail-io1-f66.google.com with SMTP id m16-v6so3983946ioj.4 for ; Thu, 04 Oct 2018 08:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aFkA/0wrykNoe/6zOrHUhGlT+Q7Jx6eOGkCxdr4cYdk=; b=FFxCmYry6eP1yN1ufHNzOppBREw4u/zF406X8tFxqchaGBoGVgsF/1kcm4z8ZECKAX 4/NMUlx4kQL7yJF/BJx71swkLQt2Jp3klUwoznSDe1v3SUYbNolpwTAMiimEWxJMWp+0 qXgpMYLrSXgroplVl33QzJbPbBr6sx6SRh5mxhqPuOqg6fLMaKiH7oFRjplEUVAIJuOy fb1YjqFlr7DgDgCN9hEV4e5Tw+5LFHdO0h4XpVVQ+sxJTZQzHS9e5GvsJj64IoEhZ1LU sXo1z6Q/OJ+BAUrt1jLWrLIxzasExlSoDjv+WYouT8MPb0osWkszYaVIwTQquAP24X9q PO9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aFkA/0wrykNoe/6zOrHUhGlT+Q7Jx6eOGkCxdr4cYdk=; b=sHnJOuGVhNkhtEDlyEfQTsmf/CLKyKjWMXsWyz9FHpl66fQg9pMal1ynV2QI83Nuc2 sgQGH4aT3Sci4edW5mIxDFMSiJ2ASyqOd31sweE4zJvW2pE0kVOq0xpu7Oeo01civ9Az g8JVQvA9oRsCvvbb0N8DUHobN4WDmvbs/bEsJHCeBGR5hhlfAPF33/bkb0TLpVt8kgws OjGZ9W2zEdtqUikAZKgZ9u1Bze20MaBPLfSqbPxFFh+kL7DdhDT7ST6TwwwkcElp90G5 vBACTBUfu3xE7DlBvKYh8x4o0/oQEdMvV2IM4zJTuB16dexKgiZSPhSMX8g9R8AseXP2 1I/Q== X-Gm-Message-State: ABuFfohiNAb7KpvX6MeKC7jUyBrk8sH2U2h7W9g1p3hT+Z8k6Vv3KFBr GaCAHLM2YasLI0YRWY4Vqg3yWtUyfhjkpXQJwtj4pnhmm/A= X-Received: by 2002:a6b:e91a:: with SMTP id u26-v6mr4551737iof.200.1538666017780; Thu, 04 Oct 2018 08:13:37 -0700 (PDT) MIME-Version: 1.0 References: <20181003234746.3586.42014.stgit@localhost.localdomain> <5329f992-d3aa-c16c-1218-c26d758889b8@arm.com> In-Reply-To: <5329f992-d3aa-c16c-1218-c26d758889b8@arm.com> From: Alexander Duyck Date: Thu, 4 Oct 2018 08:13:26 -0700 Message-ID: Subject: Re: [PATCH] dma-direct: Fix return value of dma_direct_supported To: Robin Murphy Cc: alexander.h.duyck@linux.intel.com, "open list:INTEL IOMMU (VT-d)" , Benjamin Herrenschmidt , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , LKML , Guenter Roeck , Greg KH , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 4, 2018 at 4:25 AM Robin Murphy wrote: > > 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. Thanks for the review. - Alex P.S. It looks like I forgot to add Christoph to the original mail since I had just copied the To and Cc from the original submission, so I added him to the Cc for this. > > 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 > > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu