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=-7.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 427D1C41604 for ; Tue, 6 Oct 2020 08:13:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E888A20789 for ; Tue, 6 Oct 2020 08:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601972021; bh=LvzCbB0u7EWJxbO5tO/ifPKXIHNjm4ftrTis3L8nbZI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=xgIPpo8HrJ5c35dpl4DhBLnW99roKrCWAOytv2WLwTtyphrFUbjcUetvGsBRbv0Kt nF5gwzPoCQaZV8VMj8vW3u7cWKZA2uWNH2KsY3mKw4T8rXVlIo2Rtqmt9iidOBGvxz 5lH855eH4BHInqtYKgKFYHhYYfCEqcoy+2GlaZsk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725934AbgJFINk (ORCPT ); Tue, 6 Oct 2020 04:13:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:35220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725891AbgJFINk (ORCPT ); Tue, 6 Oct 2020 04:13:40 -0400 Received: from localhost (unknown [213.57.247.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52AC9206F7; Tue, 6 Oct 2020 08:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601972019; bh=LvzCbB0u7EWJxbO5tO/ifPKXIHNjm4ftrTis3L8nbZI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xIRPRFSxiK4nC/qpnnvjhRtdGl/J+seiE36psbef8l8Ewd96nw6pPCTHTud6fn53U 4gKF2C/BgUPAlaQF7SWdloxkeZUPBMsWVLFOXeFWxjboDfm69skavJGOeP+gxqw7ML oS6uekkCp0pgnlSG2tnOORPM9aPR+uRNlyaazvfI= Date: Tue, 6 Oct 2020 11:13:34 +0300 From: Leon Romanovsky To: Christoph Hellwig Cc: Doug Ledford , Jason Gunthorpe , Adit Ranadive , Ariel Elior , Bernard Metzler , Christian Benvenuti , Dennis Dalessandro , Devesh Sharma , Faisal Latif , Gal Pressman , Lijun Ou , linux-rdma@vger.kernel.org, Michal Kalderon , Mike Marciniszyn , Naresh Kumar PBS , Nelson Escobar , Parav Pandit , Parvi Kaustubhi , Potnuri Bharat Teja , Selvin Xavier , Shiraz Saleem , Somnath Kotur , Sriharsha Basavapatna , VMware PV-Drivers , Weihang Li , "Wei Hu(Xavier)" , Yishai Hadas , Zhu Yanjun Subject: Re: [PATCH rdma-next v2] RDMA: Explicitly pass in the dma_device to ib_register_device Message-ID: <20201006081334.GL1874917@unreal> References: <20201006073229.2347811-1-leon@kernel.org> <20201006073554.GA16894@infradead.org> <20201006075345.GK1874917@unreal> <20201006075749.GA23345@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201006075749.GA23345@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Tue, Oct 06, 2020 at 08:57:49AM +0100, Christoph Hellwig wrote: > On Tue, Oct 06, 2020 at 10:53:45AM +0300, Leon Romanovsky wrote: > > On Tue, Oct 06, 2020 at 08:35:54AM +0100, Christoph Hellwig wrote: > > > > + WARN_ON(!IS_ENABLED(CONFIG_DMA_VIRT_OPS) && !dma_device); > > > > + if (!dma_device) { > > > > /* > > > > - * The caller did not provide custom DMA operations. Use the > > > > - * DMA mapping operations of the parent device. > > > > + * If the caller does not provide a DMA capable device then the > > > > + * IB device will be used. In this case the caller should fully > > > > + * setup the ibdev for DMA. This usually means using > > > > + * dma_virt_ops. > > > > */ > > > > + device->dev.dma_ops = &dma_virt_ops; > > > > + dma_device = &device->dev; > > > > > > The lack of the if probably means this will fail to link now when > > > CONFIG_DMA_VIRT_OPS is not set. This also seems to not remove the > > > dma_virt_ops assignment in the callers. > > > > I expect to see this during driver development/testing. It is not worth > > to make if() case id device won't be operable. > > Then you'll need an ifdef or whatever your preferred method is to > avoid the dma_virt_ops symbol reference for the !CONFIG_DMA_VIRT_OPS > case. diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 882a7b389dc3..49d095f45216 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -1181,7 +1181,7 @@ static void setup_dma_device(struct ib_device *device, struct device *dma_device) { WARN_ON(!IS_ENABLED(CONFIG_DMA_VIRT_OPS) && !dma_device); - if (!dma_device) { + if (IS_ENABLED(CONFIG_DMA_VIRT_OPS) && !dma_device) { /* * If the caller does not provide a DMA capable device then the * IB device will be used. In this case the caller should fully