From patchwork Thu Oct 11 16:58:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10637033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48E3C3CF1 for ; Thu, 11 Oct 2018 16:59:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 353D82BC71 for ; Thu, 11 Oct 2018 16:59:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2985E2BC7E; Thu, 11 Oct 2018 16:59:28 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 AE5712BC71 for ; Thu, 11 Oct 2018 16:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730669AbeJLA1c (ORCPT ); Thu, 11 Oct 2018 20:27:32 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:50771 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730301AbeJLA1b (ORCPT ); Thu, 11 Oct 2018 20:27:31 -0400 Received: by mail-it1-f195.google.com with SMTP id k206-v6so8475483ite.0 for ; Thu, 11 Oct 2018 09:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3UZqYzBW0T53XzWisAO7smgwRA/OCGh3+r1d8GuOmJ8=; b=wI2pphvzmD/e3trMqpHD940qU5M167sWNG3lILZAhv75rd74EKXMdtSxfVpkpRm4TB bOO5rM5eLXlqIfdGFhWozUbN3PCgRaWj/hvFBFNklK0MJtwBGzX6OtDYDmu0o90bSD2Z r7EkzKMcljMmlqObRcnN+8dyeO6IVMbZ7KJEsRqXwv9sncgBHNuYydKQERF1LCy85Zft gtjp0ak9Zx7C1R5oHmKK4CjibXroZtpioy+jWKXHcI7yS6hHAm081yBLWs7AlOmn5Kr/ 2xZ1+q/IPg3ULmRU9m6TD7j5uKtgBoRXW7Q9iupZW2riWVAPEio+Uq+hqQd5LJc9eSaK 0r1g== 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; bh=3UZqYzBW0T53XzWisAO7smgwRA/OCGh3+r1d8GuOmJ8=; b=I8euBXdmOx58ODafLftWU1j1nlctiRwvCvH8DRAM4eyB+ixTit5NR3aTpHzBXgg1EB D6LFFlkqLAhVpsHgkMf1j2M8A2V6eyvnh4KpI5CwvpJaw0xFSCkH2iL4GdvTfe9+6fZe VWTp8UMOAN8WV4M9h7yhOWFlgB0we4oI1T00mnq3exB3kGAqjEdP+kP6p30PORoZWU1x tGCqQlU740o0LJE+8M3s/MLFaBGKk77CjC9vM3ewAprqMJ8DRAqXb4as1upVZrU+ujEL ue2CmP97VAIFpfszUGXkD5EEhF/b2oAPmLzUY1bqWIOyxNL0T5MwFUapZz2GXX6NiRV/ CP4g== X-Gm-Message-State: ABuFfoj6T1ewpZ7uTuHU+zYqrWY7Q+dNsuAWddhHj6Jbz9zwj48iHZCX JeKuk8q4bB3XbRKRfujKglutwljABns= X-Google-Smtp-Source: ACcGV60vxB3mNiS4FEepJJ0aqqqMxpFuqlk6WPU/1mD5OlTvJBwzQ/mFpw/FJwZj5q7k24e0//705A== X-Received: by 2002:a02:b5c1:: with SMTP id y1-v6mr1979424jaj.143.1539277165467; Thu, 11 Oct 2018 09:59:25 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id z128-v6sm8366088itc.21.2018.10.11.09.59.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 09:59:24 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 06/17] paride: convert pf to blk-mq Date: Thu, 11 Oct 2018 10:58:58 -0600 Message-Id: <20181011165909.32615-7-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011165909.32615-1-axboe@kernel.dk> References: <20181011165909.32615-1-axboe@kernel.dk> 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 Signed-off-by: Jens Axboe --- drivers/block/paride/pf.c | 68 +++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index eef7a91f667d..58866cf495f8 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -152,7 +152,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_LUN, D_DLY}; #include #include #include -#include +#include #include #include #include @@ -206,7 +206,8 @@ module_param_array(drive3, int, NULL, 0); #define ATAPI_WRITE_10 0x2a static int pf_open(struct block_device *bdev, fmode_t mode); -static void do_pf_request(struct request_queue * q); +static blk_status_t pf_queue_rq(struct blk_mq_hw_ctx *hctx, + const struct blk_mq_queue_data *bd); static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg); static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo); @@ -238,6 +239,8 @@ struct pf_unit { int present; /* device present ? */ char name[PF_NAMELEN]; /* pf0, pf1, ... */ struct gendisk *disk; + struct blk_mq_tag_set tag_set; + struct list_head rq_list; }; static struct pf_unit units[PF_UNITS]; @@ -277,6 +280,10 @@ static const struct block_device_operations pf_fops = { .check_events = pf_check_events, }; +static const struct blk_mq_ops pf_mq_ops = { + .queue_rq = pf_queue_rq, +}; + static void __init pf_init_units(void) { struct pf_unit *pf; @@ -284,14 +291,34 @@ static void __init pf_init_units(void) pf_drive_count = 0; for (unit = 0, pf = units; unit < PF_UNITS; unit++, pf++) { - struct gendisk *disk = alloc_disk(1); + struct blk_mq_tag_set *set; + struct gendisk *disk; + + disk = alloc_disk(1); if (!disk) continue; - disk->queue = blk_init_queue(do_pf_request, &pf_spin_lock); - if (!disk->queue) { + + set = &pf->tag_set; + set->ops = &pf_mq_ops; + set->nr_hw_queues = 1; + set->queue_depth = 1; + set->numa_node = NUMA_NO_NODE; + set->flags = BLK_MQ_F_SHOULD_MERGE; + if (blk_mq_alloc_tag_set(set)) { put_disk(disk); - return; + continue; } + + disk->queue = blk_mq_init_queue(set); + if (IS_ERR(disk->queue)) { + blk_mq_free_tag_set(set); + put_disk(disk); + disk->queue = NULL; + continue; + } + + INIT_LIST_HEAD(&pf->rq_list); + disk->queue->queuedata = pf; blk_queue_max_segments(disk->queue, cluster); blk_queue_bounce_limit(disk->queue, BLK_BOUNCE_HIGH); pf->disk = disk; @@ -784,18 +811,18 @@ static int pf_queue; static int set_next_request(void) { struct pf_unit *pf; - struct request_queue *q; int old_pos = pf_queue; do { pf = &units[pf_queue]; - q = pf->present ? pf->disk->queue : NULL; if (++pf_queue == PF_UNITS) pf_queue = 0; - if (q) { - pf_req = blk_fetch_request(q); - if (pf_req) - break; + if (pf->present && !list_empty(&pf->rq_list)) { + pf_req = list_first_entry(&pf->rq_list, struct request, + queuelist); + list_del_init(&pf_req->queuelist); + blk_mq_start_request(pf_req); + break; } } while (pf_queue != old_pos); @@ -804,8 +831,12 @@ static int set_next_request(void) static void pf_end_request(blk_status_t err) { - if (pf_req && !__blk_end_request_cur(pf_req, err)) + if (!pf_req) + return; + if (!blk_update_request(pf_req, err, blk_rq_cur_bytes(pf_req))) { + __blk_mq_end_request(pf_req, err); pf_req = NULL; + } } static void pf_request(void) @@ -842,9 +873,17 @@ static void pf_request(void) } } -static void do_pf_request(struct request_queue *q) +static blk_status_t pf_queue_rq(struct blk_mq_hw_ctx *hctx, + const struct blk_mq_queue_data *bd) { + struct pf_unit *pf = hctx->queue->queuedata; + + spin_lock_irq(&pf_spin_lock); + list_add_tail(&bd->rq->queuelist, &pf->rq_list); pf_request(); + spin_unlock_irq(&pf_spin_lock); + + return BLK_STS_OK; } static int pf_next_buf(void) @@ -1023,6 +1062,7 @@ static void __exit pf_exit(void) if (!pf->present) continue; del_gendisk(pf->disk); + blk_mq_free_tag_set(&pf->tag_set); blk_cleanup_queue(pf->disk->queue); put_disk(pf->disk); pi_release(pf->pi);