From patchwork Thu Mar 30 21:31:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47F8DC761AF for ; Thu, 30 Mar 2023 21:32:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbjC3VcN (ORCPT ); Thu, 30 Mar 2023 17:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjC3VcM (ORCPT ); Thu, 30 Mar 2023 17:32:12 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2048.outbound.protection.outlook.com [40.107.92.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A780CC0C for ; Thu, 30 Mar 2023 14:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJ+Pq/bfVvBN0YrpNk9p9t8ykybt1nGtRA39alm2Q9q4RF9wKo4M3Y+1mkEPIoGjBjUwmwzGv1iddMF78CytKyv0sqHLqjaL8AnSBZT1hz/xeBL6pd6V2NZK5XkrPS9HzYs/tZq7FO3SpiBJyKTqXfPt0YjSAVvlVMZQF1OvrgPzTHFhRBRoF2Qu4aj8fPg+55S2iod4WcOkQZBMo0xrJXUNvNw34e/HQFUorZ8dyrNkGHCSNDQqmAgjd+AgAI2GfosLU2OgrShsiD2SIpL31MVGVan+kYrWDZP84x8c6dnpNJPhf1AuuvcR4qXIJ4iyIAf0UVarwHZzwJVcSW6gqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MnHEwVtX6rCM1SbFLyM3eeEcPiEfV00FTzVpdzdnlvg=; b=nKvf+sPzp5jG90Tm0LRZ/zf6T9ILGyXwnF7McL5CkKaSVGvP0rZF0nzTIq8y23cdDPsqC2wNz8wU0QE7iOe+ACivrh48MR8zkQBAiAHZgdSRNji7Gu3ojsFJeyfusxkvmJx8cItnh1o7YpXTt07oCbd99vfc7k/NNasRgjbSCEzGiFspRVnJQ96v8bkFZeo4+x42FrKpWx6+/ZhrjYupC/n9qIwNarGlbGL6k7rH3Pr1DBUFPEXiXks5It1rEyXbfAQVGasgQSnZ214MTwEZ5oexLia5cVV4VEMigqG1T5ug8qsXPEO5KH+dmWxCGxO3b85hdfmBdhWQRCuAYNvopw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MnHEwVtX6rCM1SbFLyM3eeEcPiEfV00FTzVpdzdnlvg=; b=px7XbvWMx2HLsfZD8MNizJFMAuRYhFk0g7MJWS/qQE9dEnIzkGjqxGGbBX/NQSYfqdfrTmMndEOCsIu1Bd4IMBG7Sl0fwd7HoxMVjTJVsWcN97JNqEtwPf0cL40PEKqXTGHsSYCzqHclHaqmquy2nI5U/iWABphVZwtwIAs5rvN5QgUY9v74OsUN4DFBGVZi5BT+j1EhQnms3ptYDIWQ/2qXeUJMQ3e81qGOTt6Y1qxOlGx9aqitoFqAARCL+MGfKmwq8PAoGpF4fCA5zOiDGr+kV7PccGJhCIfVBllGElirqZ/fNY/cBa6DjiUgsSt+nJWwYybHSKZBgo/cTD1/jg== Received: from MW4PR04CA0298.namprd04.prod.outlook.com (2603:10b6:303:89::33) by SA1PR12MB8917.namprd12.prod.outlook.com (2603:10b6:806:386::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.33; Thu, 30 Mar 2023 21:32:09 +0000 Received: from CO1NAM11FT079.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::5a) by MW4PR04CA0298.outlook.office365.com (2603:10b6:303:89::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Thu, 30 Mar 2023 21:32:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT079.mail.protection.outlook.com (10.13.175.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.17 via Frontend Transport; Thu, 30 Mar 2023 21:32:09 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:31:56 -0700 Received: from dev.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:31:55 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 1/9] null_blk: adjust null_param_store_val() Date: Thu, 30 Mar 2023 14:31:26 -0700 Message-ID: <20230330213134.131298-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT079:EE_|SA1PR12MB8917:EE_ X-MS-Office365-Filtering-Correlation-Id: 74378f0d-e9a1-4fd0-5d22-08db316637a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wHiMUurpbWwilRymtt0FF3MyPj9/01ycEgYrqklS1LrqAXKMUkTpqZQb2Ax7iWVoMMkPxJ/C+X1Trzjp5BxRNlQ/yUuHy4NaFjWu3hxaS/pXB/Lt23FwEznnsFZdC0ZUT+FrKmG/St1L2N5qSTzb4IWCsrS5eMR0X6W7Ge+LoMBEHvrupxlY0OYTZlbx4bE4CJyN/iMcZsZ36hcEUZYbuorAjBaJNP0A3iwZc9FPVKORShQmiUXRi+5X6BbCgE3/111fauVLNJkhH9atdPYzdcPg4aXwU144D68el4OntDNUXL72VCBToLwXumqD+/RvHTV0zWr2IS3Tv1MamvTNa1UMcnHdqMmZu2kpPUeDaSx2PePmsv9Mt0LHSuvX/I+N5K1J1upipIcgnxoWbHWNRqegCfCae6RUfr8PJKKgDttLUHM2oNV+YTxS1UB4srKpud3/vDxNsqVaMLacxMRE6WtMGSDmahs5VruWQ16wrw837rmIgvNpkbJ75aEAdLgA/i4KURk04VKjEBVTebhrSGVt7FXV/3tZ9G7PuyeTitcAIRrN9lrkSGbjy7jjYFcLiLoQOQ5b6PO62c5OKzrvhaHyg1xLTTv8/fnkyqK/5PyLmU7tYejOC0/v7av31XgkdyK55h35QrQIwKX2OB4ZExKJfvBzskO/t2ggbcp32qLOMvVkbved5r5/Ij/wqocCbfu7noNAo9vFUlWC94jSnIgpS5eDDX3CMMRxtgKa+k8KfTCeWcjJQe1h3ge2NryWR6il7jyIItQ6K7MfPGRExg== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(39860400002)(396003)(346002)(451199021)(40470700004)(46966006)(36840700001)(16526019)(2906002)(5660300002)(316002)(82310400005)(7696005)(40460700003)(8676002)(70586007)(36756003)(6916009)(70206006)(54906003)(36860700001)(4326008)(34020700004)(478600001)(40480700001)(82740400003)(41300700001)(356005)(83380400001)(7636003)(2616005)(186003)(6666004)(8936002)(1076003)(26005)(426003)(336012)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:32:09.1972 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74378f0d-e9a1-4fd0-5d22-08db316637a5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT079.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8917 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move null_param_store_val() top of all the module parameter decalrations so it can be used by next patches in this series, also while at it rename this function to null_param_store_int() since it is only validating values of type int and not generic one. No functional change in this pacth. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 9e6b032c8ecc..cf6937f4cfa1 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -77,6 +77,21 @@ enum { NULL_IRQ_TIMER = 2, }; +static int null_param_store_int(const char *str, int *val, int min, int max) +{ + int ret, new_val; + + ret = kstrtoint(str, 10, &new_val); + if (ret) + return -EINVAL; + + if (new_val < min || new_val > max) + return -EINVAL; + + *val = new_val; + return 0; +} + static bool g_virt_boundary = false; module_param_named(virt_boundary, g_virt_boundary, bool, 0444); MODULE_PARM_DESC(virt_boundary, "Require a virtual boundary for the device. Default: False"); @@ -117,24 +132,9 @@ MODULE_PARM_DESC(init_hctx, "Fault injection to fail hctx init. init_hctx= max) - return -EINVAL; - - *val = new_val; - return 0; -} - static int null_set_queue_mode(const char *str, const struct kernel_param *kp) { - return null_param_store_val(str, &g_queue_mode, NULL_Q_BIO, NULL_Q_MQ); + return null_param_store_int(str, &g_queue_mode, NULL_Q_BIO, NULL_Q_MQ); } static const struct kernel_param_ops null_queue_mode_param_ops = { @@ -177,7 +177,7 @@ static int g_irqmode = NULL_IRQ_SOFTIRQ; static int null_set_irqmode(const char *str, const struct kernel_param *kp) { - return null_param_store_val(str, &g_irqmode, NULL_IRQ_NONE, + return null_param_store_int(str, &g_irqmode, NULL_IRQ_NONE, NULL_IRQ_TIMER); } From patchwork Thu Mar 30 21:31:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1F49C7619A for ; Thu, 30 Mar 2023 21:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbjC3Vc1 (ORCPT ); Thu, 30 Mar 2023 17:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjC3VcZ (ORCPT ); Thu, 30 Mar 2023 17:32:25 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2043.outbound.protection.outlook.com [40.107.244.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41C31EF9C for ; Thu, 30 Mar 2023 14:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iVpwukiGV+WkPrsnS8dhXLSr68p0yVviYs/+oALXNIYF55G0+51nBf74EvllN4WK19yRQsdVqCBRfDe5BSYicZTiTsbFg9Bp3U7A/1xLNpBPFbZgWUVpLTVAHeNgrYd43BCwXl0eIs6zoradHnBUO8AbWLY/5VdqOI5UJGiRPqRIMxV5yUln5ZAcN03xROk8hq9f5+Bxsf6rsLoR+tUGH2gcBabBfeTTIcJkcSmzUZmpcRVlVZ3+hzk6pCZqfJId1OZS1d+mY/TSNW73CHba3pd10obmwzLL9+nab4zV4aLlIq8qQdPvqh73UIFhD1+IpgMo3/HhTVyl6Pv8KTLjMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2rhL85XEERYkQDfbI7NGkA6TTlVmWKwCDKOaBub5UKM=; b=B7QrVWtxtk8X9q/vUSDqomlK7Pv0XIwdS4W7WHl3qophNOP97RGp/cExXtRMVsRh6hBqAVwwY6+xTEAK/xioL+H+XI3MyvP7SEe78CBptiGm8zTyoSnCt0t9b8Fljz+fuGGe+ZYVeUD/RCVCDnRpl3O7wNqhAIyuJHUgl7hm7LIfWGqZBjU+msz6RYNRenj/nSRybzGqicm2x3w3C8L/aRsrdMDwyVHt7sAfEtdltPr37QXUBomkJ4QxO1+QNjqY9tqYoc3lhornSC/i3vVj0lpnmfCjkWFUSSjkvAeKfsdBqLj6q23BhrerEKT48DIoqa30UuXEWgfX9dlpKKdsKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2rhL85XEERYkQDfbI7NGkA6TTlVmWKwCDKOaBub5UKM=; b=ZgFJFul/T+S5d/GPeazxNyrHuvJMKvbAVrlNy0gyN3OIV1H9MRfYjr0rL6dowJErlFL+4M9c4cB/JYy4rR+9OIgMxSa48ONmaibT4rgLxN4OysSKkqTilWS5WLrZfYw8AVEwyJA63E6jc5VKb/iPGQjl/I4Lzo21TdWZ4q9Q4oIMu6bi6Pb5sR3pEP/uJ+louD4IcElntyspVBK2N+wV3jKZn8zjB1bOmMcA5jHhRkiYxD3OSIMiSbTZ5zBxvtqGXA5gtjUbO0/KZBXjykXA/9qWQJ2yUdIvyfOiKXq8dZdgksErf7OQghGH8bAYcB4go+jsLwoYeCa5Q78z5IbwrQ== Received: from DS7PR07CA0009.namprd07.prod.outlook.com (2603:10b6:5:3af::9) by SA1PR12MB5670.namprd12.prod.outlook.com (2603:10b6:806:239::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.31; Thu, 30 Mar 2023 21:32:20 +0000 Received: from DM6NAM11FT081.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::54) by DS7PR07CA0009.outlook.office365.com (2603:10b6:5:3af::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Thu, 30 Mar 2023 21:32:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT081.mail.protection.outlook.com (10.13.172.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.22 via Frontend Transport; Thu, 30 Mar 2023 21:32:19 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:32:07 -0700 Received: from dev.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:32:06 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 2/9] null_blk: check for valid submit_queue value Date: Thu, 30 Mar 2023 14:31:27 -0700 Message-ID: <20230330213134.131298-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT081:EE_|SA1PR12MB5670:EE_ X-MS-Office365-Filtering-Correlation-Id: 569cf018-3c03-4550-3d76-08db31663e09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6+V+zFf6Qk1hrov7hX122Jkr/pgbQ5ogRO12Wdrnm7csiylTVsXWfIglz4jVsG720lcJokOvB32nfInzllFA32MQUYby1VEmPRRGQWnKksIPAR6/Q/gVlxdAzUi0SawRKM9zKPaHzeyfdx3ckl7cZpBlpOQeSs27kJiPM83RFxrWDeUw00jMExxmfS4rmbVOC8C4C0d3t+1dT0zpzHWRhVah2dgwzjmQ43FXiO+dpS8/90Ab+p+br4RQSkI2jU2SQ0kA7+p0obMTOktrkKo0OK8GDDZVqOre2BjsmW/EVXlavTbZJHAVpQliF1P7e07PwkW2GaIQWoNtsDg1LWWksMhSBg4HPQtOzkUujWpAdJKn5ilU1ZlxeCbRVdiQ3513wW/fowj417KkNYRmFr4LLfIM+y0SDOmq9Nm9C2zhovuq53tSSj7QjSNAWG9HKfzqUIdEYZoGRcmhsMJvhPQu+vZU5dWJT8YY6z6jBqofRiWRZcEgqvgDe1+gnKUjeZjttFKgyKY0RAmylWFoRgtBxytwHvIFaFjk5UAYn0zUzOFq4b8X0dn2Yj5M6FStzvjoA3Qn1AA2ZM21sS9b0VSmZBqBnbNsckomP7yBcYvXD7yLlssfz2mPg66+Ho934K5i87Al1WQ3tvkFB6FZKXtwK2VMalhviqGWIqym1eTjqiMVvt2KvwRbDYIkqI6EJh1CH+cg+czOcber8lZMqu6OJwFljd0mG/E/8sx8Dhpi+cqXNd8rfCwmBNtxRalZHRgX2DPj02CtQkRxOa8c1lDsFWXkteOHFx9Aa+U6W/yrNDs= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(346002)(136003)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(6666004)(1076003)(7636003)(26005)(82740400003)(186003)(426003)(34020700004)(2906002)(47076005)(2616005)(16526019)(5660300002)(36860700001)(8936002)(54906003)(82310400005)(36756003)(478600001)(316002)(7696005)(70206006)(40460700003)(4326008)(336012)(41300700001)(8676002)(6916009)(40480700001)(70586007)(356005)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:32:19.8869 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 569cf018-3c03-4550-3d76-08db31663e09 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT081.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5670 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for submit_queue, that allows user to set negative values. Add a callback null_set_submit_queues() to error out when submit_queue value is < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index cf6937f4cfa1..9e3df92d0b98 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -100,8 +100,18 @@ static int g_no_sched; module_param_named(no_sched, g_no_sched, int, 0444); MODULE_PARM_DESC(no_sched, "No io scheduler"); +static int null_set_submit_queues(const char *s, const struct kernel_param *kp) +{ + return null_param_store_int(s, kp->arg, 1, INT_MAX); +} + +static const struct kernel_param_ops null_submit_queues_param_ops = { + .set = null_set_submit_queues, + .get = param_get_int, +}; + static int g_submit_queues = 1; -module_param_named(submit_queues, g_submit_queues, int, 0444); +device_param_cb(submit_queues, &null_submit_queues_param_ops, &g_submit_queues, 0444); MODULE_PARM_DESC(submit_queues, "Number of submission queues"); static int g_poll_queues = 1; From patchwork Thu Mar 30 21:31:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2158FC761AF for ; Thu, 30 Mar 2023 21:32:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229957AbjC3Vcf (ORCPT ); Thu, 30 Mar 2023 17:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbjC3Vce (ORCPT ); Thu, 30 Mar 2023 17:32:34 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2055.outbound.protection.outlook.com [40.107.243.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2DDC17F for ; Thu, 30 Mar 2023 14:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vv3Ym9Nt8TW+DiAHu35EbHyFEDryqfaNWuej/qEa3z/WvdbrUjnz8DVBvv44AgCAj6Su27DkqRWSV+1DKWX1dQTn4Aj6uxshOpWOJIro+1/iUmshgnel5RFR8qmxJbUiV27begFWGEgk22OC0/pnEl9dHYG+HJBGt01vE8a2xGcF+gO5ZBVTyF6VHI41Ge8nS2l1507RnRGdf36K96dfLC+Nnz+0fOFidN3L4MjljDnu5nW6CDDb3W0zvqCfQ2pGexVCKAOOte71oXFqQCpEKRFPjUkUdHwnrn2PXWHG2Y+w7GW/X03XYFw/ghI/J23E+1eMJbPW566zeHPBHelofg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W7aqTgXCusz2603X+GMtML6EwUJHH/9ANUdGNqbud8c=; b=h8APj1yBxxzHGwNsu8uBe44Ul8dVrkBEaQmMb2gEZA4NdshCpRyOjE5eS9IoXJk9g2jnJk0h+ohI+gbvq6DZUwT+QGSeX1t7i05j6prewapy3TwmdmBzupq7A9EllOc6OsyzEiIbWxOfgmtGWOk1CtSyFrhIXgjAxaS8bpC/aZsgJlK7MALkh5ZleubAYqBYcAixed/6MDsd0/j+JIL/DCI/zynkbSjYtJYN0HcUWJz9ZHdt76f4HJrxi1AsQ1I4DP/rRn1xnhOMPhIK34iwOZSSvjXwxBv/UpEAJp3KsbIjFfcM0DWgmCXGELUpG4P6kiagvzC5zYoBz7i801d9uw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W7aqTgXCusz2603X+GMtML6EwUJHH/9ANUdGNqbud8c=; b=TvdZ+EtRGgQpZBQKh9lWDwoiH31LU9OkZTI+UtyvWJq4NaKyCBw1CxqXsmUb/7Uh+bzv2uS7XwnrRuA04eqBOiOkCjobL7CYl/NafvyxpFyDPU3k4AHX5h8K3MsG/sQOJUmjj5HYeCiPuQ0B5PUChav/kLVOpKWcOXlQwFpaICi9sWL0FiSRLpdlsuv4ZEK5KZ7OH2bz5+ReaHshK84x4/uNwSDYHfoHdycoI8v+R5A2dyMzuFPmGJMGQ5uiDRn97M/4Htv4t4vlQPyPXI2bvhe1HclnHcy6Blmxnu5qYnyLyOywsO+ksay6gVe2CIiZzkbtqIGnFl4a0OqX9eszzw== Received: from DS7PR05CA0075.namprd05.prod.outlook.com (2603:10b6:8:57::16) by MW6PR12MB8734.namprd12.prod.outlook.com (2603:10b6:303:249::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.35; Thu, 30 Mar 2023 21:32:31 +0000 Received: from DM6NAM11FT075.eop-nam11.prod.protection.outlook.com (2603:10b6:8:57:cafe::74) by DS7PR05CA0075.outlook.office365.com (2603:10b6:8:57::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.13 via Frontend Transport; Thu, 30 Mar 2023 21:32:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT075.mail.protection.outlook.com (10.13.173.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.23 via Frontend Transport; Thu, 30 Mar 2023 21:32:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:32:18 -0700 Received: from dev.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:32:17 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 3/9] null_blk: check for valid poll_queue value Date: Thu, 30 Mar 2023 14:31:28 -0700 Message-ID: <20230330213134.131298-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT075:EE_|MW6PR12MB8734:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ae90318-926e-4f12-df29-08db3166449b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HuzAVLa0PKanxvMTaHHwVNzR2QJbjyTsuNWINWftBIXC6bNDv/7pQeg8p4H8Dfy0SeFk4gUlsVyKMtXS3y3qWMuLmedmxUEljJq+6QiLaAPsly4D6Sm1SlQwetNdD+ZNV6TFZPqdERAWIDO7lgoa/eVslyvMr4c9OqBbDLrxY4LR6Sx1zGh5xksaHrx4jpUgBAh0qLSO9A5pLaf5BpypvGht33RDwg7co0wPa5e+AdGChUoG/B2gUHNvbmpcf+YXJFid4UnFrdJT4xnlqHA87JWZolomiz5PKZF2WeFaUTqw8Hpt82TohCFkMa4R5LnR3dMFICIJCKZxRaKySWzESO5bhoLsZOm/QhesFQwHdothVuFDjaYcK6OP7D1UKA+U9KQUs0q0L1ELmk4xN1IF9yHATUn8/B2iferDYWo8uCPmoLtaoq1YA8RQQClP8Ck6oOS0ix+RW4vtB5r1Z7lvwephEaCN0Nue+9VnnCc550Z1ELQ6/j+J13u3Jp1dBLcxbn2EaXc5fe3pDbAAnzPLr9PnI62T0hNVUTxYtn9gz33kMKVKgt97QRT19VW2ys8JmR0W8ht0USbgjWc/+qm0e9QjQc043MHZ6y/nX/5unEDwZRqZkAtLCFHl9B/EL2vvFGLjWswW6yI/q4WlcnIFvNQzQZ17Xlh2I9sKmJJQwnAsbtRO4iUUb7n/SUEEMziXU2RCPFEibZZ+cAa/NZhOYT0rXWgC4ITOqyyazym1rdd/hzAdJyCaOMPeLBRzL511K4uhe2n0+y6FjHxNLFN9hMP4nPff752svZ230c0wC8KeC57N9rRgVrNmq/o4L/cm X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(70586007)(2616005)(83380400001)(36756003)(7636003)(5660300002)(40460700003)(8936002)(82310400005)(356005)(8676002)(40480700001)(41300700001)(82740400003)(70206006)(4326008)(47076005)(2906002)(6916009)(478600001)(426003)(34020700004)(336012)(6666004)(186003)(36860700001)(16526019)(316002)(26005)(7696005)(1076003)(54906003)(473944003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:32:30.8985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ae90318-926e-4f12-df29-08db3166449b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT075.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8734 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for poll_queue, that allows user to set negative values. Add a callback to error out when poll_queue value is set < 1 before module is loaded. This fixes following message with invalid poll_queues value set more than num_online_cpus(): $echo $(nproc) 48 $ for i in `seq 45 49`; do modprobe -r null_blk modprobe null_blk poll_queues=$i echo "poll_queues = $i" dmesg -c done poll_queues = 45 blk_queue_max_hw_sectors: set to minimum 8 null_blk: disk nullb0 created null_blk: module loaded blk_queue_max_hw_sectors: set to minimum 8 null_blk: disk nullb0 created null_blk: module loaded 46 blk_queue_max_hw_sectors: set to minimum 8 null_blk: disk nullb0 created null_blk: module loaded 47 blk_queue_max_hw_sectors: set to minimum 8 null_blk: disk nullb0 created null_blk: module loaded 48 blk_queue_max_hw_sectors: set to minimum 8 null_blk: disk nullb0 created null_blk: module loaded 49 ------------[ cut here ]------------ WARNING: CPU: 23 PID: 36379 at lib/group_cpus.c:400 group_cpus_evenly+0x26e/0x280 CPU: 23 PID: 36379 Comm: modprobe Tainted: G W O N 6.3.0-rc1lblk+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 RIP: 0010:group_cpus_evenly+0x26e/0x280 Code: b1 ff 48 8b 7c 24 08 e8 20 d1 5d 00 48 8b 3c 24 e8 17 d1 5d 00 45 85 ed 0f 89 01 fe ff ff e9 f1 fd ff ff e8 b4 9d 8d ff eb ac <0f> 0b eb a8 e8 39 c4 60 00 41 bd f4 ff ff ff eb 9b cc 90 90 90 90 RSP: 0018:ffffc90000723cb8 EFLAGS: 00010297 RAX: 0000000080000000 RBX: 0000000000000031 RCX: 0000000000000000 RDX: 0000000000000001 RSI: 0000000000000030 RDI: 00000000ffffffff RBP: ffff88884b2204f0 R08: ffff88884b220bd8 R09: ffff8888c31f0000 R10: ffff88884b220bd8 R11: 0000000000000000 R12: ffff8888c31f0000 R13: 0000000000000000 R14: 0000000000000030 R15: 0000000000000000 FS: 00007f5ff6be8b80(0000) GS:ffff888fff7c0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f5ff6706800 CR3: 0000000849554000 CR4: 0000000000350ee0 DR0: ffffffff843793e0 DR1: ffffffff843793e1 DR2: ffffffff843793e2 DR3: ffffffff843793e3 DR6: 00000000ffff0ff0 DR7: 0000000000000600 Call Trace: blk_mq_map_queues+0x16/0xc0 null_map_queues+0xa5/0xe0 [null_blk] blk_mq_alloc_tag_set+0x14d/0x3f0 ? __kmalloc+0xbc/0x130 null_add_dev.part.0+0x601/0x700 [null_blk] null_init+0x109/0xff0 [null_blk] ? __pfx_init_module+0x10/0x10 [null_blk] do_one_initcall+0x44/0x220 ? kmalloc_trace+0x25/0x90 do_init_module+0x4c/0x210 __do_sys_finit_module+0xb4/0x130 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc RIP: 0033:0x7f5ff672c15d Code: c5 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d e3 7c 0c 00 f7 d8 64 89 01 48 RSP: 002b:00007ffd32ca3148 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 000056096285db90 RCX: 00007f5ff672c15d RDX: 0000000000000000 RSI: 000056096285df00 RDI: 0000000000000003 RBP: 0000000000040000 R08: 0000000000000000 R09: 0000000000000020 R10: 0000000000000003 R11: 0000000000000246 R12: 000056096285df00 R13: 000056096285dcc0 R14: 000056096285db90 R15: 000056096285df20 ---[ end trace 0000000000000000 ]--- blk_queue_max_hw_sectors: set to minimum 8 null_blk: disk nullb0 created null_blk: module loaded Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 9e3df92d0b98..29bc4b5720c1 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -114,8 +114,24 @@ static int g_submit_queues = 1; device_param_cb(submit_queues, &null_submit_queues_param_ops, &g_submit_queues, 0444); MODULE_PARM_DESC(submit_queues, "Number of submission queues"); +static int null_set_poll_queues(const char *s, const struct kernel_param *kp) +{ + int ret; + + ret = null_param_store_int(s, kp->arg, 1, num_online_cpus()); + if (ret) + pr_err("out of bound poll_queues [1 .. %u]\n", + num_online_cpus()); + return ret; +} + +static const struct kernel_param_ops null_poll_queues_param_ops = { + .set = null_set_poll_queues, + .get = param_get_int, +}; + static int g_poll_queues = 1; -module_param_named(poll_queues, g_poll_queues, int, 0444); +device_param_cb(poll_queues, &null_poll_queues_param_ops, &g_poll_queues, 0444); MODULE_PARM_DESC(poll_queues, "Number of IOPOLL submission queues"); static int g_home_node = NUMA_NO_NODE; From patchwork Thu Mar 30 21:31:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82519C6FD1D for ; Thu, 30 Mar 2023 21:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229974AbjC3Vcn (ORCPT ); Thu, 30 Mar 2023 17:32:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjC3Vcm (ORCPT ); Thu, 30 Mar 2023 17:32:42 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060.outbound.protection.outlook.com [40.107.220.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82358CA26 for ; Thu, 30 Mar 2023 14:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nEy23+5EIXMKonByHpbm10ytvMEmuCNeMEobHlan9zQKmkHIZzxkz4+jKwN2iKZJHF6ALzkBEJn3jKQIUVM4sklU2BY6U5d08G8pWghCDgaHkYO/jmOd/edzmVLF1YI2VbCeDewHHu9azhm3cRogjZr3PG0OtthW/W9aIB9xevI+Fv4WTfND1VijOLF790O4H5u7krCKZPXs31LJBzbtoY2PYP0odzbrNNElE7h79JDtIvcqaNmm0xkKT8Ap5xqqRNWf9PSr/L5uqaLJ1D9PYVS4ePYU5MS0+dILTCqy7/3l5pQcG49VSYRIiwMGNWJUslyuc1ZdVeNdoc5KsSCNZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bLGEFvAD3iYIPweXY9TYHtGQB3SOQ++9SjP8ThxJ9MU=; b=XIR8x59G98sOlERt67eZ4/XJszxNRc4LTAfn10n3Fh4PchU2KBZ1DtZ3dsahJoD5lIpEAqH5ZfFPTOVZj86N9NmFJoRy+fWm3fKlItAOahugspAIv6aIk/446G9eTAin0ZhqcrJ9PbVSl/EcELKC4Itw67cXo0oeDjnkiMeC0/jYwgUopW/yQBC53ZN5x4komAh6/lL+mONy99ScrSzYaaieBpxmkUHuDui8Zti2m8425skNVkY+C8fJ1jeq8mIWGipzgn5jM5cGW1kwmJoCRtbSiJdidirIRkjrQN3XlG9ACDU4jorMhiv/iYj3oBrLD+ceTF3IZCrLGSkzMGxc0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bLGEFvAD3iYIPweXY9TYHtGQB3SOQ++9SjP8ThxJ9MU=; b=gzaA1pj+VExjxsGazo/IF94MypymGVqJV9Juso7flbM2TZ+iIod7WWKRF7wXn7FMkX3XxPTFpJffu6kIRt/cKECk4/auvuh9Gbm4ZYp2A/FFYEyiEBR4D/21IO23dYnLUQD6lenfkT0wPt0hgobkiL/mr9JWqnc/T4vTf8KcIkc+0yLR88qnIcpYWw5A0Y2kGSaqKR+O4tmU+JsaHWrGbxXyoLcUHdMQzr/zNUK5FGEVOYBgzInQ+HNOBvz1qNAdlPyV5fe3nw01UViLctg+qe738gnU1Kg5hqGvnWplRGgu/KAR8Z0aHts/fzClqGiH1QsELLiGPKGAD60Mc5pFxw== Received: from DS7PR07CA0018.namprd07.prod.outlook.com (2603:10b6:5:3af::27) by DM8PR12MB5446.namprd12.prod.outlook.com (2603:10b6:8:3c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22; Thu, 30 Mar 2023 21:32:39 +0000 Received: from DM6NAM11FT081.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::bb) by DS7PR07CA0018.outlook.office365.com (2603:10b6:5:3af::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Thu, 30 Mar 2023 21:32:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT081.mail.protection.outlook.com (10.13.172.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.22 via Frontend Transport; Thu, 30 Mar 2023 21:32:39 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:32:29 -0700 Received: from dev.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:32:29 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 4/9] null_blk: check for valid gb value Date: Thu, 30 Mar 2023 14:31:29 -0700 Message-ID: <20230330213134.131298-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT081:EE_|DM8PR12MB5446:EE_ X-MS-Office365-Filtering-Correlation-Id: dafba594-1382-4db2-5585-08db316649a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TpYqx5TdrnEv3/xmh/Ya92BPxU4jezZ7d1gvvT48J2HqefypYqYfkvsrwaoLm1yWRPdBShf3ghckDumZzuFSoGE6ZayH3NsaN8yCgA48oWUHPAga76EcUxAJMoeLhTEbg6O3aFYmPf8uGvc63m5rbQE4V2kual8/fiv2VaiL7z69agI1o0CMrwI+8Kjzm17WtyvOPOyCv0gP9/WxwBAiNBB5R6Lwlt1Venwdu0TXqjVWLPEbveKYKWNEoMWQI1EWyhzVXcj8KNmC3/oBX4gCs7uWVy32Al3AWEHLUGREANsYJz3W6EIzigmZ7b25LeufuOeufKiVqqCBJbjQP9LvA6Y+1ETm5VDdta5De3iaxowmWs816gTlwLyrSINhHgTjepCqcQNfHoUZJhapHIy+fADyy8iZS4J5FkTg8eVy0woT0Y6hKvpwT9Me/viNwSrQcwpNcI98nc4+4Psw3pdNwXagS6mrFoCloT0GSjjfKKTXbXkrkPlqHoy73xuP/FXANWYoY9EE3mn8Z8aNb8irnVRrLQRoPZwuTf4BQ/Pbx5lmyP3ewlgx2oUcVbUHvO0lKIjjgNe9cDUSCKlPbW4matrHZJsL6s4lD0wS0302N1Ymm4ZaoWnn2QPKKptNRSFFUTTHWb/srqgj7NsYjfANDXmpBZyMaWM5OCRrrVVrb8A0rfqcKFbBwcb9M+l3Usixwfd+5hjQrm5aY3yR5CU0Am/AIqA2FgqLpFC893zArPWUxcgIObaOzdbSYmzsxExZMEr5nHGZkmG8r2UrIPqvIoQXt4+tgxloFxv5pJU0iMQ= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(40480700001)(83380400001)(40460700003)(2616005)(2906002)(5660300002)(7696005)(1076003)(26005)(316002)(7636003)(54906003)(478600001)(36860700001)(34020700004)(8936002)(356005)(8676002)(41300700001)(6916009)(4326008)(70586007)(70206006)(82740400003)(36756003)(186003)(82310400005)(16526019)(47076005)(336012)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:32:39.3386 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dafba594-1382-4db2-5585-08db316649a1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT081.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5446 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for gb, that allows user to set negative values. Add a callback to error out when gb value is set < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 29bc4b5720c1..f55d88ebd7e6 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -171,8 +171,23 @@ static const struct kernel_param_ops null_queue_mode_param_ops = { device_param_cb(queue_mode, &null_queue_mode_param_ops, &g_queue_mode, 0444); MODULE_PARM_DESC(queue_mode, "Block interface to use (0=bio,1=rq,2=multiqueue)"); +static int null_set_gb(const char *s, const struct kernel_param *kp) +{ + int ret; + + ret = null_param_store_int(s, kp->arg, NULL_Q_BIO, NULL_Q_MQ); + if (ret) + pr_err("only positive values are allowed for gb\n"); + return ret; +} + +static const struct kernel_param_ops null_gb_param_ops = { + .set = null_set_gb, + .get = param_get_int, +}; + static int g_gb = 250; -module_param_named(gb, g_gb, int, 0444); +device_param_cb(gb, &null_gb_param_ops, &g_gb, 0444); MODULE_PARM_DESC(gb, "Size in GB"); static int g_bs = 512; From patchwork Thu Mar 30 21:31:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84C69C6FD1D for ; Thu, 30 Mar 2023 21:32:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbjC3Vcw (ORCPT ); Thu, 30 Mar 2023 17:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjC3Vcv (ORCPT ); Thu, 30 Mar 2023 17:32:51 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::601]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 615E3CA26 for ; Thu, 30 Mar 2023 14:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XaZOyvx3lC2KSUc/gxfOR/oZCkoOJgu1OO5limemxJYMKc5+YzyPpwmNdpXOBk7pXolZrPH3p/fEPVWIURa2PVavJnePtqe5AFQ7qlhrNocchiKKcCi/H+GVkWxKfCbV5KoFvL22tC/gxbGV86IQtHosJWzDJYlNOJLsJeV+v5iaQRyU/TGJkLO577r/WUcUY03M3xaZcCNtnnGYaWrKKtL9dC9mG7HWrWouckKZXNHcdF3KwHeijYqYjGZ9Oes+aW9S1/CI5L3+lpygAEKmt0lPt4Ws8GuqjLDeDTOzIPei7WTa43E0sojXgkSySAEfm/Bj/Pi6dRA4QpNKDlaUBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e/Tfg0W2RLBd86B5HfF9hIp9S8HIJaCsipdxWlaUfzA=; b=h67j5FYxidPQEIH5hRhc4e6UfKyNEYWfUX7o5HOANqYVe3VhWgoCYIQQq2755Vgb2MspFuHCeh0VTkAHVK78dXhk/l22UwAXzFy146OjWRgnHhwswunJ8WofGN7nvueWuXreHVqesRVgo/lXymO8VXVK/Tcccf1K0IPlBEYri+dbPBJ5pVlO8fQ3gXbwk93rzEVSEX7lKV6kf0J/qNPdWvVeeVjHxDPb6pBFynFuSZceulNnKbU0+/mgV+guSQYEXDQGyibrQdl/wEOamZ0koQoWcSqknPbShuGI8suI1vuX38gF3xovixS31yRxV4ZIMioH14Ix0j80iZxQ8Z6pzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e/Tfg0W2RLBd86B5HfF9hIp9S8HIJaCsipdxWlaUfzA=; b=BG78O6pgOCLR6to/xBjMzcQbouL1BkJVh23ImIl0vkOox4ikf71ZIGnMqdIvVuzvCAuRnOlt9DWLCVvlgTQQbS/G99E2KmCeq4uxs/6r2lGMiE//3Nijd9BdcvTnQurAiVVCZh7DWJS29/e8nbDa9M+Y9SHJu/8J8DrDz6546HXjOIfFBFoiSsYwAQv2di277J1lcM29KDKjsDDlb5K9erLmDDJqmWKy83FuvSx7zAZdvPd3LoP8vDuOqB4KnW43+7Z2SkOQ9dYs9SVGXyWsypogemkKyD6565m9coNJ1IxWs/W87SWELq4fbEPSkf/VksIlFzHP8D4GIiNVMyzVdQ== Received: from MW4P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::7) by MW3PR12MB4554.namprd12.prod.outlook.com (2603:10b6:303:55::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22; Thu, 30 Mar 2023 21:32:47 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:115:cafe::86) by MW4P220CA0002.outlook.office365.com (2603:10b6:303:115::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Thu, 30 Mar 2023 21:32:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21 via Frontend Transport; Thu, 30 Mar 2023 21:32:47 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:32:41 -0700 Received: from dev.nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:32:40 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 5/9] null_blk: check for valid block size value Date: Thu, 30 Mar 2023 14:31:30 -0700 Message-ID: <20230330213134.131298-6-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT005:EE_|MW3PR12MB4554:EE_ X-MS-Office365-Filtering-Correlation-Id: 76c52c26-6e66-4fc5-3a2b-08db31664e37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s2R4sjtewK8wmQAesCLYFQhTF9jrSPNy15GMyLgMr/5VR8cKrRic2w2B4w/iJU1N6qQ65R0Cw1K8u8qe8bfl09nb6Tc5hW0Y4Cm8O2/Hmz6zm/fldW5G3UMLs7zOZlOPCm4M3EtVKsBF8y+vESgYl2nCs2jXttLuSJgpcmh72LgqGbsZA6pRBkxsqtgnWDDHXha66W7wXUNPG1q8aaJFfZmrXs8G3d9WC6/ssWysgZUs3iONMsu/IHJDcKHVlujtZSf/jrD9CglVcBT9k/tIsGa+SU4PJ608nkoVHkrLRTv/6o5gD3xKOoBWr7NG4hST/0WcueJFY90dGdix6khyU/Y1XJ39AFlx1eU1v7WakFcx4LwYml0dIAMVS2YsKc2F5vJ67XLpixfK6yihslE2tqprfqW/r1zS5UsYa09I5I0ElKGuWcPoH8vvnoO10VwmoB59wgvHx/sa08sVNadzl2Ea0q7M/fLw0seoQGpwXlap6eyMbQir/eF+H1QZIvd0uV7jO4JgMFvfREjpZFy/jBqHuZUw/bUfhsS6ofANY/AgM1S4ge2JhcyG3EKGsYhUDQ45xpcesyDkyRMi9Rpc4depm1o12zvmeOTaqUX/PPyuUafk7O45KLwuAmpPYNx2ut5+dLV+4lCC5hNwgl9oH4P1KapUUxWJNyei8H+mDbiVBTV9ZyvZf2nyUpd0ywTKY2+yUHNVXuW9rt/i8M/Yka0X/Yr1sV1n0TlIGQ11kNnLsS2F+kCS7fTxnw8lLxvD8r2YAKPBBoa++KBdxpMcfYXbbqoJzA2AKvU5l0J4Dvk= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199021)(36840700001)(46966006)(40470700004)(41300700001)(1076003)(34020700004)(36860700001)(2616005)(478600001)(82740400003)(54906003)(356005)(7636003)(40480700001)(36756003)(426003)(336012)(82310400005)(316002)(186003)(26005)(6666004)(16526019)(7696005)(4326008)(40460700003)(6916009)(47076005)(70206006)(83380400001)(70586007)(8676002)(8936002)(5660300002)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:32:47.0787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76c52c26-6e66-4fc5-3a2b-08db31664e37 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4554 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for block size, that allows user to set negative values. Add a callback to error out when block size value is set < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index f55d88ebd7e6..d8d79c66a7aa 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -190,8 +190,23 @@ static int g_gb = 250; device_param_cb(gb, &null_gb_param_ops, &g_gb, 0444); MODULE_PARM_DESC(gb, "Size in GB"); +static int null_set_bs(const char *s, const struct kernel_param *kp) +{ + int ret; + + ret = null_param_store_int(s, kp->arg, 512, INT_MAX); + if (ret) + pr_err("valid range for bs value [512 ... %d]\n", INT_MAX); + return ret; +} + +static const struct kernel_param_ops null_bs_param_ops = { + .set = null_set_bs, + .get = param_get_int, +}; + static int g_bs = 512; -module_param_named(bs, g_bs, int, 0444); +device_param_cb(bs, &null_bs_param_ops, &g_bs, 0444); MODULE_PARM_DESC(bs, "Block size (in bytes)"); static int g_max_sectors; From patchwork Thu Mar 30 21:31:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9FE3C6FD1D for ; Thu, 30 Mar 2023 21:33:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbjC3VdE (ORCPT ); Thu, 30 Mar 2023 17:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjC3VdD (ORCPT ); Thu, 30 Mar 2023 17:33:03 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2068.outbound.protection.outlook.com [40.107.102.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AED35B5 for ; Thu, 30 Mar 2023 14:33:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nek/aHusYm9jnVn2NEfKoWztO92yAn+IlWNFOJXmDyeNNOLCAEEMgg5HBk+QIn/7hzNmvhhO8Akgq1Pf1KDUx02S3gdBAMntX4GOLjAHFf50Re84zbA1qLAsBZiFJ9synyhtbbLgD1lgBBdZ3yYgCSdxZjv8luOJNX3R03J371X/st1Sk9+IjjuFVAlmc4nKwaZ3ST3ak0AkQAe+uJiN/8eiPFkXnSlOtpBGxeX5UT/Ly3EFYh5z9Hwf3xhnM9illfXucLngGmLM9kIJHCz1CMu26c7G09Ucx4Zyye3sAwcIwAJrSTrI1MxPaUFND61RqSCsvMd8ElzsDvbTd3UV/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DpgpRO4z1okmq0mI60XQR47068UT4MFrSQ0Fu84M3lM=; b=PxpiryfGnwI7I6CqsGTGJ9nmGjV3Bc4/SxIrDHp+EQp51DzhYBVjN0V7Rb4jT2x/dFhUQdGX3HnKov+e48GRgdv+T/kMXDdrgvkPfg4hnOnxOvO9YdE8N963aLfKMsK7oV6VcNesr1lmHFKdTXAq/uj5TkuB/BiRT5POwUgHjOeIWOxCoxhB8wZ3lwHLVdvzv545p5snNJ2HSrw0SZefCHaH3//5u2BjhCfsRa4lz6/Ko/QEZsLQW3dyXeEwnEo9FVdQLfmZm5VDY7CzCpPLTMwmnNri7K2hLxFxcQsZ70LdJ5/HJijCRQ+gYl2yXpoPNi7Ac6LjjkWXgQPu2m36xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DpgpRO4z1okmq0mI60XQR47068UT4MFrSQ0Fu84M3lM=; b=Y5RCDZVS6qHWQVDUa/Fzg+N5gfQmaYjEwb2OZ2Dfyeo4dYRCL7Lq1I2YYIUXdPn840hd5PmWhHLvVjPf30lNa49PQZp/2VYTfJdI3AQofqCZMfbAje3jT7zkXXdTUMeDxabbdLmKzNNrZ3qHd5j8UuwmwJMBvLjNdQHmzn++3nxh9EzqPAStmDay3XdSjON7r73n/XKT/qQNdYrGg9UizngftpQKNAZZVA8lMhXHEx0EZAxSnQHyRlL8io8EYPKbnbX1CiN43Ct/np1qvk/mqV/pl9SP9hjGutOrQegexcl9ZEzBZxm2TSjWMp1R289B5pvq6V58YUZStE1MZygZAQ== Received: from DM6PR06CA0083.namprd06.prod.outlook.com (2603:10b6:5:336::16) by SN7PR12MB7155.namprd12.prod.outlook.com (2603:10b6:806:2a6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20; Thu, 30 Mar 2023 21:33:00 +0000 Received: from DM6NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:5:336:cafe::9f) by DM6PR06CA0083.outlook.office365.com (2603:10b6:5:336::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Thu, 30 Mar 2023 21:33:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT107.mail.protection.outlook.com (10.13.172.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Thu, 30 Mar 2023 21:32:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:32:52 -0700 Received: from dev.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:32:51 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 6/9] null_blk: check for valid max_sectors value Date: Thu, 30 Mar 2023 14:31:31 -0700 Message-ID: <20230330213134.131298-7-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT107:EE_|SN7PR12MB7155:EE_ X-MS-Office365-Filtering-Correlation-Id: f9a8f5e7-782e-4e3b-7f28-08db316655ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yMiu7LMJJW4yJ6c+0iYx7CN8s8pwwctYkcrzMHFU+s7cG0p55xTgEgGXcnQKf5fmDSygLEsOo87cSz5KTTUtjYlne37s/ZhJJn+AcnC+4UDi5jcumMyXQLfuu/NjBrhZZgh4ml3y6x076IVaLn0sLbV793JB8TWlOouXExEaNEO4abUb09dzpQ1k1+9JFTNSbGorkWBY/qwcvLis8lfTNxL5Ij7TaL9njbbOIrAJ7KlrQNax7UNmDI/6Z+5nD4FTCPN7gjL3VRqr1axd4VgZNeCC+zuTzI7Eeo1sLDWZ1TKJIsJbEiY5zptDciFTkBUEAIHY0CXXsJAAiAw8eu/57OwkWdQjsH9Fc2XJlGlWb4H2LX0/kiSEJTTqzLh6Fg5kRU/iUN4FBiDa+ULDip7rVq61wNh/8BoZZ48oeHe2b5LaJFMlO0W141uVCL59l9f4zg3dhIuhvdbmkQfoquSDl8e8yJl/ATxY9tcsW5Ddq9MR38GX0bx0vW5iMeXr1eacfH43xOxlWLt/OuA3bMP0RbQxkb2UMmF5ohpHCWnGVDNlEwwtulY35RzfhBMsdzIyj8uYx+ecm7achB4hNW5/DK6wr4p68ojRvtPAkR4R0x1zCckiWO+9KWNpqKy8g9dSAnb1YG9yIm74CrAg3Iau90a2sAcGSpi+hGkljc0dICJ5875AVjSq6We9398INdBIYhqOOSAleGa8k1Nrxi679HwfZGYAkoxkiCZTiQrvkXxStueGDJv6zNIaFME8+dz1HBfM7FCs0qd6w5cnm6PU0e80YMmdEprdD5Tz0eItE8w= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(39860400002)(136003)(346002)(451199021)(40470700004)(46966006)(36840700001)(16526019)(82310400005)(40460700003)(186003)(40480700001)(26005)(1076003)(34020700004)(36860700001)(336012)(7636003)(36756003)(82740400003)(47076005)(83380400001)(426003)(356005)(316002)(70206006)(70586007)(2616005)(54906003)(2906002)(8676002)(8936002)(5660300002)(41300700001)(4326008)(6916009)(6666004)(7696005)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:32:59.9351 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9a8f5e7-782e-4e3b-7f28-08db316655ea X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7155 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for max_sectors, that allows user to set negative values. Add a callback to error out when max_sectors value is set < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index d8d79c66a7aa..c13f0f2b8d86 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -209,8 +209,23 @@ static int g_bs = 512; device_param_cb(bs, &null_bs_param_ops, &g_bs, 0444); MODULE_PARM_DESC(bs, "Block size (in bytes)"); +static int null_set_max_sects(const char *s, const struct kernel_param *kp) +{ + int ret; + + ret = null_param_store_int(s, kp->arg, 1, INT_MAX); + if (ret) + pr_err("only positive values are allowed for max_sectors\n"); + return ret; +} + +static const struct kernel_param_ops null_max_sects_param_ops = { + .set = null_set_max_sects, + .get = param_get_int, +}; + static int g_max_sectors; -module_param_named(max_sectors, g_max_sectors, int, 0444); +device_param_cb(max_sectors, &null_max_sects_param_ops, &g_max_sectors, 0444); MODULE_PARM_DESC(max_sectors, "Maximum size of a command (in 512B sectors)"); static unsigned int nr_devices = 1; From patchwork Thu Mar 30 21:31:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B31DAC7619A for ; Thu, 30 Mar 2023 21:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229603AbjC3VdQ (ORCPT ); Thu, 30 Mar 2023 17:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjC3VdP (ORCPT ); Thu, 30 Mar 2023 17:33:15 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2070.outbound.protection.outlook.com [40.107.93.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0287835B5 for ; Thu, 30 Mar 2023 14:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QRBLccT7F43ud1cDs9lI24DES2+Teymn2hm6Mwo1UUFjM8aycE49yRBF6IjKgS/7QhMOWFG/H9C1q8tFbDecOVSY0HvyJV141yCEb2szvjzlTxZXUr2HNh7YHmmrAWU1mA3nl8/hgQtmD0c3ux2B4FqphFNSZpNv57PMtJflirzAdlV9Tw+TUo5qUE3MPysmxP6rf4sa2Ea0lw93Eh8aZPC8SWJHaaPS/yokW55EybgOe4hCqJ5WOHNRhPpCBAKxvg1Tey4Yn/b86Dm9w/SfaLKd2qDh4mE+g4NK508WlGVWRDA+vOpWUPVVa4hDkVwYXUFQoVJVe2npOUvkPpchgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ay5Z0N6oBRZ4/K2Or1meAgFWdvIhSKpu/PSEKaryELc=; b=WK8H+y+r/LUKjKbWyAFl5UaTGcSC6fZreu6d4sUU3m933XeMK/s2INqdYtCCrjgf8TwIXH00rOvURmTmLU9GlvMvuV7hsZ9ZQzo5RAvxCQQAwrPZqfXiMZK+TwxuYeNNauH/gli0hOESmF243MDsPPQdBB7fqlAr55xKpBg9hjxLQ6ZL+n125ihQqlyizmmEM3B6dhAwyElcZiJdjuMV1K9+uUgFf6gNVny/8bsGF/7vEZjS/+1CJ47JAuA2MihHpngZCqX5sJZVdsanYWy1guC4CfnNL7v3BvfqtFF8d9v8m6wBE8QOi1kPXbM2f9RYof2PDQ4wiX7XFojLzuWnjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ay5Z0N6oBRZ4/K2Or1meAgFWdvIhSKpu/PSEKaryELc=; b=tJqpdejCL5F+ty01Bor6pNb9Efc1U/hgNAt4+JWCiX/3KOI4dVJCkTRANzGMvbuz6220rS9E8GIUIXmzdfLgfu+oNeMeyezOlXEVRt3GROdmZ3JR8nJl4rGpD1tYf7UV4KvmrEtMFuNgpVG2AyhQXLzEmA06wy6YnuGnBuEvKM9Q7kqlM7adS2FO9suRdsxt+HII5DkThftN9pJbS8jlrbQSajJ469qz4vKRBq5tn6Fx1Tdeq+vt1/EgtcrrJWpb0B7p+DgSqERuFn+KXfD0iaKf6pFUVawJqEbmp1kef93PGcGTGKR9Vv1BHeoKKajhD6ysHkeHr2B25fJbbKppAQ== Received: from MW4P220CA0012.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::17) by SJ1PR12MB6337.namprd12.prod.outlook.com (2603:10b6:a03:456::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.32; Thu, 30 Mar 2023 21:33:11 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:115:cafe::fa) by MW4P220CA0012.outlook.office365.com (2603:10b6:303:115::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Thu, 30 Mar 2023 21:33:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21 via Frontend Transport; Thu, 30 Mar 2023 21:33:10 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:33:03 -0700 Received: from dev.nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:33:03 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 7/9] null_blk: check for valid queue depth value Date: Thu, 30 Mar 2023 14:31:32 -0700 Message-ID: <20230330213134.131298-8-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT005:EE_|SJ1PR12MB6337:EE_ X-MS-Office365-Filtering-Correlation-Id: 791ace4c-cc38-450a-c54d-08db31665c76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: usPD2AvvedW7IQqeaj3k1SXCjZmVdE5H4l/zajC3wT9AxrdIXhoMU2K7HPSbyj7O91OG4NIbSBK1ay0xBkq611owkRBWUmAmirPqMcrVva+idBdkiIWuuwMYWozM8vgJ+qmOWckEWRnY8AFOzauLYH5jRIu+dKQLZn31vIT7PYY9gpjyubVOfQhXlQj/ZoRNTzWtJa+eL0s0tQHOCfbA0QTFUGnuy7cSEA4WeJ38UHFGVJ/6SPbXIihpggUppZ26F4zMvFVPVozSUgCcBLahzILGf0ztpAa/T7aQeWTFrisc0SbhTo9Rnkp0OlwGrTslSrmdEqZH3JRVszBr52awf9HqpU8GJN+rTUYmWO7LvAu5kIBqJ1Y7JZvF+hC1OD6a8J+j2l/mtGayVPsYsFuZDUUa7eqjzP8oQA3mS0uCyCjSFxZIycFALx02sbG6qymgVMaEcxonmMmkXsKjqfI9BOcm6HNYsOg/aX6rYEvc8i50QeLrKMwuPSNsMF2iSPq9R2ZryMf1f2v4UZ2kxO8nBAa1JXB2wR15zoHSiYQa03ZiFRPigitYCihX9zU9PoCyiwYChqN82WUITMBNVgCnGQqAGFYeeVIhFfCf5u4N87D2/QdLXXvC0Ed2jxlHrc8J1QSeb71goRu/MGkR6vACfPtkEqN2pSkbit2R1NcKnN+UHzGpol4wpS7f/Fp7zMc7rP5A6R56QJigQ3TL3QwTYW7Nff95kKT+2Q/34X2tmJ4hxq+IP1b0M55yEI35VThBxBdzGYwBY1Pt/bQtto8/U1VQnLYs8zkz2/MLz4OFekI= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(39860400002)(136003)(451199021)(46966006)(40470700004)(36840700001)(6666004)(70206006)(4326008)(40460700003)(1076003)(316002)(6916009)(8936002)(47076005)(26005)(54906003)(34020700004)(82740400003)(41300700001)(356005)(7636003)(70586007)(186003)(83380400001)(5660300002)(2616005)(478600001)(8676002)(336012)(36860700001)(7696005)(426003)(16526019)(82310400005)(2906002)(36756003)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:33:10.9676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 791ace4c-cc38-450a-c54d-08db31665c76 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6337 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for queue depth, that allows user to set negative values. Add a callback to error out when queue depth value is set < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index c13f0f2b8d86..96ced0485e35 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -264,8 +264,23 @@ static unsigned long g_completion_nsec = 10000; module_param_named(completion_nsec, g_completion_nsec, ulong, 0444); MODULE_PARM_DESC(completion_nsec, "Time in ns to complete a request in hardware. Default: 10,000ns"); +static int null_set_hw_queue_depth(const char *s, const struct kernel_param *kp) +{ + int ret; + + ret = null_param_store_int(s, kp->arg, 1, INT_MAX); + if (ret) + pr_err("only positive values are allowed for queue_depth\n"); + return ret; +} + +static const struct kernel_param_ops null_hw_qdepth_param_ops = { + .set = null_set_hw_queue_depth, + .get = param_get_int, +}; + static int g_hw_queue_depth = 64; -module_param_named(hw_queue_depth, g_hw_queue_depth, int, 0444); +device_param_cb(hw_queue_depth, &null_hw_qdepth_param_ops, &g_hw_queue_depth, 0444); MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 64"); static bool g_use_per_node_hctx; From patchwork Thu Mar 30 21:31:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194884 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C40B2C761AF for ; Thu, 30 Mar 2023 21:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjC3Vd3 (ORCPT ); Thu, 30 Mar 2023 17:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjC3Vd2 (ORCPT ); Thu, 30 Mar 2023 17:33:28 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F37EFAD for ; Thu, 30 Mar 2023 14:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cT/7s2P59Y/GK/dux3ybpIzQECGzovezmRjxHuvWRlklKg0pnARyegt8Txt6/8vzGQbVdeoMG2fA0zMsnc+DVtAto7L3WJkwa5FUZ/X4uNxzWt0Mt8bahdU0D6s3CDxf1noRlDhOC4hu3/75AqvrUQtwY8b/j57idwDu74H/PkxJlHQpIBGUrqDksagCPnfp5rGPmjfVLl+FYPPMb3S1YMpFG8t+IahUhE19eAS0/Rc+J5Nm0rSUx283H+qqxoZWAPWsGDYkpzFADXNENF8oj6AoaP/F+dFmqmE3qOB8qXxXfKt3aHDOqRfKqAiG3d2w/2V6v9lUBiaL1prcqcOMDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MadCxwS9c+RauycmyBdgmNdtCtt4D6xzoC+/leRBIMc=; b=X8zb45O1j4dv0fNcTAskDRwUHH2/TPO9Kvz6YqSgnQKH5q12HsEgdgDbH7BkkjzKVTnssBFWwl3PasQqruMCd9XcVDlnSNSqgfQColxI+t31qwSQZBn94SL4dptVBsBpa7yVDkgmEdCpJkezj14XWAOjzGij/BxnJP2aIEUMsTVyXYqjrOD4fRbLD9UB0IVHlwO6bIrXGgllYxks1M+Ot03hVv+E5YmaF394T7pZi8jc2jUYnD3+1hULH7P9JSTqaOjwa2KZwrWqj75jEDWTK39sL8/5CvzDXJO/GnfhR8NGfOsIre1Eb2EvT/1bjL1cqUpvsiLmNsgzilH4U4euWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MadCxwS9c+RauycmyBdgmNdtCtt4D6xzoC+/leRBIMc=; b=Ixu22Lx0kZSQYMNvmx47DpFaIjQxFzgRxFA2m8yNet8o/WfAvSKxO65apV0iHmA3nH7F/nUapnMH8Bnrj/aUSq2MYc2B6wXXJR561S2uv4wzSBRvgz16pO+gLYwdQf8k+X/54tgteyrNpe98PgBWKE/9HmxROoswvc8ooWMExabr8jG0uqYCjmkzaPGFCxIHrWGta92GvYeScb6QBnEK/N8xgxyUeMIMiCOPqGJUiAZhlJZncV3cZql2hMn5LFu2qH+Yz+xRhg9yK5epIllfth4zDJFnLTitZ5WNe/M0F7TsogeFHvSWkaytOQ0tG9Z5irkADw5KYw/W5sI1KIbFew== Received: from MW4PR03CA0349.namprd03.prod.outlook.com (2603:10b6:303:dc::24) by SA1PR12MB8700.namprd12.prod.outlook.com (2603:10b6:806:388::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.33; Thu, 30 Mar 2023 21:33:25 +0000 Received: from CO1NAM11FT114.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::ac) by MW4PR03CA0349.outlook.office365.com (2603:10b6:303:dc::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Thu, 30 Mar 2023 21:33:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT114.mail.protection.outlook.com (10.13.174.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.14 via Frontend Transport; Thu, 30 Mar 2023 21:33:24 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:33:15 -0700 Received: from dev.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:33:14 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 8/9] null_blk: avoid use global modparam g_queue_mode Date: Thu, 30 Mar 2023 14:31:33 -0700 Message-ID: <20230330213134.131298-9-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT114:EE_|SA1PR12MB8700:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b9fa025-c266-4323-cf89-08db316664c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r0AZ72JWZqfM4K3UtoD4y+ZmFN/Ufd0nPo9vygJS0JS27ptVKgqAEODHIUvltt7TKP+rTIxWyTYHERuAwtZUAyosKMgTCxGmt2lQTNbsSvgDi2x9cG/O6pIWlQBwhzy0ptlBqeYgJmg5LT8zrJX22Jp2a/q2nSDNg/84yAdCliCQumFZgS62KwDJE37VOA/AOVuI6QZaFU713DQfdrnQw0/J5BDrGqBohDKcojEB5gDhgIxjewzDY0gApKlVUFOG659P4udEPUYxe+khi31pZ3ruDT9dXiw+b9jfoGACjN16pHQKZ+cYS42FgYxb598JRUQnKX2WL7ULiBV3W0+UrTz8RP7BO19SN2307QeXn2X/0vsl/R1SF23VgDhta9k/n7SOaa6cbwKvt9JQKIMqzrzjsjrLDifD2UhvodtEl1ChFRVQX+enC3qI4KfZIwlx50aX4xDDLvftUYEpDs5l6Zz4StpkKt8bVCmcOi2bsHL0B0TZgLEwCEG7wuLLuwos16lsfntGIwVKtHUxkABxfKIRNyaMaHum7ZHkQMJixMub6Cd8JNZw6XEGIACgyEtZrRn7Q+E3+k/WD+MqZOvItLaXJyUjmQTaFxGQj8MeD99v1QhV17jyp7lwtWV6RSsqZOOUlAc0ButJT1GtsCTuKao1mbmeslRGcqPVBKmWH8aQrpLYsABPUdj6AQyC8coSlrNUaaevakFl/BNBehkp08JmzMQ/5O5Hcay4NU37wpkB8bJoF39RCwOsKzdtUo6aOswtP3V+7wa/3tjjGENnOyMtTPUayAHbk4Y+XBFQKqI= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(8936002)(4326008)(2906002)(41300700001)(5660300002)(356005)(426003)(40480700001)(7636003)(36756003)(82310400005)(40460700003)(82740400003)(478600001)(6916009)(1076003)(54906003)(316002)(7696005)(6666004)(26005)(2616005)(70206006)(8676002)(83380400001)(336012)(186003)(70586007)(34020700004)(16526019)(47076005)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:33:24.9074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b9fa025-c266-4323-cf89-08db316664c5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT114.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8700 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The reference to module parameter is already present in the struct kernel_param dp->arg include/linux/moduleparam.h :- device_param_cb(name, ops, arg, perm) level_param_cb(name, ops, arg, perm, level) __module_param_call(prefix, name, ops, arg, perm, level, flags) 288 /* Default value instead of permissions? */ \ 289 static const char __param_str_##name[] = prefix #name; \ 290 static struct kernel_param __moduleparam_const __param_##name \ 291 __used __section("__param") \ 292 __aligned(__alignof__(struct kernel_param)) \ 293 = { __param_str_##name, THIS_MODULE, ops, \ 294 VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } Replace global reference to the g_queue_mode in null_set_queue_mode() with the function parameter kp-arg and rearrage code that matches nicely with this patch series. Also, use this opportunity to print the error message with valid range. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 96ced0485e35..5325ec57287d 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -156,11 +156,15 @@ module_param_string(init_hctx, g_init_hctx_str, sizeof(g_init_hctx_str), 0444); MODULE_PARM_DESC(init_hctx, "Fault injection to fail hctx init. init_hctx=,,,"); #endif -static int g_queue_mode = NULL_Q_MQ; - static int null_set_queue_mode(const char *str, const struct kernel_param *kp) { - return null_param_store_int(str, &g_queue_mode, NULL_Q_BIO, NULL_Q_MQ); + int ret; + + ret = null_param_store_int(str, kp->arg, NULL_Q_BIO, NULL_Q_MQ); + if (ret) + pr_err("queue_mode valid values BIO: %u, MQ: %u\n", + NULL_Q_BIO, NULL_Q_MQ); + return ret; } static const struct kernel_param_ops null_queue_mode_param_ops = { @@ -168,6 +172,7 @@ static const struct kernel_param_ops null_queue_mode_param_ops = { .get = param_get_int, }; +static int g_queue_mode = NULL_Q_MQ; device_param_cb(queue_mode, &null_queue_mode_param_ops, &g_queue_mode, 0444); MODULE_PARM_DESC(queue_mode, "Block interface to use (0=bio,1=rq,2=multiqueue)"); From patchwork Thu Mar 30 21:31:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13194885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F128CC6FD1D for ; Thu, 30 Mar 2023 21:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229659AbjC3Vdk (ORCPT ); Thu, 30 Mar 2023 17:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjC3Vdj (ORCPT ); Thu, 30 Mar 2023 17:33:39 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A6D9F76B for ; Thu, 30 Mar 2023 14:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kAOkvydzQOMOOhaIOm2e4Ir0f0livstVRWsVlIOZTc3ZtGJDIl1kOLILUWQ04q6DJmHN22ZX4HDH40opWRE/TwtxGSTZIPu0QVDFIJWEe4BGHKth8yPZeJdsLrtNhaFwMrHYOetYi0r173TMd43x3G+c/YSZbJK2f2PhPRktZKDBAzYj+qfkSuLRPP0kxucjikiZJ0NZL/5VlyjfO38KlT6//2CwuSN3HxwJoIGiDJfFUZLUu1Tj6y3w0MD2mrZPJpyZ3mrabZPpjHyaHS/kyq72KSSxWoah0/0MRePhZedIc2V0YC9ArbaULgXXJQO0h+M4s14DdjA+igjvVhMXgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ew1X+UlUO6EJRTQODJdgPIrcr6WdzqakGA6TD7Ha0MY=; b=azhk2kJl6jhVzmnsgdmPzOK/vHp0yLg/uH6KUY0u8LPS0atsIuXNEW/HSGIw3nkdKGb8Y1uY3oTyOWjyerW3+/6qSQKzDqtlipjZEntU0d81sgQLHzrh1LJLBiHne+ZEapJavFmxpFCc72CnEFOwPfIeAAif7sRUkDPjctBm2osOhIzVRyYPWuXWyngk5F0L82VL/81uVu66RGkAXBSuAeJy1oz0P1EBv7bkP7WzCr3oKGBVcQ5GV/TWFz4nqLlPB9DK8/jXv8gfK0LvNqKoKr2CAcogPcASJC6NgKPSP7Lk+7iPLpg2kp/ryNvA8C9Soav9+oBhdZKxg0LYmUI/jA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ew1X+UlUO6EJRTQODJdgPIrcr6WdzqakGA6TD7Ha0MY=; b=hyiDdCtrrRXcld683Umpx2jao/NejtieKnxLR4odRZeKrjPdV0z8ibDlZ9QmAvazMa/Np3VWydTIXDog4Nv/0Q+bbmiTcdok/e6IWA++Sp2/Rs/8b6Im8e9RSenkZ0Bi+Wbh1dbKdvhOdyo/wAS7IV/AV+wNHOFkCPPj1La8l/9eiczwC4zsZ2wR+Ooz53WqOf3I1XItDkmODiI5YLRe+nN8eTfBK8NiSOEGPtxjWtCpGXsJ6tFetFIrIKvl6v79+cfOhwSWCt62EZLjUaYOrf8XStKAIymv8FjiYY5BhIX3qaBlu1kMDMbUoCLtnca01pVDy8V8zRLduwGSTv8q3Q== Received: from DM6PR02CA0047.namprd02.prod.outlook.com (2603:10b6:5:177::24) by SA0PR12MB4574.namprd12.prod.outlook.com (2603:10b6:806:94::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22; Thu, 30 Mar 2023 21:33:36 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::f9) by DM6PR02CA0047.outlook.office365.com (2603:10b6:5:177::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Thu, 30 Mar 2023 21:33:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Thu, 30 Mar 2023 21:33:36 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 30 Mar 2023 14:33:27 -0700 Received: from dev.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 30 Mar 2023 14:33:26 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH V2 9/9] null_blk: avoid use global modparam g_irq_mode Date: Thu, 30 Mar 2023 14:31:34 -0700 Message-ID: <20230330213134.131298-10-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20230330213134.131298-1-kch@nvidia.com> References: <20230330213134.131298-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT054:EE_|SA0PR12MB4574:EE_ X-MS-Office365-Filtering-Correlation-Id: 45e6b818-7d09-4aec-4a67-08db31666bba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H8YegNhg9W3GzDAeN3+XZZg9iinlBxryMrkPEy3jAypBRPlycwA7wGBv241z1/R1Lyu8LTJwblbyDoSE+yMvTcD7z5S6ZxJTBUrnT+yhq19i0oYO/nw0pDbWV0Z/nwmM5Fl7i4/yH0BKJrtaPObJU0DrB6VRsBVyPQPrLovLgW+ttublmDeBcq+2C1DO+Yf4D6DItTDzPJSwTTK3hTt+8zXzIM99I6v7FH7JA522afbfxB230mTF2/sOnvcQ5ezM+8dJp3AoOfwfs7bSFroq6ipo/BpakLu2p/MnC0pImGedqBoVqQmrmlBlGKZ/3eIZnN1bf8ogwkyxpjg1mdUPWK+LEjAuCdaAClcrmSbdKBuSuUp3UNV5G2IyZSYaIvMFES0Sz0msrZbWiDlbvnF+lV59R9PJuTCDkezbOztEMSSh6I16Hfm+n8OLcwnrsF8I6oAoJ2LaT4oko9jWWQncHBQkDqixDMIcXLFDgqKaZWrd7CZORbsCdZozyK92xeY+fENmWiSPyVAYXImBKDvWD4BcSShp5XHqcPqrux8tMgDOA426E4T6vKuLvpUjkin5EdGwH/Iia3D82hPXe/r+slcWBXcSphLbcGfzsFub1sUxdeVUT1jeBa7atuOVfri4xscyod01HUGNEFlTf+qcdmqlRjPOF6cAnB0inOCnB1v2JV9ZhPomnckDzxXESe4LtUZQgCnMJR2osUB197kiTSWcUQtw/w7X8u03ac38k1jLd791pLKfrOwkAaVO5yq0vhdu4OyfwniJZu1hXgebrIyEAbeBy03OFphkT3aV3yg= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(376002)(39860400002)(136003)(451199021)(46966006)(40470700004)(36840700001)(356005)(41300700001)(40460700003)(5660300002)(7636003)(2906002)(82740400003)(8936002)(82310400005)(36756003)(40480700001)(36860700001)(34020700004)(316002)(54906003)(1076003)(26005)(6666004)(2616005)(426003)(47076005)(478600001)(7696005)(8676002)(6916009)(4326008)(336012)(70206006)(70586007)(186003)(83380400001)(16526019);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 21:33:36.5290 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45e6b818-7d09-4aec-4a67-08db31666bba X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4574 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The reference to module parameter is already present in the struct kernel_param dp->arg include/linux/moduleparam.h :- device_param_cb(name, ops, arg, perm) level_param_cb(name, ops, arg, perm, level) __module_param_call(prefix, name, ops, arg, perm, level, flags) 288 /* Default value instead of permissions? */ \ 289 static const char __param_str_##name[] = prefix #name; \ 290 static struct kernel_param __moduleparam_const __param_##name \ 291 __used __section("__param") \ 292 __aligned(__alignof__(struct kernel_param)) \ 293 = { __param_str_##name, THIS_MODULE, ops, \ 294 VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } Replace global reference to the g_irq_mode in null_set_irq_mode() with the function parameter kp-arg and rearrage code that matches nicely with this patch series. Also, use this opportunity to print the error message with valid range. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 5325ec57287d..f34a147e0fa7 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -249,12 +249,14 @@ static bool g_shared_tag_bitmap; module_param_named(shared_tag_bitmap, g_shared_tag_bitmap, bool, 0444); MODULE_PARM_DESC(shared_tag_bitmap, "Use shared tag bitmap for all submission queues for blk-mq"); -static int g_irqmode = NULL_IRQ_SOFTIRQ; - static int null_set_irqmode(const char *str, const struct kernel_param *kp) { - return null_param_store_int(str, &g_irqmode, NULL_IRQ_NONE, - NULL_IRQ_TIMER); + int ret; + + ret = null_param_store_int(str, kp->arg, NULL_IRQ_NONE, NULL_IRQ_TIMER); + if (ret) + pr_err("irqmode valid values 0-none, 1-softirq, 2-timer\n"); + return ret; } static const struct kernel_param_ops null_irqmode_param_ops = { @@ -262,6 +264,7 @@ static const struct kernel_param_ops null_irqmode_param_ops = { .get = param_get_int, }; +static int g_irqmode = NULL_IRQ_SOFTIRQ; device_param_cb(irqmode, &null_irqmode_param_ops, &g_irqmode, 0444); MODULE_PARM_DESC(irqmode, "IRQ completion handler. 0-none, 1-softirq, 2-timer");