From patchwork Thu Apr 5 15:46:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitra P B X-Patchwork-Id: 10324833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94E33600CB for ; Thu, 5 Apr 2018 15:47:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84EB1292CA for ; Thu, 5 Apr 2018 15:47:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79834292CC; Thu, 5 Apr 2018 15:47:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08665292CA for ; Thu, 5 Apr 2018 15:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751466AbeDEPrZ (ORCPT ); Thu, 5 Apr 2018 11:47:25 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35892 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751461AbeDEPrZ (ORCPT ); Thu, 5 Apr 2018 11:47:25 -0400 Received: by mail-wm0-f65.google.com with SMTP id x82so8474308wmg.1 for ; Thu, 05 Apr 2018 08:47:24 -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=/t8KJkArONOkGIU9MfGHY+k0axodH7zIUN+XYuQthFg=; b=MVtIO/hRGtc6K6lkjvaOLGTfgiAbcPLODLhk4K3LTGydU+VLWARiv78hohrB72fTmq EZAe2HBFoedbGssYn53siQHUUaiuJZXFZ+12wDO0Vqrr4HF7AzGwiE8VCCqbwd3nsco1 UDBlvu+DUo/yV7fRrK5MO57om7pvBmWkECgxI= 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=/t8KJkArONOkGIU9MfGHY+k0axodH7zIUN+XYuQthFg=; b=IEWbk553tz0U13JiQXZ9WJO7RnUzZP2N5dpZt3QRXVAPKM36v5ZslcvQQAi+RQF7r6 BWcxmoQDpDDM5Xu1HxatO0cp0YQq/A+aCXN1qm6MlwM3j8ghoGEQ98Lhb9KoW9V/Tev5 GS+1p+86uns86t/J7oyAPUwi3gzgmCOac/Jlk+wCJIlHG3V25u3g+Oa/mXcdxF+3dG0q bZvku1MKDX91KT1E1uTvSkyVOEVN7Gs+/vzvGzjA5i34NzJ3NcfgWv2zZG1xmBTXeuR0 vswVxH7Z9FQGpGLJ+bVlCpby3sGPpo7XZN8rByRGT9zyeipCbPCMwfdrAwyZImiZsoS6 i4Lg== X-Gm-Message-State: ALQs6tDWdgYnHgOKkZVn8VFyQgt6IXEpWoGtxav86Y8QjRfQzXz6WTCJ biQt6VEe2nLYfN4GGPUv94wDe9ja X-Google-Smtp-Source: AIpwx4/KQiAs2RsBKygA0sW0INxs9heblGX9D7eo3Jhg5TbVMuv/Zees4V/AaLwkNbxCFB4qyHXhFQ== X-Received: by 10.80.140.200 with SMTP id r8mr3358201edr.310.1522943243548; Thu, 05 Apr 2018 08:47:23 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id p91sm4745777edp.65.2018.04.05.08.47.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 08:47:21 -0700 (PDT) From: Chaitra P B To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, Chaitra P B Subject: [PATCH v1 06/15] mpt3sas: Enhanced handling of Sense Buffer. Date: Thu, 5 Apr 2018 11:46:28 -0400 Message-Id: <1522943197-5408-7-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1522943197-5408-1-git-send-email-chaitra.basappa@broadcom.com> References: <1522943197-5408-1-git-send-email-chaitra.basappa@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enhanced DMA allocation for Sense Buffer, if the allocation does not fit within same 4GB.Introduced is_MSB_are_same function to check if allocted buffer within 4GB range or not. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.c | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 701e1e7..bd1beaf 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -4205,6 +4205,31 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc) } /** + * is_MSB_are_same - checks whether all reply queues in a set are + * having same upper 32bits in their base memory address. + * @reply_pool_start_address: Base address of a reply queue set + * @pool_sz: Size of single Reply Descriptor Post Queues pool size + * + * Returns 1 if reply queues in a set have a same upper 32bits + * in their base memory address, + * else 0 + */ + +static int +is_MSB_are_same(long reply_pool_start_address, u32 pool_sz) +{ + long reply_pool_end_address; + + reply_pool_end_address = reply_pool_start_address + pool_sz; + + if (upper_32_bits(reply_pool_start_address) == + upper_32_bits(reply_pool_end_address)) + return 1; + else + return 0; +} + +/** * _base_allocate_memory_pools - allocate start of day memory pools * @ioc: per adapter object * @@ -4664,6 +4689,37 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc) ioc->name); goto out; } + /* sense buffer requires to be in same 4 gb region. + * Below function will check the same. + * In case of failure, new pci pool will be created with updated + * alignment. Older allocation and pool will be destroyed. + * Alignment will be used such a way that next allocation if + * success, will always meet same 4gb region requirement. + * Actual requirement is not alignment, but we need start and end of + * DMA address must have same upper 32 bit address. + */ + if (!is_MSB_are_same((long)ioc->sense, sz)) { + //Release Sense pool & Reallocate + dma_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma); + dma_pool_destroy(ioc->sense_dma_pool); + ioc->sense = NULL; + + ioc->sense_dma_pool = + dma_pool_create("sense pool", &ioc->pdev->dev, sz, + roundup_pow_of_two(sz), 0); + if (!ioc->sense_dma_pool) { + pr_err(MPT3SAS_FMT "sense pool: pci_pool_create failed\n", + ioc->name); + goto out; + } + ioc->sense = dma_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL, + &ioc->sense_dma); + if (!ioc->sense) { + pr_err(MPT3SAS_FMT "sense pool: pci_pool_alloc failed\n", + ioc->name); + goto out; + } + } dinitprintk(ioc, pr_info(MPT3SAS_FMT "sense pool(0x%p): depth(%d), element_size(%d), pool_size" "(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth,