From patchwork Mon Apr 19 11:01:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 424268 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,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 376B9C43460 for ; Mon, 19 Apr 2021 11:02:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1831561166 for ; Mon, 19 Apr 2021 11:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238567AbhDSLDL (ORCPT ); Mon, 19 Apr 2021 07:03:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236023AbhDSLDE (ORCPT ); Mon, 19 Apr 2021 07:03:04 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9728BC061763 for ; Mon, 19 Apr 2021 04:02:34 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id u14-20020a17090a1f0eb029014e38011b09so13468392pja.5 for ; Mon, 19 Apr 2021 04:02:34 -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=otQGSiJTgqOIwJDV3S/vbuvzsw6eMhrSb2Rgp7NrsgA=; b=K/Aa6PDu9R9spKpn+fOfwuEm6jQmGQOG26NIkmaiXIE/maeUhiMzNtRnZVM+BAjM76 2age8zP08qIPYabBZMXtD3x7aMs88+nXl8Wh6K5X1CJsP/G1iWxDqsgi/sao87LHVyZ6 NCM16tdDl290mdzsOvoZ0z2qCxHF52t1YM0XE= 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=otQGSiJTgqOIwJDV3S/vbuvzsw6eMhrSb2Rgp7NrsgA=; b=ihOd29pmR2/2JjxI7ZxrECKQnGcbHksAmQX/zg9U9mtJcJR/aHVQLeAHSbFLjLO1di uuIpUlP7oJzvC2QmqSNG/21Y5MIbKrsTuiV1IG6hcNLKTiTLtwVku8+bJndTcDnXqwHO SvGfvTDKBq1QBF9ra1dyW79IPPXlouxYvA2OTlLwKf5SDDkNjms+XBYhOhM+oyHNhEu1 5fnyRuvPrFx0aRC9oPdbxKiObaMPanRWcAAVUWa6UQWRwouenAc8z61k+uhZA8IGsH9C zoFM/3pLqCONm/2BrP6xaZNL8QJejKFjZkcZCdq/mhIZOFu9sMH+Uhsn3MhGg/VtsSu0 lKHw== X-Gm-Message-State: AOAM531aG38quU22hi14afa5XzYsXWzEveQYv+NrksoxySeGjRM5pqqf HhHYd07F37vnFPPHtpMgfT7lnXPnjUeFLeFRBCXwgFeu0SDcb/qhhTOzRhyOjFqOYSdMwHI1V9d I4k3bbFbaj1c/wBV4iQTVQ1o7CNbASTFhJzXFFPV8LikQBXIMr3o2kNOqhaEDkUxNUOWXMuCdhR 8AcY9lqv/W X-Google-Smtp-Source: ABdhPJzWn79JTRLJuUhXr02UmfwG/xMijOe552euzO7Ur4Oh/BEAvtkD6stFftXQTOM/xAWHl1joMw== X-Received: by 2002:a17:90a:e00f:: with SMTP id u15mr4806976pjy.26.1618830153809; Mon, 19 Apr 2021 04:02:33 -0700 (PDT) Received: from drv-bst-rhel8.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k13sm11825736pfc.50.2021.04.19.04.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 04:02:33 -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 v3 12/24] mpi3mr: add bios_param shost template hook Date: Mon, 19 Apr 2021 16:31:44 +0530 Message-Id: <20210419110156.1786882-13-kashyap.desai@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210419110156.1786882-1-kashyap.desai@broadcom.com> References: <20210419110156.1786882-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 Cc: sathya.prakash@broadcom.com Reviewed-by: Himanshu Madhani --- drivers/scsi/mpi3mr/mpi3mr_os.c | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 39928e2997ba..946a62610b55 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2075,6 +2075,45 @@ static int mpi3mr_build_sg_scmd(struct mpi3mr_ioc *mrioc, return ret; } +/** + * mpi3mr_bios_param - BIOS param callback + * @sdev: SCSI device reference + * @bdev: Block device reference + * @capacity: Capacity in logical sectors + * @params: Parameter array + * + * Just the parameters with heads/secots/cylinders. + * + * Return: 0 always + */ +static int mpi3mr_bios_param(struct scsi_device *sdev, + struct block_device *bdev, sector_t capacity, int params[]) +{ + int heads; + int sectors; + sector_t cylinders; + ulong dummy; + + heads = 64; + sectors = 32; + + dummy = heads * sectors; + cylinders = capacity; + sector_div(cylinders, dummy); + + if ((ulong)capacity >= 0x200000) { + heads = 255; + sectors = 63; + dummy = heads * sectors; + cylinders = capacity; + sector_div(cylinders, dummy); + } + + params[0] = heads; + params[1] = sectors; + params[2] = cylinders; + return 0; +} /** * mpi3mr_map_queues - Map queues callback handler @@ -2508,6 +2547,7 @@ static struct scsi_host_template mpi3mr_driver_template = { .slave_destroy = mpi3mr_slave_destroy, .scan_finished = mpi3mr_scan_finished, .scan_start = mpi3mr_scan_start, + .bios_param = mpi3mr_bios_param, .map_queues = mpi3mr_map_queues, .no_write_same = 1, .can_queue = 1,