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.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS 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 EE84AC169C4 for ; Mon, 11 Feb 2019 20:32:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1ACE218DE for ; Mon, 11 Feb 2019 20:32:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="oo87iyip" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727138AbfBKUcI (ORCPT ); Mon, 11 Feb 2019 15:32:08 -0500 Received: from mail-eopbgr140081.outbound.protection.outlook.com ([40.107.14.81]:18198 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726025AbfBKUcH (ORCPT ); Mon, 11 Feb 2019 15:32:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AxplcQavahw+LxTptgwniDIpQNvSS+N+Z5AFrMzE+cY=; b=oo87iyipcj8t4ZaFc7ZjssX7I+PXPWsoPvyTzBSH1hQI/v98aJlJm/3qYuj16gLKWkIQiMmnT+gyhP03csmvnbVD0RAHLkPlLcgS9M5dtxSGr8R2fMtgaNXsfbyo/V8shL/m5uMyMTM7I9jrXvt1Lygzl/XSb+rbU1/Pb2UcuSI= Received: from DBBPR05MB6570.eurprd05.prod.outlook.com (20.179.44.81) by DBBPR05MB6330.eurprd05.prod.outlook.com (20.179.41.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.21; Mon, 11 Feb 2019 20:32:02 +0000 Received: from DBBPR05MB6570.eurprd05.prod.outlook.com ([fe80::34e8:76a2:998f:581a]) by DBBPR05MB6570.eurprd05.prod.outlook.com ([fe80::34e8:76a2:998f:581a%7]) with mapi id 15.20.1601.023; Mon, 11 Feb 2019 20:32:02 +0000 From: Jason Gunthorpe To: Leon Romanovsky CC: Doug Ledford , RDMA mailing list , Moni Shoua , Saeed Mahameed , linux-netdev Subject: Re: [PATCH mlx5-next 2/2] net/mlx5: Factor out HCA capabilities functions Thread-Topic: [PATCH mlx5-next 2/2] net/mlx5: Factor out HCA capabilities functions Thread-Index: AQHUwgDQW5oscdw7ukWE1gIBKHDWvaXbAisAgAADJ4CAAAhTAA== Date: Mon, 11 Feb 2019 20:32:02 +0000 Message-ID: <20190211203154.GM24706@mellanox.com> References: <20190211115608.22677-1-leon@kernel.org> <20190211115608.22677-3-leon@kernel.org> <20190211195050.GL24706@mellanox.com> <20190211200207.GD21447@mtr-leonro.mtl.com> In-Reply-To: <20190211200207.GD21447@mtr-leonro.mtl.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MWHPR2001CA0013.namprd20.prod.outlook.com (2603:10b6:301:15::23) To DBBPR05MB6570.eurprd05.prod.outlook.com (2603:10a6:10:d1::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jgg@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [174.3.196.123] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DBBPR05MB6330;6:dyi1X7TJ+QtdGsdbW0FpuCvUFwLCZmegsJuuDNTx/HRGzQDn87yQR4yiC9H6kSfWA+WDoPfREdE4mcWvTvUAGb9Ci8GI61us7um+iYwthSwB1BCv1nKlCO6wLikz0UBSuacY68KWEy7BRmfrFbQmhSkK6zioRuw/gyE3Gow9NV6khROx0pEdkhuALvL7QFWfs/ELvTzBmzp7rARtBI05nvYOvMfa+7eEa1aUHa1/UeI1Ys7OhrqHZirW/DJ3bFiehh/A2gdOwJOaLWyhYeJ6EnMLpkVL+NQFvqSKYEmm8oT0JVTyrBFsCxBdh2XtIT+4t0DSdmnWEW7Yuw0NCIiEZZxH5hxbhaZpjs80Pxj6zma7qtq1bWtWiE9FOurLzjLsWMBVFhD/8jVSY1juU5lgdMzbuXTwT/4rWx70gyIZUmd5z1VXMx8uILTe3eWB0h2ZcrXUy5ezbSMmkB7yLmcXqQ==;5:eYmvydmMS+69WN42sUHEW/rus8JwLz5PWZqoAkyNvxlpcwcT1s4/zQbhjVP0V0gJnfs5AYRL5WfurSdpXs3k/FABggsKD0vr/szwiiZtC6da+FBIJ/GHVnGrNjMUbumAahHIPGDVjp/cDpoN2VTYove1EdCK3hpJGkX5FlIES24uAM0i+TNnrHCyEAkbXDhL/y51+RJTufg+qmORqmirWA==;7:62veJIrHBXjLKnjmwUXgrVQTxAIvs3/YvszpflsmAYl2KmQ7YN5a1Vdx/LWxphCMii2/r4C4IpY/1QYbFclIfJUZ33L1oMG1r+yTnNyJ4k+cW7B/H7eIJWnMo+qGY/jYzhwIVUa5R0IYdLoEWuS5CA== x-ms-office365-filtering-correlation-id: 9faa2e19-435b-4e4e-211e-08d6905ffadb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605077)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:DBBPR05MB6330; x-ms-traffictypediagnostic: DBBPR05MB6330: x-microsoft-antispam-prvs: x-forefront-prvs: 0945B0CC72 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(366004)(376002)(346002)(39860400002)(396003)(199004)(189003)(446003)(486006)(386003)(2616005)(476003)(14454004)(102836004)(11346002)(105586002)(106356001)(1076003)(93886005)(97736004)(6506007)(6116002)(36756003)(3846002)(71200400001)(71190400001)(86362001)(6246003)(53936002)(4326008)(68736007)(2906002)(99286004)(54906003)(316002)(66066001)(256004)(8936002)(478600001)(33656002)(25786009)(8676002)(52116002)(186003)(305945005)(26005)(6916009)(7736002)(6436002)(6486002)(76176011)(81156014)(81166006)(229853002)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:DBBPR05MB6330;H:DBBPR05MB6570.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2iusXUru5gHarXho7Gvhy58t/E/8QLFAL1QVsETaAvsC8FsIQbyxU41Dob9jl/22YbSU+gmK6whZbDeTVtbF6mG51W/UlNQWNsgo51psNiJXpfIIfITI3p6KBfsb011b2VNem8btQz9yeF1nsJ74EMZhgmeM4ZXCXkp4aso4Gp/IzC/q/D7MBUnCVIT+ixpUSS5bmw7rcXJRTpTzoiNd94dFyxio6m/M0bLem1nvLQsjlyFbHFslFPmQ1F4PjRIv4NFCyZ0R0gTyvL0DY8DarGq/tRLwDCR8h+iBWJX4dGWOR/Ye0cYWvGGksQS5L153HZxVV+qcuVLVZf/BA3nUEQyPEBhIxZkhtgJGRfozqWzLMIFwxLO9eSLMHM+n2PJz4LnxWzuWOHpks/Zw9FvivpPXCL3Hw3WMtyFIyVp0uII= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9faa2e19-435b-4e4e-211e-08d6905ffadb X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2019 20:32:02.4451 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR05MB6330 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Feb 11, 2019 at 10:02:07PM +0200, Leon Romanovsky wrote: > On Mon, Feb 11, 2019 at 07:50:55PM +0000, Jason Gunthorpe wrote: > > On Mon, Feb 11, 2019 at 01:56:08PM +0200, Leon Romanovsky wrote: > > > From: Leon Romanovsky > > > > > > Combine all HCA capabilities setters under one function > > > and compile out the ODP related function in case kernel > > > was compiled without ODP support. > > > > > > Signed-off-by: Leon Romanovsky > > > .../net/ethernet/mellanox/mlx5/core/main.c | 47 +++++++++++++----= -- > > > 1 file changed, 33 insertions(+), 14 deletions(-) > > > > > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers= /net/ethernet/mellanox/mlx5/core/main.c > > > index 6d45518edbdc..d7145ab6105d 100644 > > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c > > > @@ -459,6 +459,7 @@ static int handle_hca_cap_atomic(struct mlx5_core= _dev *dev) > > > return err; > > > } > > > > > > +#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING > > > static int handle_hca_cap_odp(struct mlx5_core_dev *dev) > > > { > > > void *set_hca_cap; > > > @@ -502,6 +503,7 @@ static int handle_hca_cap_odp(struct mlx5_core_de= v *dev) > > > kfree(set_ctx); > > > return err; > > > } > > > +#endif > > > > > > static int handle_hca_cap(struct mlx5_core_dev *dev) > > > { > > > @@ -576,6 +578,35 @@ static int handle_hca_cap(struct mlx5_core_dev *= dev) > > > return err; > > > } > > > > > > +static int set_hca_cap(struct mlx5_core_dev *dev) > > > +{ > > > + struct pci_dev *pdev =3D dev->pdev; > > > + int err; > > > + > > > + err =3D handle_hca_cap(dev); > > > + if (err) { > > > + dev_err(&pdev->dev, "handle_hca_cap failed\n"); > > > + goto out; > > > + } > > > + > > > + err =3D handle_hca_cap_atomic(dev); > > > + if (err) { > > > + dev_err(&pdev->dev, "handle_hca_cap_atomic failed\n"); > > > + goto out; > > > + } > > > + > > > +#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING > > > + err =3D handle_hca_cap_odp(dev); > > > + if (err) { > > > + dev_err(&pdev->dev, "handle_hca_cap_odp failed\n"); > > > + goto out; > > > + } > > > +#endif > > > > Adding > > if (IS_ENABLED..) > > return 0; > > > > To the top of handle_hca_cap_odp is alot better. >=20 > Saeed gave comment that he prefers code to be compiled-out in case > config is not set. In you suggestion, the code will exist and only > with some optimizations enabled it will be thrown. the kernel always compiles with optimizations that will throw away this code, it is a widely used pattern. #ifdef creates a compilation test matrix that is very undesired. Jason