Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3632743rwb; Tue, 16 Aug 2022 06:29:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR7b6PBQ+bF54yz8oSLiVcr9+1M6bPjvAbTSoRqzezb6HWdLVwJW4BBsOQOmMgCn7W4TrNMV X-Received: by 2002:a17:907:a046:b0:730:9c7a:eab3 with SMTP id gz6-20020a170907a04600b007309c7aeab3mr14010931ejc.285.1660656560923; Tue, 16 Aug 2022 06:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660656560; cv=none; d=google.com; s=arc-20160816; b=Kdq+BpXsF+eJW+atFJFXFfyfmOE+jzip9fjA5f8+T6m1fS1Y9NwNGZfZ0/Tb1DHHZ3 HVQOQGsbu5GpmBNVw2l0dNPQvFAb4JrodKa+XyFrFF/ZGhpk6YQxiFnLg2Ecwdb4V168 USj48cPLOfG6WhHBigAfPx6zwTTBLGI5tJrLcN/kej2LE9jM34S/BgSiZk91dRXIaFJB mfkR+vHtIWCZjGglL05gWOD+O9zIYfG0kyyOXiOYCeRQntUoN6jktRGkyKT0o/kGLVvY rqtZeUc29gz0C4fFmcGk9lLjNZRZjdSvVYZlsrw9PqiInV1i3zEU8dNkv/jo+Vm/LDTa Rbrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=EO928PFpmrq5sHaWlnNhp7CZXI/51IcH8DoHTWAcRM0=; b=korCpKNDMiFvc/V3+nM0PRm+MbpsZp3HkY8efXLN4n70JpM11MtvjwLOuiha23/ncE Fg/4HRvMJhfUlH9rRS9o8NvSW2Ax1+8qdXyDCqxNrETZta6P2Gdw+95rt6tFcHktAIVH 1De+KkRsURppeAKRGqJFqITXukFRHcCdHYw3WrGxdeSaV1JgWSdZpU0JigsADx6MVwvO 2T66+4YBDCcbF/RnbvDqSWa7cmlI4vvN/aMJTxb+ACjMtkQ6+ypXnmo3D4hJ5UDX5frI 9bLXAwliN/yik/Q+ZE2TqRK4ehd0lX2lZSTemhCZ/5zEBoySrofTJezgzVxo1rQUjFXk X7xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=u+LjqtUa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a170906124500b0073113a19ca6si9443441eja.219.2022.08.16.06.28.50; Tue, 16 Aug 2022 06:29:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=u+LjqtUa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235678AbiHPNQ0 (ORCPT + 99 others); Tue, 16 Aug 2022 09:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233972AbiHPNPt (ORCPT ); Tue, 16 Aug 2022 09:15:49 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D89A5FF7A for ; Tue, 16 Aug 2022 06:15:47 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131545euoutp01d2caece1aebbc484efc198081ef4523e~L1Zo0z0Q00135401354euoutp01M for ; Tue, 16 Aug 2022 13:15:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131545euoutp01d2caece1aebbc484efc198081ef4523e~L1Zo0z0Q00135401354euoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655745; bh=EO928PFpmrq5sHaWlnNhp7CZXI/51IcH8DoHTWAcRM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u+LjqtUaKQJ3mJLaXx06eFzSyrMT+xxCcdQ9SNPrLQQfy2OXCz4XaAdy9ix/Stsgt Cs9VxAdNg+viOpydOZh2z7t808qlySuEDUtgm85iS8gM4z0IMz26MPK4awM6gS6uQQ +THHJ02wNl1cr4AULcyhdCKipQsv1n8f4vT0FSdA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131544eucas1p13471fe76b92999809feb4dc6e73873ce~L1ZnEDab70549005490eucas1p19; Tue, 16 Aug 2022 13:15:44 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 2C.B7.10067.F789BF26; Tue, 16 Aug 2022 14:15:43 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131543eucas1p12fd75be0a752006267bbe2c5b3b1a444~L1ZmbG4zH0141101411eucas1p1c; Tue, 16 Aug 2022 13:15:43 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131543eusmtrp1ce374e143ed40b3fb8b3ad4feda88a32~L1ZmJw05K0149801498eusmtrp1F; Tue, 16 Aug 2022 13:15:42 +0000 (GMT) X-AuditID: cbfec7f4-dd7ff70000002753-15-62fb987f0dfc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id ED.A0.09095.E789BF26; Tue, 16 Aug 2022 14:15:42 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131542eusmtip1c4d8f6d05922324c8e9962539b0974ed~L1ZlxxJ302645326453eusmtip1d; Tue, 16 Aug 2022 13:15:42 +0000 (GMT) From: Pankaj Raghav To: damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, agk@redhat.com Cc: pankydev8@gmail.com, gost.dev@samsung.com, matias.bjorling@wdc.com, hare@suse.de, bvanassche@acm.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, Johannes.Thumshirn@wdc.com, linux-block@vger.kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v11 05/13] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size Date: Tue, 16 Aug 2022 15:15:28 +0200 Message-Id: <20220816131536.189406-6-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220816131536.189406-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7r1M34nGVzttrJYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAldE/ ZS9TQaNIxdsZl5gaGM8IdDFy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-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220816131543eucas1p12fd75be0a752006267bbe2c5b3b1a444 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131543eucas1p12fd75be0a752006267bbe2c5b3b1a444 References: <20220816131536.189406-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the condition which disallows non-power_of_2 zone size ZNS drive to be updated and use generic method to calculate number of zones instead of relying on log and shift based calculation on zone size. The power_of_2 calculation has been replaced directly with generic calculation without special handling. Both modified functions are not used in hot paths, they are only used during initialization & revalidation of the ZNS device. As rounddown macro from math.h does not work for 32 bit architectures, round down operation is open coded. Reviewed-by: Luis Chamberlain Reviewed by: Adam Manzanares Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav --- drivers/nvme/host/zns.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index 12316ab51bda..fe1d715d61cc 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -101,13 +101,6 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf) } ns->zsze = nvme_lba_to_sect(ns, le64_to_cpu(id->lbafe[lbaf].zsze)); - if (!is_power_of_2(ns->zsze)) { - dev_warn(ns->ctrl->device, - "invalid zone size:%llu for namespace:%u\n", - ns->zsze, ns->head->ns_id); - status = -ENODEV; - goto free_data; - } disk_set_zoned(ns->disk, BLK_ZONED_HM); blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); @@ -129,7 +122,7 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns, sizeof(struct nvme_zone_descriptor); nr_zones = min_t(unsigned int, nr_zones, - get_capacity(ns->disk) >> ilog2(ns->zsze)); + div64_u64(get_capacity(ns->disk), ns->zsze)); bufsize = sizeof(struct nvme_zone_report) + nr_zones * sizeof(struct nvme_zone_descriptor); @@ -182,6 +175,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, int ret, zone_idx = 0; unsigned int nz, i; size_t buflen; + u64 remainder = 0; if (ns->head->ids.csi != NVME_CSI_ZNS) return -EINVAL; @@ -197,7 +191,9 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, c.zmr.zrasf = NVME_ZRASF_ZONE_REPORT_ALL; c.zmr.pr = NVME_REPORT_ZONE_PARTIAL; - sector &= ~(ns->zsze - 1); + /* Round down the sector value to the nearest zone start */ + div64_u64_rem(sector, ns->zsze, &remainder); + sector -= remainder; while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) { memset(report, 0, buflen); -- 2.25.1