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 X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7154C43382 for ; Thu, 27 Sep 2018 15:28:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 839DC215F0 for ; Thu, 27 Sep 2018 15:28:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 839DC215F0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbeI0VrH (ORCPT ); Thu, 27 Sep 2018 17:47:07 -0400 Received: from verein.lst.de ([213.95.11.211]:45890 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727212AbeI0VrH (ORCPT ); Thu, 27 Sep 2018 17:47:07 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id C360868B02; Thu, 27 Sep 2018 17:28:18 +0200 (CEST) Date: Thu, 27 Sep 2018 17:28:18 +0200 From: Christoph Hellwig To: Robin Murphy Cc: Christoph Hellwig , iommu@lists.linux-foundation.org, Marek Szyprowski , Benjamin Herrenschmidt , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 2/5] dma-direct: add an explicit dma_direct_get_required_mask Message-ID: <20180927152818.GC10566@lst.de> References: <20180920185247.20037-1-hch@lst.de> <20180920185247.20037-3-hch@lst.de> <02ce2ecc-281d-7b7f-6d30-8d246acd1eaa@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <02ce2ecc-281d-7b7f-6d30-8d246acd1eaa@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 27, 2018 at 03:12:25PM +0100, Robin Murphy wrote: >> +u64 dma_direct_get_required_mask(struct device *dev) >> +{ >> + u64 max_dma = phys_to_dma_direct(dev, (max_pfn - 1) << PAGE_SHIFT); >> + >> + return (1ULL << (fls64(max_dma) - 1)) * 2 - 1; > > I think that may as well just use __fls64() - it seems reasonable to assume > max_dma > 0. Otherwise, Is there any good reason to micro-optimize given that this isn't a fast path?