From patchwork Thu May 20 15:25:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 443723 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=-19.0 required=3.0 tests=BAYES_00,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, 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 19307C433ED for ; Thu, 20 May 2021 15:22:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0CF86124C for ; Thu, 20 May 2021 15:22:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232274AbhETPYE (ORCPT ); Thu, 20 May 2021 11:24:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243906AbhETPX1 (ORCPT ); Thu, 20 May 2021 11:23:27 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C58FC061346 for ; Thu, 20 May 2021 08:22:04 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id c17so12608716pfn.6 for ; Thu, 20 May 2021 08:22:04 -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:in-reply-to:references; bh=sdYGM5hrjSWS63U+WC3gpLxoOlb69b7k01F/WMAyDX8=; b=UO247fRwwlOF0BQGSEfyOc4GF7Ss7Pi+XLEPlllDVqXQ6PgBMnbdhW3/y0Rdbkx/CH 0vzhVvek4VqbwtYddx8GenAAu/xoLGxVjfvbF7gsbeMpmjvKVfS1adRyMkfMM3Wn+/NM MNoA04qTbtmE1dikGiY8lgzGooHl+t0xOpyF8= 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=sdYGM5hrjSWS63U+WC3gpLxoOlb69b7k01F/WMAyDX8=; b=MX4kTCnK3xQG5Hz727xbW1qKBy7MRqEc/0/7WO2W3FjTmPv4nN/i79sE6C5M5Efnx3 raW9/N1F2CnE9fTkni/KRwK77T9GfKb1GVQfZTc6WwxhfU6Ai4tXMmVwsTKrrT5Y5DDS IWUEegVMLUQhTTzAxOcdc1JpbCOKGuVNzncc7wBcDNIkzgKii0Y+37gojYh+hWIEUU8S qxcXbAVsu58nDb7vFC4cV/ofTvHbPNddOsBLYlR+C4I0qyCkvNs/JYsUe0GlDi7Qtt55 N8EDxU+8L0RF/DgbCSQM+SSgOWYbGzoba9PXBJDHW/uBMdUkMPRaNXGac0mCK4jpSC04 XGWg== X-Gm-Message-State: AOAM530f7KdI83VYwRjxFBx4pEDE6F0IgNxNOx1X8P+9BAz+jipQ+V5g 8domQEFrDT+nun/Qj33H9+genwCm6+7RQpbFLv1CpNmh73YsyIWzLvfgg0ByHlry9Eoz+F0AF/8 SRrkx1zCSf4QUDm0SaFU7jn5TzCroY8bBlZ77s6JDABIFgWCtF1nTKrNa/VmR23ttX84rJSBWEQ mohnbY5g== X-Google-Smtp-Source: ABdhPJwqDq6ItHTOzsZ/+/yXtcYxkyz/+emYOOkvl/i2FLNyzf2dDJeowHaYWYEss6KlShIEDwLjPw== X-Received: by 2002:a63:cf55:: with SMTP id b21mr5236478pgj.126.1621524123273; Thu, 20 May 2021 08:22:03 -0700 (PDT) Received: from drv-bst-rhel8.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s8sm2250557pfe.112.2021.05.20.08.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 08:22:02 -0700 (PDT) From: Kashyap Desai To: linux-scsi@vger.kernel.org Cc: jejb@linux.ibm.com, martin.petersen@oracle.com, steve.hagan@broadcom.com, peter.rivera@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, Kashyap Desai , sathya.prakash@broadcom.com Subject: [PATCH v6 14/24] mpi3mr: add change queue depth support Date: Thu, 20 May 2021 20:55:35 +0530 Message-Id: <20210520152545.2710479-15-kashyap.desai@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210520152545.2710479-1-kashyap.desai@broadcom.com> References: <20210520152545.2710479-1-kashyap.desai@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Kashyap Desai Reviewed-by: Hannes Reinecke Reviewed-by: Tomas Henzl Reviewed-by: Himanshu Madhani Cc: sathya.prakash@broadcom.com --- drivers/scsi/mpi3mr/mpi3mr.h | 3 +++ drivers/scsi/mpi3mr/mpi3mr_os.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 65886f3..cecd779 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -146,6 +146,9 @@ extern struct list_head mrioc_list; /* Command retry count definitions */ #define MPI3MR_DEV_RMHS_RETRY_COUNT 3 +/* Default target device queue depth */ +#define MPI3MR_DEFAULT_SDEV_QD 32 + /* SGE Flag definition */ #define MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST \ (MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE | MPI3_SGE_FLAGS_DLAS_SYSTEM | \ diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index f3cc383..0a0e42d 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -643,6 +643,33 @@ out: return retval; } +/** + * mpi3mr_change_queue_depth- Change QD callback handler + * @sdev: SCSI device reference + * @q_depth: Queue depth + * + * Validate and limit QD and call scsi_change_queue_depth. + * + * Return: return value of scsi_change_queue_depth + */ +static int mpi3mr_change_queue_depth(struct scsi_device *sdev, + int q_depth) +{ + struct scsi_target *starget = scsi_target(sdev); + struct Scsi_Host *shost = dev_to_shost(&starget->dev); + int retval = 0; + + if (!sdev->tagged_supported) + q_depth = 1; + if (q_depth > shost->can_queue) + q_depth = shost->can_queue; + else if (!q_depth) + q_depth = MPI3MR_DEFAULT_SDEV_QD; + retval = scsi_change_queue_depth(sdev, q_depth); + + return retval; +} + /** * mpi3mr_update_sdev - Update SCSI device information * @sdev: SCSI device reference @@ -663,6 +690,7 @@ mpi3mr_update_sdev(struct scsi_device *sdev, void *data) if (!tgtdev) return; + mpi3mr_change_queue_depth(sdev, tgtdev->q_depth); switch (tgtdev->dev_type) { case MPI3_DEVICE_DEVFORM_PCIE: /*The block layer hw sector size = 512*/ @@ -2623,6 +2651,7 @@ static int mpi3mr_slave_configure(struct scsi_device *sdev) if (!tgt_dev) return -ENXIO; + mpi3mr_change_queue_depth(sdev, tgt_dev->q_depth); switch (tgt_dev->dev_type) { case MPI3_DEVICE_DEVFORM_PCIE: /*The block layer hw sector size = 512*/ @@ -2876,6 +2905,7 @@ static struct scsi_host_template mpi3mr_driver_template = { .slave_destroy = mpi3mr_slave_destroy, .scan_finished = mpi3mr_scan_finished, .scan_start = mpi3mr_scan_start, + .change_queue_depth = mpi3mr_change_queue_depth, .eh_device_reset_handler = mpi3mr_eh_dev_reset, .eh_target_reset_handler = mpi3mr_eh_target_reset, .eh_host_reset_handler = mpi3mr_eh_host_reset,