From patchwork Tue Nov 24 13:26:48 2015 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: 7690771 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 C29B59F1D3 for ; Tue, 24 Nov 2015 13:27:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2973206F9 for ; Tue, 24 Nov 2015 13:27:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19C53206F6 for ; Tue, 24 Nov 2015 13:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753809AbbKXN10 (ORCPT ); Tue, 24 Nov 2015 08:27:26 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38135 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753887AbbKXN1O (ORCPT ); Tue, 24 Nov 2015 08:27:14 -0500 Received: by wmec201 with SMTP id c201so26493570wme.1 for ; Tue, 24 Nov 2015 05:27:13 -0800 (PST) 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-type:content-transfer-encoding; bh=Xxb7Re4iIyLyRXFerl/jIQhY3nAe6/CS2mBSmeXZszc=; b=mPw1rvJJinY9CQY99ddPuazb/1JeC5jQTwbMinhhG3a6z8XKkm2LjpgBlPN8At8axu xGwULlWzEprvqDSoFv3yddoAnyM8q2m4WhCN+D6DmYjMhKMRqTgbhab5eHNA2L3GUgod sA1xp2m9V8DGN00FltWvo2/whIe8Utpv2+t4A= 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-type:content-transfer-encoding; bh=Xxb7Re4iIyLyRXFerl/jIQhY3nAe6/CS2mBSmeXZszc=; b=eknKCXLgffytHejZ/zQIiWkgrCZ0c8j6fOeFkiVa0sgPRSmWplSK5NoHxuHnFedXuM rMfR0A1V/aMPdXtW8nPzNTxAAxsL9Iemy6OTQVeWFlM0UI/UQnDATr/V9+tXQE0JMLuO tr65nlkReJBjUiKVigCA3VqvrnGM9661rSoTC/CNiFZgBZwIYY1xUk4nxwBQc/b7TPB1 ym8D8EmqFI+aub+yG/VqPcw2erOZjrwvwU20PXQsTk/UFrQnJHrnfN3WeSmNzJEgDnHG RCh5OY7t7quj4+e5W4kLelJPF+odkhhwvuwJJAFDr6CEv4IN03F8tJnhUDcZmK6drZ2f BwMA== X-Gm-Message-State: ALoCoQmnpwWdYQK/2NT9FKqkQD+BL44jP77kby7o+LD6xsEgGlg+sRnwx9djbqNh+p8XKoIPgpJg X-Received: by 10.194.89.226 with SMTP id br2mr40087021wjb.22.1448371633557; Tue, 24 Nov 2015 05:27:13 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id w67sm18215045wmw.17.2015.11.24.05.27.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Nov 2015 05:27:12 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: hch@infradead.org, keith.busch@intel.com, sudipm.mukherjee@gmail.com, ww.tao0320@gmail.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 5/5] lightnvm: do device max sectors boundary check first Date: Tue, 24 Nov 2015 14:26:48 +0100 Message-Id: <1448371608-18053-6-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448371608-18053-1-git-send-email-m@bjorling.me> References: <1448371608-18053-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.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 From: Wenwei Tao do device max_phys_sect boundary check first, otherwise we will allocate dma_pools for devices whose max sectors are beyond lightnvm support and register them. Signed-off-by: Wenwei Tao Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index ea50fa5..ea6dba5 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -308,6 +308,12 @@ int nvm_register(struct request_queue *q, char *disk_name, if (ret) goto err_init; + if (dev->ops->max_phys_sect > 256) { + pr_info("nvm: max sectors supported is 256.\n"); + ret = -EINVAL; + goto err_init; + } + if (dev->ops->max_phys_sect > 1) { dev->ppalist_pool = dev->ops->create_dma_pool(dev->q, "ppalist"); @@ -316,10 +322,6 @@ int nvm_register(struct request_queue *q, char *disk_name, ret = -ENOMEM; goto err_init; } - } else if (dev->ops->max_phys_sect > 256) { - pr_info("nvm: max sectors supported is 256.\n"); - ret = -EINVAL; - goto err_init; } down_write(&nvm_lock);