Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3962595rwe; Tue, 30 Aug 2022 01:55:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5NR88lj+1pXaEK5iBoL/CYIbSv1SHZKHRHdRTtPXR7IpvKeo9h33/KMrvvMAQwKugdPWYb X-Received: by 2002:a17:906:8a4e:b0:740:2450:d69a with SMTP id gx14-20020a1709068a4e00b007402450d69amr12140669ejc.523.1661849733968; Tue, 30 Aug 2022 01:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661849733; cv=none; d=google.com; s=arc-20160816; b=t2Wf7aifwk9JRiHMWMMjmwDQw2+TyVKvgXcjDcIW4p4yRa1VIZujtUpB5C2nttWYqM UU0zxOPRPVOYrOLAvqH+3/9fs4+qMq1mEDQlUXec3aW2VbvSetE3g8df3v9rljqcwId0 sQMbleDxCi9HqsY5xxyuMy72msy+qXGd6jvQYoP5XNlgl6iA7izemjftelHhFYkaNcwE kmEb+FozmXCGJYoyw5a833UVXaUAXADgiWyvkc/v7jUMruXG91bOnJ9dsWnUBN8w8aWD VrK6HYnDlTtphVWvmvXyATGHlrWdyyhcoJYBSiznxMg8DfbjL4pskX3AasXoBM4OyjiG NpPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+FOQ2s0KaO6/qTgBnamaHkOfrAyVixQpWyjuHlsOaVU=; b=fXx5a7Wa4aTjzSVQgtLBHyBD+0w+XbPUelD7pahOQ/NtbKmkimbEwM00pzUuNY/M2O DN7VWYW5Q0H/NMMLL75TBrFqW6lriu+mdPx8yj0KbbYBI6froBmubQICO7xaS108+zg5 1WpomWfVaL8MRGs4rksZWH+c1L1XkW3H5/mt7zRBKBDnp26AhvJ6LHPKUeZWb/s9QH5G HvHQfnCBIL7m7ly6XaBjxrz70MsKH16LOKbj5ixy7MrSDnAnCuRxuLWyCJchir2txCVf JvsSJ9uxMj9WjF6N/vtflvYVfs9ZMlCoLpOhRgmDPmcspKFgKFEmaGjSH51jzpnrEHrX l3Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C0lqN22g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n25-20020a170906089900b007312789a037si7183057eje.144.2022.08.30.01.54.52; Tue, 30 Aug 2022 01:55:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C0lqN22g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231321AbiH3ICA (ORCPT + 99 others); Tue, 30 Aug 2022 04:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbiH3IB5 (ORCPT ); Tue, 30 Aug 2022 04:01:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06EF19D11F; Tue, 30 Aug 2022 01:01:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 94303B81629; Tue, 30 Aug 2022 08:01:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C20E3C433D6; Tue, 30 Aug 2022 08:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661846513; bh=ht4Zb7xny/jU85fv7zKRsCxM3zyAR48FezEpPUUfMrg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C0lqN22g0FEIFVPmdUDewu7idrLTy5lvQq1ak0rhRTi1K5PV4hH0Se+i8+pKPeynW kGSlcn0/mSos+bwADVsjUVgE3F1znICkDnst2LdAvMtcpeG6ZpXhERqNiBNHd8lkE1 XjjrytdP2vNgPjhxTZf7A8Pzhhh+7O+vum6rEmYmpe0STVoNGkCJkuNjtzFBvQl4p1 03zVuveOwu0+kIVIK5waxr1t8Ny3BRNOM9Losl+l8MUmD9Gj3VK4HqjDEB5ySWFO9E iqmtPoYEZSUyltFzMGI97om3L6OMADoGHqLE7uGkBe8XZVawJG/zFIPLCEEBf8W5Mj 71Id5ok+Awg0Q== Date: Tue, 30 Aug 2022 11:01:49 +0300 From: Leon Romanovsky To: Jinpu Wang , Christoph Hellwig Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] RDMA: dma-mapping: Return an unsigned int from ib_dma_map_sg{,_attrs} Message-ID: References: <20220826095615.74328-1-jinpu.wang@ionos.com> <20220826095615.74328-3-jinpu.wang@ionos.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 29, 2022 at 03:19:14PM +0200, Jinpu Wang wrote: > On Mon, Aug 29, 2022 at 2:06 PM Leon Romanovsky wrote: > > > > On Mon, Aug 29, 2022 at 11:40:40AM +0200, Jinpu Wang wrote: > > > On Sun, Aug 28, 2022 at 1:09 PM Leon Romanovsky wrote: > > > > > > > > On Fri, Aug 26, 2022 at 11:56:15AM +0200, Jack Wang wrote: > > > > > Following 2a047e0662ae ("dma-mapping: return an unsigned int from dma_map_sg{,_attrs}") > > > > > change the return value of ib_dma_map_sg{,attrs} to unsigned int. > > > > > > > > > > Cc: Jason Gunthorpe > > > > > Cc: Leon Romanovsky > > > > > Cc: Christoph Hellwig > > > > > Cc: linux-rdma@vger.kernel.org > > > > > Cc: linux-kernel@vger.kernel.org > > > > > > > > > > Signed-off-by: Jack Wang > > > > > --- > > > > > drivers/infiniband/core/device.c | 2 +- > > > > > include/rdma/ib_verbs.h | 6 +++--- > > > > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > > > > > You forgot to change ib_dma_map_sgtable_attrs() and various > > > > ib_dma_map_sg*() callers. > > > No, they are different. > > > ib_dma_map_sgtable_attrs and dma_map_sgtable return negative on errors. > > > > It is not the point. You changed ib_dma_virt_map_sg() to be unsigned, > > so now the following lines are not correct: > > > > 4138 int nents; > > 4139 > > 4140 if (ib_uses_virt_dma(dev)) { > > 4141 nents = ib_dma_virt_map_sg(dev, sgt->sgl, sgt->orig_nents); > > > > "int nents" should be changed to "unsigned int". > > > > Thanks > ok, I can do it. > just to check if we are on the same page: > For all the callers of ib_dma_map_sg, would it be better to fix it > one patch per driver or do it in a single bigger patch. > I feel it's better to do it per driver, and there are drivers from > different subsystems e.g. nvme/rds/etc. I don't know, everything here looks not nice to me. After commit 2a047e0662ae ("dma-mapping: return an unsigned int from dma_map_sg{,_attrs}"), all callers left in limbo state where they expect that dma_map_sg{,_attrs} will return upto INT_MAX. However now, the API can return upto UINT_MAX, which is not the case now due to internal implementation of dma_map_sg_*(), but can be changed any second. Can we simply revert that commit and restore the "int" return type? I don't see any benefit in having "unsigned int" if compiler doesn't enforce it. Thanks > > Thx! > > > > > > > > > > > > Thanks > > > Thanks!