From patchwork Thu Dec 3 03:40:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 337402 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.6 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MIME_HEADER_CTYPE_ONLY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FF9CC83012 for ; Thu, 3 Dec 2020 11:42:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B87B822206 for ; Thu, 3 Dec 2020 11:42:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388801AbgLCLl7 (ORCPT ); Thu, 3 Dec 2020 06:41:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388791AbgLCLl6 (ORCPT ); Thu, 3 Dec 2020 06:41:58 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A5B3C061A4F for ; Thu, 3 Dec 2020 03:41:18 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id n7so1251986pgg.2 for ; Thu, 03 Dec 2020 03:41:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=scIvj42NwgQm4c+uRIJpXHWqMZ0NvMgxsG5ZwR7bDCg=; b=e1FSdFIkR7NaOyjM64aHSu3eSR8B0IJCu4QFBWivAcUHetoOuL7YhVqyq/9Vndt6g9 eBoTcFwnjzkTiEC6kOO2txUbeOQxrUJq4o1i+0S9QK4RFp+HjUZ8HivToF3gDzllRxtK cJPJLj74dzWVEjvQlbjKL0Rkr2VqtOOswURW8= 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=scIvj42NwgQm4c+uRIJpXHWqMZ0NvMgxsG5ZwR7bDCg=; b=b17TZaN/kg3cQHKsq+6kYCtmcdeGABB4D9UKggwjyKWNSOdHnnAyr2vNs1TZMlvfPi N733X0kUY6YVKAD9u7aAQASHlJ2zWrFwOXdiWHyQCxk3tvd76XR/Ek6/ITlnJeaary5X wW+2lZfF11sWGp7RsYUe32YRqW6w3iGkEAdCceAg9ZW7hlWeq0g3k3ciDFCGYT0r0uSL w6N2strJ54AVMAIyrCzEf4+XNbOn2tkA6YTCs3WPF5s8cjy/EEAwuBYMXIhOkCv0I71T vNAn0pMf7bVt9QdbGVYzYpdJt1CzpBAP1ZN45oQsjnKUMfWIPAoqGYiAlTn9ikmCkaiN m+QQ== X-Gm-Message-State: AOAM5319vvR4LRAMvy5PebYPoXiHFStPoMFYv2FWznuCU+OrLQoJGf+a tenFerBxbkmibETJWN1324Z3dDRYr+OFSP4/c9GrWYNt2M8oUsucfLAa3aufPrUVw2KBYz9kVwO xmPFe74Kyu39e2AKOnygEHGzgX/J2RC0Z2UYlVo7UYY4TfakErNP+6R27GF9paJL32QYoBboXmQ kymtoQuClH X-Google-Smtp-Source: ABdhPJxF6AJF13Bp3NAQaiR46atYPorGKD53i6oOCH0tbh//auBE7VzbAt1eeo/GJ18dClkUdasXxw== X-Received: by 2002:a63:e5a:: with SMTP id 26mr2674257pgo.450.1606995677308; Thu, 03 Dec 2020 03:41:17 -0800 (PST) Received: from drv-bst-rhel8.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id cl23sm1310331pjb.23.2020.12.03.03.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 03:41:16 -0800 (PST) From: Kashyap Desai To: linux-scsi@vger.kernel.org Cc: Kashyap Desai , sumit.saxena@broadcom.com, chandrakanth.patil@broadcom.com, linux-block@vger.kernel.org Subject: [PATCH v2 1/4] add io_uring with IOPOLL support in scsi layer Date: Thu, 3 Dec 2020 09:10:57 +0530 Message-Id: <20201203034100.29716-2-kashyap.desai@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20201203034100.29716-1-kashyap.desai@broadcom.com> References: <20201203034100.29716-1-kashyap.desai@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org io_uring with IOPOLL is not currently supported in scsi mid layer. Outside of that everything else should work and no extra support in the driver is needed. Currently io_uring with IOPOLL support is only available in block layer. This patch is to extend support of mq_poll in scsi layer. Signed-off-by: Kashyap Desai Cc: sumit.saxena@broadcom.com Cc: chandrakanth.patil@broadcom.com Cc: linux-block@vger.kernel.org Reviewed-by: Hannes Reinecke Reviewed-by: John Garry --- drivers/scsi/scsi_lib.c | 16 ++++++++++++++++ include/scsi/scsi_cmnd.h | 1 + include/scsi/scsi_host.h | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index b7ac14571415..8675900ccc27 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1786,6 +1786,19 @@ static void scsi_mq_exit_request(struct blk_mq_tag_set *set, struct request *rq, cmd->sense_buffer); } + +static int scsi_mq_poll(struct blk_mq_hw_ctx *hctx) +{ + struct request_queue *q = hctx->queue; + struct scsi_device *sdev = q->queuedata; + struct Scsi_Host *shost = sdev->host; + + if (shost->hostt->mq_poll) + return shost->hostt->mq_poll(shost, hctx->queue_num); + + return 0; +} + static int scsi_map_queues(struct blk_mq_tag_set *set) { struct Scsi_Host *shost = container_of(set, struct Scsi_Host, tag_set); @@ -1853,6 +1866,7 @@ static const struct blk_mq_ops scsi_mq_ops_no_commit = { .cleanup_rq = scsi_cleanup_rq, .busy = scsi_mq_lld_busy, .map_queues = scsi_map_queues, + .poll = scsi_mq_poll, }; @@ -1881,6 +1895,7 @@ static const struct blk_mq_ops scsi_mq_ops = { .cleanup_rq = scsi_cleanup_rq, .busy = scsi_mq_lld_busy, .map_queues = scsi_map_queues, + .poll = scsi_mq_poll, }; struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev) @@ -1913,6 +1928,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) else tag_set->ops = &scsi_mq_ops_no_commit; tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1; + tag_set->nr_maps = shost->nr_maps ? : 1; tag_set->queue_depth = shost->can_queue; tag_set->cmd_size = cmd_size; tag_set->numa_node = NUMA_NO_NODE; diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 69ade4fb71aa..3f5b5b7a556f 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -10,6 +10,7 @@ #include #include #include +#include #include struct Scsi_Host; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 701f178b20ae..a0cda0f66b84 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -270,6 +270,16 @@ struct scsi_host_template { */ int (* map_queues)(struct Scsi_Host *shost); + /* + * SCSI interface of blk_poll - poll for IO completions. + * Possible interface only if scsi LLD expose multiple h/w queues. + * + * Return value: Number of completed entries found. + * + * Status: OPTIONAL + */ + int (* mq_poll)(struct Scsi_Host *shost, unsigned int queue_num); + /* * Check if scatterlists need to be padded for DMA draining. * @@ -610,6 +620,7 @@ struct Scsi_Host { * the total queue depth is can_queue. */ unsigned nr_hw_queues; + unsigned nr_maps; unsigned active_mode:2; unsigned unchecked_isa_dma:1;