From patchwork Tue Dec 22 10:11:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 11986233 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.8 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,SPF_HELO_NONE,SPF_PASS, 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 BADEFC433DB for ; Tue, 22 Dec 2020 10:13:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CB8F2310D for ; Tue, 22 Dec 2020 10:13:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726340AbgLVKNt (ORCPT ); Tue, 22 Dec 2020 05:13:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgLVKNt (ORCPT ); Tue, 22 Dec 2020 05:13:49 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E94EC0611CC for ; Tue, 22 Dec 2020 02:12:56 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id iq13so1070316pjb.3 for ; Tue, 22 Dec 2020 02:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oqjCRVRhTd07AAe3AjPYo4TYB8xHyAF97592c2J624E=; b=KqTyzpLlhJBM9F2jFFO7PZGRzYOXCBOr2TzhRp4NsYYYsnLJonT/EsZAeBBqZtN7Az 8holHwexlD3XJF34M/Xjgi7w38tm9HLDxFn1/E5p9rfIgERAxrGLdhO+HlYJMYP6cckW gb3LGUAimhfd3HKhpJcGMq7fStDIsfZjHYjm4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references; bh=oqjCRVRhTd07AAe3AjPYo4TYB8xHyAF97592c2J624E=; b=SM0QoAtARy+sYeGx7M01mu/Yu9IkS6Az9pRUCMc9/yWWYa4QYuzKeXWbunUX2YcHeX iVgiccZIxTJ08ErvfHoDfcG92a7zuyD4Ltpyy6CWx2uMBUicIhXAcHhNFnhctdPGzDMP ebO0sc91mCnykcTa0NKU15vFbjc0k8VCAHS6XevFP6QwiE4hutroEc5Fk6nyCoh0UFk7 0oQJiEmu7c8QYKLdcKqhD7wBbS08NeDES2T57lTqGR89/9ZL9Ykogk6mPi2acoHMyNWC CLP+5uJy3sFfyYy8JrkVywMaq/8u56yzN2/7parWA4lTDOEK9IqHlCTzrOMREMhqwUQV Pwtg== X-Gm-Message-State: AOAM530sVATlXF914/TQaS8iqo3OLilOukOot0PtzhTLbLPdYQDghntG olD7D/aDFI97L22REfxi3X9ro0yl66/X4gDdghW2zHyUtEkqUct+tkic/DZ/goz2luT+qbelTQB 42W93WdVbpWjYsvWyKKybMgZ8hFUf7jpNm9umybMSGc5Oe/zLV6YewnZ0f23FaGaLR0SnKjku3G wcmG221Jd6 MIME-Version: 1.0 X-Google-Smtp-Source: ABdhPJzeWQ0Pj4QVbqX2+inZk+zL7184AkGOwlZmB0CSxFdTgJBvFhAZYczMTh4GSaj4UwlIrE2lnA== X-Received: by 2002:a17:90a:fa8e:: with SMTP id cu14mr21656704pjb.140.1608631975790; Tue, 22 Dec 2020 02:12:55 -0800 (PST) Received: from drv-bst-rhel8.static.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id p16sm19148624pju.47.2020.12.22.02.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 02:12:55 -0800 (PST) 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 12/24] mpi3mr: add bios_param shost template hook Date: Tue, 22 Dec 2020 15:41:44 +0530 Message-Id: <20201222101156.98308-13-kashyap.desai@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20201222101156.98308-1-kashyap.desai@broadcom.com> References: <20201222101156.98308-1-kashyap.desai@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Kashyap Desai Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke --- 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 4d94352a4d48..7e0eacf45d84 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2078,6 +2078,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 @@ -2511,6 +2550,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,