From patchwork Thu Oct 15 13:36:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 11839329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6253914B3 for ; Thu, 15 Oct 2020 13:36:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 397A922256 for ; Thu, 15 Oct 2020 13:36:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="NLZGn6jZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729679AbgJONgz (ORCPT ); Thu, 15 Oct 2020 09:36:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbgJONgz (ORCPT ); Thu, 15 Oct 2020 09:36:55 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DC1EC061755 for ; Thu, 15 Oct 2020 06:36:55 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id j18so2067474pfa.0 for ; Thu, 15 Oct 2020 06:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=cl50QpGoYbGMn7bpXWUhWdSR1TC2DD8TqxxP5tPXMQk=; b=NLZGn6jZU+apcPrI0XzoxQxm0SPOfn5mgYDwdeYLuCDJpnzRc+1WnIOt3FOa/dFb0B aeLurDpcccNbL31WJeab/baG4pa8gjPspCxNmMQo6CPOp9F0kwnVDBHSsg4LmEafHDEq iZwVfOZnUtbGGtxbeQcOa6XVz8D2ulhgBNN5U= 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; bh=cl50QpGoYbGMn7bpXWUhWdSR1TC2DD8TqxxP5tPXMQk=; b=eiUhU6R8CytxvNPSh0OmMzfS5QCtSwti+Ib5KWv+WMbrVvg6GOQARGC6GtVNwTPAKl JHwXfoceXSg3Aa34uMj3oNQSwDyAUMWxDJM9RuAAiIFk6g5PTH4hIYLkxAuImhFyRR9f 87HzKWTp2DUdEXns6TI+MRBMaRuKyLehTAJqBfXg5GxmQjGhBCyBpWwMJCunkwtAAIXg GGxlZ8MLiRWaArVTRbH/D0AW3YfbCghJ5yJOKBgoe0KhMNFz+j64d/Dy3sX4RV8+LlNB Xa5asfBMEDwZ8vIPzv9fh1KuYsugwPJY+fY4XKwStdAQAp8K7aQg9P/vi2q6ZIuqiB07 rr2w== X-Gm-Message-State: AOAM531laLDs0//V9zdeljXJRew6u/bUSJs4V6TIHlcrw7sN6+0veL6S 25ytc36oEXzAg2XZIlFtl72dmA== X-Google-Smtp-Source: ABdhPJxduYnU27dnro37fEx3/UohHCbuq+dTU5c8Obz5ql5sEkz0pEw9LOTZcloAOMt4IuCv48gE+w== X-Received: by 2002:a65:45cb:: with SMTP id m11mr3306913pgr.75.1602769014496; Thu, 15 Oct 2020 06:36:54 -0700 (PDT) Received: from drv-bst-rhel8.static.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id f4sm3474280pgk.19.2020.10.15.06.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 06:36:53 -0700 (PDT) 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 v1 1/3] add io_uring with IOPOLL support in scsi layer Date: Thu, 15 Oct 2020 19:06:33 +0530 Message-Id: <20201015133633.61836-1-kashyap.desai@broadcom.com> X-Mailer: git-send-email 2.18.1 Precedence: bulk List-ID: X-Mailing-List: linux-block@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 --- 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 72b12102f777..5a3c383a2bb3 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1766,6 +1766,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); @@ -1833,6 +1846,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, }; @@ -1861,6 +1875,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) @@ -1893,6 +1908,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 e76bac4d14c5..5844374a85b1 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 701f178b20ae..905ee6b00c55 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 values: 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;