From patchwork Wed Jan 27 03:55:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 373028 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=-17.4 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 1B56EC433E9 for ; Wed, 27 Jan 2021 12:00:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C616B2078D for ; Wed, 27 Jan 2021 12:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237330AbhA0MAE (ORCPT ); Wed, 27 Jan 2021 07:00:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237449AbhA0L5Z (ORCPT ); Wed, 27 Jan 2021 06:57:25 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68883C06178B for ; Wed, 27 Jan 2021 03:55:16 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id w18so1029666pfu.9 for ; Wed, 27 Jan 2021 03:55:16 -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=xv9BXLaPLpWaMpfdyiy4gLOkFcTkt4HNTVzoz25nlcI=; b=Qfy0+1bbDbeu3l9meBaavrWz04D/cd5y9nxWzY09c1wo+nhl+4GWTibYqkwn1k9v/0 /R6dL8ExZBjyW7RN8wgkyZSV8QB1C5GQDhibWZrgP56f6jOAVNrXIVt8/pThInvLUGIh eSMBRBeENR3XB0ULiYhEMDVV4YCk4uS75RsP0= 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=xv9BXLaPLpWaMpfdyiy4gLOkFcTkt4HNTVzoz25nlcI=; b=LjW9h84SIKGylC+csMsZ8Q+4scEpjN2r5im6GvXlbY9wHVaHHDFr87z/LRSPHwctxG m6xQ2tFM84VUdIyvJ/KD2hqHJveRFYMdhYqILFCvUKi9eSAcJHLsdJYHKI0QRTSJg7qS DsStRHGJqfBWkXkg3kT25j5bpPC2C7AyWtgUYUBhGTsRb7PeQVNL7l1PuMo4HMTeSZl2 32IiwAIFG/sc5wAXgMRRRhwitpy6i2ipZMqxQ5klPYDZeFviE4BD2kn9RvA3fVRJtixV zgON62jy7OXIWxYkyp5dAX2/S+nv4hvkaBpUu7xv4FmBm/e8zPcVmgcyy+/H2uEkkQrc XvdQ== X-Gm-Message-State: AOAM532MjQ6VB9eGCTvuS6aDhJxx+nRtKKzdPKvgHR54/6QUMrHUD/kn ERpVjKYJTEPWl9XioQXlnzCXUGIrhseFKQU05afylicbKsCk5qIhMjAna91DHwQk4025xOPWYhy VouX+R0tsUFW/dGhDcC50DQbdzDTz5/rJsCEVuQyeHrnpMDwrYmvX9RWLK9mbhTIPoFnYhc9wsX jDiX1rRRuv X-Google-Smtp-Source: ABdhPJyU4eY5EzW6HJLHaujFROu2/XmiYp1kXce9b/dJnIoVPLDlRp6lu2SKM4p8+UKdhCvoXgaGqg== X-Received: by 2002:a62:1b15:0:b029:1b9:1c1:1673 with SMTP id b21-20020a621b150000b02901b901c11673mr10516920pfb.2.1611748515482; Wed, 27 Jan 2021 03:55:15 -0800 (PST) Received: from drv-bst-rhel8.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id l190sm2235552pfl.205.2021.01.27.03.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jan 2021 03:55:14 -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: [RESEND PATCH v2 1/4] add io_uring with IOPOLL support in scsi layer Date: Wed, 27 Jan 2021 09:25:24 +0530 Message-Id: <20210127035527.40622-2-kashyap.desai@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210127035527.40622-1-kashyap.desai@broadcom.com> References: <20210127035527.40622-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 --- 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 d0ae586565f8..8c29bf0e4cfd 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1789,6 +1789,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); @@ -1856,6 +1869,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, }; @@ -1884,6 +1898,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) @@ -1916,6 +1931,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 ace15b5dc956..1d8a0f6ea8c5 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 e30fd963b97d..3d627bf7b951 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. * @@ -616,6 +626,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;