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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 8BEABC43331 for ; Tue, 16 Mar 2021 08:01:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6915464F77 for ; Tue, 16 Mar 2021 08:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233876AbhCPIAo (ORCPT ); Tue, 16 Mar 2021 04:00:44 -0400 Received: from verein.lst.de ([213.95.11.211]:58883 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbhCPIAR (ORCPT ); Tue, 16 Mar 2021 04:00:17 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 75A4D68C4E; Tue, 16 Mar 2021 09:00:09 +0100 (CET) Date: Tue, 16 Mar 2021 09:00:08 +0100 From: Christoph Hellwig To: Logan Gunthorpe Cc: Ira Weiny , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , Christian =?iso-8859-1?Q?K=F6nig?= , Ira Weiny , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin Subject: Re: [RFC PATCH v2 07/11] dma-mapping: Add flags to dma_map_ops to indicate PCI P2PDMA support Message-ID: <20210316080008.GC15949@lst.de> References: <20210311233142.7900-1-logang@deltatee.com> <20210311233142.7900-8-logang@deltatee.com> <20210313023657.GC3402637@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 15, 2021 at 10:33:13AM -0600, Logan Gunthorpe wrote: > >> + return !ops || ops->flags & DMA_F_PCI_P2PDMA_SUPPORTED; > > > > Is this logic correct? I would have expected. > > > > return (ops && ops->flags & DMA_F_PCI_P2PDMA_SUPPORTED); > > > If ops is NULL then the operations in kernel/dma/direct.c are used and > support is added to those in patch 6. So it is correct as written. It is not quite that easy. There also is the bypass flag and for the specific case where that is ignored the code needs a really good comment. And to assist that formatted so that it makes sense. The above line is indeed highly confusing even if it ends up being correct.