From patchwork Thu May 20 15:25:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 443724 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 B4D0AC433ED for ; Thu, 20 May 2021 15:22:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AC6261363 for ; Thu, 20 May 2021 15:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232206AbhETPXt (ORCPT ); Thu, 20 May 2021 11:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243776AbhETPXT (ORCPT ); Thu, 20 May 2021 11:23:19 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECEDBC06138B for ; Thu, 20 May 2021 08:21:57 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id k5so9310491pjj.1 for ; Thu, 20 May 2021 08:21:57 -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=NEwHRc5XgoFCULXSc3H/LUNf8NkNLjpvjIhBnL32f8g=; b=V88pXy1KcfhatwciowM3687pFo2i2tgUegT13WwOe0TU8oabhz5x/hi3LKiGtM/1cj qIWlGs0fb7DRLlNuG7CiReBvp5Cy6YhN2zE8IlhrzmOzu8TA9abVafqD0ZeJOKhsMPSj ZY5JhSQ/5o1KmEawOX/YxCGA4oHwuLGfrjGwU= 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=NEwHRc5XgoFCULXSc3H/LUNf8NkNLjpvjIhBnL32f8g=; b=k1vTLjvmAbqtt0MLK+EADTCEymDiVXfoAWgpovQRfiiBTRbPi2Ygnmt3eDLlb6Dr3x RJgpEd4MwWhZc9ZMVVwwdtulH7jdnbCS2/8pmXDL+6Kq7Q8eQ3uhWndI1ojpuhaF4CvL PgXROoiCEVMu9DT0JTAfKI907WumhB33jglzVVVIt+RzqPwdaZID9ZfMu7vhWxbw8/OM 39A+lz4mnH2lliYvAV+YokVPDfCdgEYWLckTBdZU96mExKTLWh6reZ1Kj1+HGVXP46LE Xx1uACaIv9B+/1az5btwsSCHzo1hXpVyrnrWcb9ELnSnXJIKjqCSG71wHZDvaWH2sxX3 +5/Q== X-Gm-Message-State: AOAM531s9GC7BTua1s7TSN61xcqCWFBrnXTyG4QKB36fhkC1TgypBuvO FyBvP/6rk4V/9kubzV4Dp0ziJpksnxeaQGy2NGQ0R0cpMSvjtc5nCYu4Y3lBmwbqb83JGAVshjp R5HNHCKjw8kOEncTtvqrzAc80jGoYeEY8Q4B56PAmXxDzd5XFAwdYXlbWyVE61HJ6VIxh9KRna3 +gI3pKSA== X-Google-Smtp-Source: ABdhPJy7Xobj9MdZDkNiqGPTfLm3HUOBX1FQ3ucxOpxqET4AHjNtO9pFT6tyOS9PWWA2wfOVkt1R1g== X-Received: by 2002:a17:902:d503:b029:f2:c88c:6349 with SMTP id b3-20020a170902d503b02900f2c88c6349mr6578813plg.84.1621524117035; Thu, 20 May 2021 08:21:57 -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.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 08:21:56 -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 12/24] mpi3mr: add bios_param shost template hook Date: Thu, 20 May 2021 20:55:33 +0530 Message-Id: <20210520152545.2710479-13-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_os.c | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 21e2ac4..8d895e4 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2050,6 +2050,46 @@ 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 * @shost: SCSI host reference @@ -2493,6 +2533,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,