Received: by 10.223.185.116 with SMTP id b49csp3770896wrg; Mon, 26 Feb 2018 05:54:13 -0800 (PST) X-Google-Smtp-Source: AG47ELsI+lHao78+MBBFCfPGyq224YJqr6RofBkb9M8/o1tZPs3el6uXWZBiF02ZJAPAQTWerLqT X-Received: by 2002:a17:902:4581:: with SMTP id n1-v6mr8962008pld.135.1519653252986; Mon, 26 Feb 2018 05:54:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519653252; cv=none; d=google.com; s=arc-20160816; b=KZqmvohVcIVei0Z0EFSr1x61kEfJqOi93cFAJTcfQnYSCNMa3+akd/CoCFRhGDB61K otUkjgh3NNG1DZS6Ck2eK79sXGd8wB63PToel0R7nhmYpSWAX6E9Movjaes/DjGHDKvy O/33RcHWQ+so6okdIbHM9/i9qoocnJB9SZo0SYn8TM0yB0XTmmjkjqCAy0Tk7ToGf3QL ElCcj3QKClqAc9IEoJIibvAe5+aH6MvMa67WLtKHNNSPOW1SBTIHvZB3+QjArPUlxJMb cPnr1givAuXM+bjqRVHB42ob2RqkoiCD9wFm8x0c1yS4x6k/nWDmgj+BrflY0VyrPD3L yAsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=YKzoHwdzLXCldlOGifLoXEEW5lDMVATuRg9MtD+mo/w=; b=LR/F9/NUof4TJEko3QA2ujH4XqHJnV4QlK7itQR6YXznsl95OL1JmxEhT2sCXyyRVu 38aCdCQ6CySzkpVIGtbZU/TIIMOpcwpQ5fOK/5VHKuMz9ZwgN1v0+2nqFR2ceJHtfptw QmUjLV+8FSYZVD8DUcWfQo3YJep0eGofPos9sJmz7FmaPlEqLp7R+YNVYrrNXvfyK7kl OnfQaTq9a8jHAOelEUxmEnN64g+Cq+vqtzMzKZrFbIU4O5cOPE+zn3IUKR+vp1HIpHAd qPyoBKJGMhoTDobhqDHpxvVFQcvihYOSdVgV7RIAIvPCQ6sFRFIez47onH14DG5BtBPt CHiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=L/PO/Gin; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m187si6787101pfb.291.2018.02.26.05.53.58; Mon, 26 Feb 2018 05:54:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=L/PO/Gin; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753463AbeBZNXD (ORCPT + 99 others); Mon, 26 Feb 2018 08:23:03 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:56078 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753225AbeBZNRm (ORCPT ); Mon, 26 Feb 2018 08:17:42 -0500 Received: by mail-wm0-f67.google.com with SMTP id q83so17442001wme.5 for ; Mon, 26 Feb 2018 05:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YKzoHwdzLXCldlOGifLoXEEW5lDMVATuRg9MtD+mo/w=; b=L/PO/GinVaU0CUfJVPKm3nhazIpRs83KvchLpPTD/hAyhunZmwMwEst3B5x75yz1Zm fnohHXbpdqbezOqyZ/c751lWhFNirSq4u5eKUv35MIRh/g/FtrEVI0u5DMi7ld6lQuqd E0yEpuHTx9qDNnJ2JWpWIy65f0JD8MhhHQSsk3fBwy2jD0AcYDCW2uMxyE+IhfAjtE4O LEgZz52seXgK3nVn3eaATCK9YaVIq1wjI6fq9ENKD1afuUCqes7nYm68K6ATbomtyNyk cJBi+xxubCXAUTnwv23MlWpckR6bujiwPAf54GImzJirzt8x9R1+6OI9sYJq4SIQWubh 8qhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YKzoHwdzLXCldlOGifLoXEEW5lDMVATuRg9MtD+mo/w=; b=iubb7h5/BbTAuGp7Eo4/QZ8kGuUq1Gh6wVwesACdCtGppzQniEWPhf3QJi3hnHIMZz gqpo9ph5wH60n4gXli77Mzr+y92k0G4oSrRU6HenKzyPJFiaLz4A1asG5RAeJnOdhU2q gVWSb35qoOG2wiY6icaDNUVchJcbTo2q9fm8ZN58rbEk5GjTE+72jFttywtMNjYOHu5H cFvleBZj1iWe7XEAl84uAWIKr/l4eOfO4rVT0caMLwJXNps8oik3ZbF/VjVYQMVEW4QH E7p2HkQX4ietCq4mCNzmPPvLRAcBJCn+1aC0oGZ7xKA9MiZw21eLlxnIPlWsABvtpZSZ 4ZdQ== X-Gm-Message-State: APf1xPA+hfsRkaajV3grl7/VdGlLYHWwXIFX2hEJlHQH+JdoTc1t2pww bMUa+8IagR5PenBeQo3RVpW84RE0 X-Received: by 10.80.219.139 with SMTP id p11mr14789808edk.192.1519651061019; Mon, 26 Feb 2018 05:17:41 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id g59sm7097451ede.19.2018.02.26.05.17.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 05:17:40 -0800 (PST) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 13/19] lightnvm: make address conversions depend on generic device Date: Mon, 26 Feb 2018 14:17:12 +0100 Message-Id: <1519651038-16845-14-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519651038-16845-1-git-send-email-javier@cnexlabs.com> References: <1519651038-16845-1-git-send-email-javier@cnexlabs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On address conversions, use the generic device, instead of the target device. This allows to use conversions outside of the target's realm. Signed-off-by: Javier González --- drivers/lightnvm/core.c | 4 ++-- include/linux/lightnvm.h | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 92ea6e39dd64..fae5e8c6fcd0 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -588,7 +588,7 @@ static void nvm_ppa_tgt_to_dev(struct nvm_tgt_dev *tgt_dev, for (i = 0; i < nr_ppas; i++) { nvm_map_to_dev(tgt_dev, &ppa_list[i]); - ppa_list[i] = generic_to_dev_addr(tgt_dev, ppa_list[i]); + ppa_list[i] = generic_to_dev_addr(tgt_dev->parent, ppa_list[i]); } } @@ -598,7 +598,7 @@ static void nvm_ppa_dev_to_tgt(struct nvm_tgt_dev *tgt_dev, int i; for (i = 0; i < nr_ppas; i++) { - ppa_list[i] = dev_to_generic_addr(tgt_dev, ppa_list[i]); + ppa_list[i] = dev_to_generic_addr(tgt_dev->parent, ppa_list[i]); nvm_map_to_tgt(tgt_dev, &ppa_list[i]); } } diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 8cda1125c34a..2b909592568a 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -405,15 +405,15 @@ struct nvm_dev { struct list_head targets; }; -static inline struct ppa_addr generic_to_dev_addr(struct nvm_tgt_dev *tgt_dev, +static inline struct ppa_addr generic_to_dev_addr(struct nvm_dev *dev, struct ppa_addr r) { - struct nvm_geo *geo = &tgt_dev->geo; + struct nvm_geo *dev_geo = &dev->geo; struct ppa_addr l; - if (geo->c.version == NVM_OCSSD_SPEC_12) { + if (dev_geo->c.version == NVM_OCSSD_SPEC_12) { struct nvm_addr_format_12 *ppaf = - (struct nvm_addr_format_12 *)&geo->c.addrf; + (struct nvm_addr_format_12 *)&dev_geo->c.addrf; l.ppa = ((u64)r.g.ch) << ppaf->ch_offset; l.ppa |= ((u64)r.g.lun) << ppaf->lun_offset; @@ -422,7 +422,7 @@ static inline struct ppa_addr generic_to_dev_addr(struct nvm_tgt_dev *tgt_dev, l.ppa |= ((u64)r.g.pl) << ppaf->pln_offset; l.ppa |= ((u64)r.g.sec) << ppaf->sec_offset; } else { - struct nvm_addr_format *lbaf = &geo->c.addrf; + struct nvm_addr_format *lbaf = &dev_geo->c.addrf; l.ppa = ((u64)r.m.grp) << lbaf->ch_offset; l.ppa |= ((u64)r.m.pu) << lbaf->lun_offset; @@ -433,17 +433,17 @@ static inline struct ppa_addr generic_to_dev_addr(struct nvm_tgt_dev *tgt_dev, return l; } -static inline struct ppa_addr dev_to_generic_addr(struct nvm_tgt_dev *tgt_dev, +static inline struct ppa_addr dev_to_generic_addr(struct nvm_dev *dev, struct ppa_addr r) { - struct nvm_geo *geo = &tgt_dev->geo; + struct nvm_geo *dev_geo = &dev->geo; struct ppa_addr l; l.ppa = 0; - if (geo->c.version == NVM_OCSSD_SPEC_12) { + if (dev_geo->c.version == NVM_OCSSD_SPEC_12) { struct nvm_addr_format_12 *ppaf = - (struct nvm_addr_format_12 *)&geo->c.addrf; + (struct nvm_addr_format_12 *)&dev_geo->c.addrf; l.g.ch = (r.ppa & ppaf->ch_mask) >> ppaf->ch_offset; l.g.lun = (r.ppa & ppaf->lun_mask) >> ppaf->lun_offset; @@ -452,7 +452,7 @@ static inline struct ppa_addr dev_to_generic_addr(struct nvm_tgt_dev *tgt_dev, l.g.pl = (r.ppa & ppaf->pln_mask) >> ppaf->pln_offset; l.g.sec = (r.ppa & ppaf->sec_mask) >> ppaf->sec_offset; } else { - struct nvm_addr_format *lbaf = &geo->c.addrf; + struct nvm_addr_format *lbaf = &dev_geo->c.addrf; l.m.grp = (r.ppa & lbaf->ch_mask) >> lbaf->ch_offset; l.m.pu = (r.ppa & lbaf->lun_mask) >> lbaf->lun_offset; -- 2.7.4