From patchwork Tue Apr 5 14:55:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 8752811 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5E99E9F336 for ; Tue, 5 Apr 2016 14:57:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 75DA920390 for ; Tue, 5 Apr 2016 14:57:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C754D2027D for ; Tue, 5 Apr 2016 14:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758382AbcDEO4S (ORCPT ); Tue, 5 Apr 2016 10:56:18 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:36573 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758705AbcDEO4Q (ORCPT ); Tue, 5 Apr 2016 10:56:16 -0400 Received: by mail-wm0-f42.google.com with SMTP id 127so27452709wmu.1 for ; Tue, 05 Apr 2016 07:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MQc3NHyoISgHDF1WZVUG0lmiYk0s7tPpF+EdYbncAbw=; b=h7g05x0Bo86ViGxfyjVKDWXZPB1CF1sT5Floq2zESdapBBFyTJ9TsrVE5p0ASKS/ex X2GPSJvVRI855AFl4cwtp03TYdCf1VxqbOBQahI5VXYzhnvNra5X/0hikBtcemqRR5uU EOUB+HHfoUU4y0PYnqZuSJ68Yu0+PbiJHqfDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MQc3NHyoISgHDF1WZVUG0lmiYk0s7tPpF+EdYbncAbw=; b=mjHD1CRbLDcIdx2auG5TqdEDca1KjibmcQEvHHLZaIJwVHioKOxWwxQneEUpj4gDRN 0iHqWd8VP8xMnrSYuADNrEP5tCqNjn/6nH0eHL94oF4rGzVbDeeM2Izc0FtRPGhLTHEy 0zn9gVdR/KHQJO/d203B432/Qzme3GoJiBOSZ2ktCCrwbV60rk1D26Dy7Tp6xTwVi/kx hEeyizkMp8L3QDGcruLaGR1axjEGsh2oJMJx49/O/hwsB67RlYu00aDxayU3qg2M6Nst seJrMGsTWF2wafIKSYflzLWIwFV+PB3buKub5/0Jc0F2+k+oR6auH30YAdVe49l647ec jUHg== X-Gm-Message-State: AD7BkJIBFkx4JBAkCjWCsNUBWpcgKO58nJ9AzTKUjRebHHA53BHkk7JtU+ZIrQeYPGUH7w== X-Received: by 10.194.84.100 with SMTP id x4mr26251122wjy.169.1459868174606; Tue, 05 Apr 2016 07:56:14 -0700 (PDT) Received: from Macroninja.cnexlabs.com (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id av3sm35125573wjc.44.2016.04.05.07.56.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Apr 2016 07:56:13 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 3/5] lightnvm: add fpg_size and pfpg_size to struct nvm_dev Date: Tue, 5 Apr 2016 16:55:29 +0200 Message-Id: <1459868131-15133-4-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459868131-15133-1-git-send-email-m@bjorling.me> References: <1459868131-15133-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The flash page size (fpg) and size across planes (pfpg) are convenient to know when allocating buffer sizes. This has previously been a calculated in various places. Replace with the pre-calculated values. Signed-off-by: Matias Bjørling Reviewed-by: Johannes Thumshirn --- drivers/lightnvm/core.c | 2 ++ drivers/lightnvm/sysblk.c | 17 +++++++---------- include/linux/lightnvm.h | 2 ++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index f4e04a5..652b8c7 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -476,6 +476,8 @@ static int nvm_core_init(struct nvm_dev *dev) dev->pgs_per_blk = grp->num_pg; dev->blks_per_lun = grp->num_blk; dev->nr_planes = grp->num_pln; + dev->fpg_size = grp->fpg_sz; + dev->pfpg_size = grp->fpg_sz * grp->num_pln; dev->sec_size = grp->csecs; dev->oob_size = grp->sos; dev->sec_per_pg = grp->fpg_sz / grp->csecs; diff --git a/drivers/lightnvm/sysblk.c b/drivers/lightnvm/sysblk.c index 321de1f..8835d89 100644 --- a/drivers/lightnvm/sysblk.c +++ b/drivers/lightnvm/sysblk.c @@ -154,13 +154,12 @@ static int nvm_scan_block(struct nvm_dev *dev, struct ppa_addr *ppa, struct nvm_system_block *sblk) { struct nvm_system_block *cur; - int pg, cursz, ret, found = 0; + int pg, ret, found = 0; /* the full buffer for a flash page is allocated. Only the first of it * contains the system block information */ - cursz = dev->sec_size * dev->sec_per_pg * dev->nr_planes; - cur = kmalloc(cursz, GFP_KERNEL); + cur = kmalloc(dev->pfpg_size, GFP_KERNEL); if (!cur) return -ENOMEM; @@ -169,7 +168,7 @@ static int nvm_scan_block(struct nvm_dev *dev, struct ppa_addr *ppa, ppa->g.pg = ppa_to_slc(dev, pg); ret = nvm_submit_ppa(dev, ppa, 1, NVM_OP_PREAD, NVM_IO_SLC_MODE, - cur, cursz); + cur, dev->pfpg_size); if (ret) { if (ret == NVM_RSP_ERR_EMPTYPAGE) { pr_debug("nvm: sysblk scan empty ppa (%u %u %u %u)\n", @@ -272,14 +271,12 @@ static int nvm_write_and_verify(struct nvm_dev *dev, struct nvm_sb_info *info, { struct nvm_system_block nvmsb; void *buf; - int i, sect, ret, bufsz; + int i, sect, ret; struct ppa_addr *ppas; nvm_cpu_to_sysblk(&nvmsb, info); - /* buffer for flash page */ - bufsz = dev->sec_size * dev->sec_per_pg * dev->nr_planes; - buf = kzalloc(bufsz, GFP_KERNEL); + buf = kzalloc(dev->pfpg_size, GFP_KERNEL); if (!buf) return -ENOMEM; memcpy(buf, &nvmsb, sizeof(struct nvm_system_block)); @@ -309,7 +306,7 @@ static int nvm_write_and_verify(struct nvm_dev *dev, struct nvm_sb_info *info, } ret = nvm_submit_ppa(dev, ppas, dev->sec_per_pg, NVM_OP_PWRITE, - NVM_IO_SLC_MODE, buf, bufsz); + NVM_IO_SLC_MODE, buf, dev->pfpg_size); if (ret) { pr_err("nvm: sysblk failed program (%u %u %u)\n", ppas[0].g.ch, @@ -319,7 +316,7 @@ static int nvm_write_and_verify(struct nvm_dev *dev, struct nvm_sb_info *info, } ret = nvm_submit_ppa(dev, ppas, dev->sec_per_pg, NVM_OP_PREAD, - NVM_IO_SLC_MODE, buf, bufsz); + NVM_IO_SLC_MODE, buf, dev->pfpg_size); if (ret) { pr_err("nvm: sysblk failed read (%u %u %u)\n", ppas[0].g.ch, diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 38814e2..f7c607f 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -323,6 +323,8 @@ struct nvm_dev { int sec_per_pg; /* only sectors for a single page */ int pgs_per_blk; int blks_per_lun; + int fpg_size; + int pfpg_size; /* size of buffer if all pages are to be read */ int sec_size; int oob_size; int mccap;