From patchwork Fri Mar 30 09:37:15 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: 10317463 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 2A36E60212 for ; Fri, 30 Mar 2018 09:39:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17A2F2A55F for ; Fri, 30 Mar 2018 09:39:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C6A92A574; Fri, 30 Mar 2018 09:39:35 +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 702D12A55F for ; Fri, 30 Mar 2018 09:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752219AbeC3JjP (ORCPT ); Fri, 30 Mar 2018 05:39:15 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:43759 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752168AbeC3JjM (ORCPT ); Fri, 30 Mar 2018 05:39:12 -0400 Received: by mail-qk0-f193.google.com with SMTP id v2so8634490qkh.10 for ; Fri, 30 Mar 2018 02:39:12 -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=wRwig/eQ3VGyzvMDZqU7ZsmAcfsu/N606p9WCuDCKGE=; b=GCDwEs6HCQTPOKjhh+e6NV7I7ptJTb7fT5TZGI2L3i1R2LIXXnF7goVRdek2gW3CMc Tfb+Kmo+HwIa3mYGbQobLACBULOjQvLCLFw73sxJPEpy+3HIpRHJv4vw0x1HKL50OpSr QiSuyyJBm7xSv6rHdT2sDmPTvBILmAU+Iz6oM= 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=wRwig/eQ3VGyzvMDZqU7ZsmAcfsu/N606p9WCuDCKGE=; b=k059qOpIs+m/YWABGYu44orhMUS/qxd5DBdkkerRMjf5IvWjULjd9YsF98VdYweu// Fr3zefp/WfaJmW9fWewhsp1UH0yEPq32a07ZCl1t+3ua8K/VNBUJAo6791H+azYqXWYn eWr8Il+bS2pmzM5/00qqjg2M31GmLoaJv83f0fEsDh9tE9BjyeghHsrCKRptLIKvFpWg p6y2H3CZ7fph/UBboToQ6nRPBmxJpshY8RI4OxECSejiJKgMH6LVJfbGOCjal1MIR9PP ELojXg1Vzjo+59sKEqQaZ6m2laQymfxtSPxmYRyU7S//5t5CxxHlukXlxEsV7d7rMfXp uYAw== X-Gm-Message-State: AElRT7FDL/PVtGMFvPd4G/vO5xq+sLz4bDtiG4snrBEntbomHkSPhJNb EPTdEc4MX1S7DTilthZDZRGA6Wf8 X-Google-Smtp-Source: AIpwx480MF6nHF6P/7SX6ARM2LGsCcxWKDNoTqS4WQgkZ69KmRTQ5I6n6KZTJeDY88YzQ3khCObR+g== X-Received: by 10.55.24.1 with SMTP id j1mr16363806qkh.23.1522402751446; Fri, 30 Mar 2018 02:39:11 -0700 (PDT) Received: from dhcp-10-122-86-193.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id n4sm1125526qkf.29.2018.03.30.02.39.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Mar 2018 02:39:10 -0700 (PDT) From: Chaitra P B To: linux-scsi@vger.kernel.org, stable@vger.kernel.org Cc: suganath-prabu.subramani@broadcom.com, Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Chaitra P B Subject: [PATCH 06/15] mpt3sas: Enhanced handling of Sense Buffer. Date: Fri, 30 Mar 2018 15:07:15 +0530 Message-Id: <1522402644-3016-7-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1522402644-3016-1-git-send-email-chaitra.basappa@broadcom.com> References: <1522402644-3016-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 | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 701e1e7..7f3b684 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -4205,6 +4205,32 @@ _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; + unsigned long bit_divisor_16 = 0x10000; + + reply_pool_end_address = reply_pool_start_address + pool_sz; + + if (((reply_pool_start_address / bit_divisor_16) / (bit_divisor_16)) == + ((reply_pool_end_address / bit_divisor_16) / bit_divisor_16)) + return 1; + else + return 0; +} + +/** * _base_allocate_memory_pools - allocate start of day memory pools * @ioc: per adapter object * @@ -4664,6 +4690,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,