From patchwork Wed Jun 29 14:41:55 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: 9205491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 79DC1607D8 for ; Wed, 29 Jun 2016 14:44:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B64128667 for ; Wed, 29 Jun 2016 14:44:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 602712866C; Wed, 29 Jun 2016 14:44:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E50BF28667 for ; Wed, 29 Jun 2016 14:44:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753007AbcF2OnN (ORCPT ); Wed, 29 Jun 2016 10:43:13 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36274 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752744AbcF2OmX (ORCPT ); Wed, 29 Jun 2016 10:42:23 -0400 Received: by mail-wm0-f65.google.com with SMTP id c82so14900674wme.3 for ; Wed, 29 Jun 2016 07:42:17 -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=HadtnoNemrT0jM757p+jhuIsOjGqmxJ4F6fyn9TCsWU=; b=Q0eAckblxQZjZL/zcJjdRyJ6mLffQCeQ5GCWr1AnRusQ5gL+WoiO0auXy0liZdKSYs APCiftSB9S9Ngw+G3/8M8rQ27JjrqaWgaZoOVbaJxO4zZUyXEcSIp4eOtGnGK4k3o/DL TcwT0ckQ8etliwpIxRycsJXEDxT5UflEDwIao= 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=HadtnoNemrT0jM757p+jhuIsOjGqmxJ4F6fyn9TCsWU=; b=mWXRC0jSNQoIq1dN78ndUEtW3jTMtdTnxzgzpW2sFmj5PdqSCYVogf3fLCgWvXdQ9H 2tubmfiImNwu2nU8tgakvvwg8ESQvGleF4YOeJCtSZhqzZ/5+WDibWoHJyUmEHopCreK YSHswtO7ztn/XEuQ4pEo2IwxseGHLCyOdjcr/36Lv3IFyCWRi5qNwCjihlZ9cHYWvi4y 3yuQn/uST95x2ZTcm9zB45GZJimYw0mDtCi12CWAZ5QnKeNhO1nQQVjxhfU1dr48VL21 O2jcryV3otC2TZLdz2JcTB4EElogpbC8iUdjjmEhEMXCYQevdgUiN2dFK2ccXuK0hry4 HIRQ== X-Gm-Message-State: ALyK8tIGN/8AQiuGKvSlNViEx4Z8dAHl9vP1ueiXCnmHWobwwRwnN2QBqRMYSHp1+SAaaQ== X-Received: by 10.28.3.66 with SMTP id 63mr9961980wmd.101.1467211337130; Wed, 29 Jun 2016 07:42:17 -0700 (PDT) Received: from Macroninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id t190sm5472766wmt.24.2016.06.29.07.42.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Jun 2016 07:42:16 -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: [RFC PATCH 10/11] lightnvm: make ppa_list const in nvm_set_rqd_list Date: Wed, 29 Jun 2016 16:41:55 +0200 Message-Id: <1467211316-22373-11-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1467211316-22373-1-git-send-email-m@bjorling.me> References: <1467211316-22373-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-Virus-Scanned: ClamAV using ClamSMTP The passed by reference ppa list in nvm_set_rqd_list() is updated when multiple planes are available. In that case, each PPA plane is incremented when the device side PPA list is created. This prevents the caller to rely on the PPA list to be unmodified after a call. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 8 +++++--- include/linux/lightnvm.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index ddc8098..00b64f7 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -237,9 +237,10 @@ void nvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd) EXPORT_SYMBOL(nvm_generic_to_addr_mode); int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd, - struct ppa_addr *ppas, int nr_ppas, int vblk) + const struct ppa_addr *ppas, int nr_ppas, int vblk) { int i, plane_cnt, pl_idx; + struct ppa_addr ppa; if ((!vblk || dev->plane_mode == NVM_PLANE_SINGLE) && nr_ppas == 1) { rqd->nr_ppas = nr_ppas; @@ -264,8 +265,9 @@ int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd, for (i = 0; i < nr_ppas; i++) { for (pl_idx = 0; pl_idx < plane_cnt; pl_idx++) { - ppas[i].g.pl = pl_idx; - rqd->ppa_list[(pl_idx * nr_ppas) + i] = ppas[i]; + ppa = ppas[i]; + ppa.g.pl = pl_idx; + rqd->ppa_list[(pl_idx * nr_ppas) + i] = ppa; } } } diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index e9836cf..ba78b83 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -534,7 +534,7 @@ extern int nvm_submit_io(struct nvm_dev *, struct nvm_rq *); extern void nvm_generic_to_addr_mode(struct nvm_dev *, struct nvm_rq *); extern void nvm_addr_to_generic_mode(struct nvm_dev *, struct nvm_rq *); extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *, - struct ppa_addr *, int, int); + const struct ppa_addr *, int, int); extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *); extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr *, int); extern int nvm_erase_blk(struct nvm_dev *, struct nvm_block *);