From patchwork Wed Mar 2 08:55:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Wodkowski X-Patchwork-Id: 8479431 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7DD5FC0553 for ; Wed, 2 Mar 2016 09:06:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D86420114 for ; Wed, 2 Mar 2016 09:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99B5020107 for ; Wed, 2 Mar 2016 09:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753736AbcCBJGj (ORCPT ); Wed, 2 Mar 2016 04:06:39 -0500 Received: from mga09.intel.com ([134.134.136.24]:21083 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751240AbcCBJGg (ORCPT ); Wed, 2 Mar 2016 04:06:36 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 02 Mar 2016 01:06:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,527,1449561600"; d="scan'208";a="915100379" Received: from gklab-246-016.igk.intel.com (HELO olimp) ([10.217.246.16]) by fmsmga001.fm.intel.com with SMTP; 02 Mar 2016 01:06:22 -0800 Received: by olimp (sSMTP sendmail emulation); Wed, 02 Mar 2016 10:00:43 +0100 From: Pawel Wodkowski To: linux-block@vger.kernel.org Cc: Mateusz Nowak , linux-mmc@vger.kernel.org Subject: [PATCH 1/2] block: Allow to set max_dev_sectors for a queue. Date: Wed, 2 Mar 2016 09:55:01 +0100 Message-Id: <75ce1abfb958565fa484390f514ac7c1b934c465.1456847028.git.pawelx.wodkowski@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 From: Mateusz Nowak max_dev_sectors is the upper limit for supported block size by the block device. Since it is used for limiting up max_hw_sectors value (and, as consequence maximum block size for request), lower level driver may need to set it to non-default value. This patch implements function allowing to do so. Fixes: ca369d51b3e1 ("block/sd: Fix device-imposed transfer length limits") Cc: linux-mmc@vger.kernel.org Signed-off-by: Mateusz Nowak --- block/blk-settings.c | 24 ++++++++++++++++++++++++ include/linux/blkdev.h | 1 + 2 files changed, 25 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index c7bb666aafd1..276920dfacd0 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -253,6 +253,30 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_secto EXPORT_SYMBOL(blk_queue_max_hw_sectors); /** + * blk_queue_max_dev_sectors - set max sectors supported by a device for + * this queue. + * @q: the request queue for the device + * @max_dev_sectors: max device sectors in the usual 512b unit + * + * Description: + * Enables a low level driver to set a device supported upper limit, + * max_dev_sectors, on the size of request. max_dev_sectors is set by + * the device driver based upon the capabilities of the device. + * + * max_dev_sectors is upper limit for max_hw_sectors value, thus + * it should be set before changing the latter value. + **/ +void blk_queue_max_dev_sectors(struct request_queue *q, + unsigned int max_dev_sectors) +{ + struct queue_limits *limits = &q->limits; + + limits->max_dev_sectors = min_t(unsigned int, max_dev_sectors, + BLK_DEF_MAX_SECTORS); +} +EXPORT_SYMBOL(blk_queue_max_dev_sectors); + +/** * blk_queue_chunk_sectors - set size of the chunk for this queue * @q: the request queue for the device * @chunk_sectors: chunk sectors in the usual 512b unit diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 4571ef1a12a9..2752d3afcf1c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -967,6 +967,7 @@ extern void blk_cleanup_queue(struct request_queue *); extern void blk_queue_make_request(struct request_queue *, make_request_fn *); extern void blk_queue_bounce_limit(struct request_queue *, u64); extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int); +extern void blk_queue_max_dev_sectors(struct request_queue *, unsigned int); extern void blk_queue_chunk_sectors(struct request_queue *, unsigned int); extern void blk_queue_max_segments(struct request_queue *, unsigned short); extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);