From patchwork Mon Apr 9 10:04:52 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: 10330947 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 20A646053B for ; Mon, 9 Apr 2018 10:05:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19BB928897 for ; Mon, 9 Apr 2018 10:05:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E27028AE0; Mon, 9 Apr 2018 10:05:34 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, 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 A050628897 for ; Mon, 9 Apr 2018 10:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751794AbeDIKFd (ORCPT ); Mon, 9 Apr 2018 06:05:33 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:43685 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751754AbeDIKFc (ORCPT ); Mon, 9 Apr 2018 06:05:32 -0400 Received: by mail-qk0-f195.google.com with SMTP id v2so8591062qkh.10 for ; Mon, 09 Apr 2018 03:05:32 -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=ArmaVdoA3jIuKRi5wmQfhpcvjzIyNDTdGzAc2Ts/jYyLx+eMEhw/fOkC+IFsez2tnE Dzo4gnphrcIXuBZBsW5NyoOHcuAcbVJgtnWx8zCJUG8FtY08nVMVY8kd98w4Zf4+UL0t AX7Vn5iymYUQDIAwhNeY3lxBLmuGYKSdKRvWE= 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=TDNATIMCXSK7XYQn19ej9IfyigmQwK8DzqrQSzihop+1ssbwatQhY9icfKmTXvSv6+ WeKTvkLz1tXRWlKlMT2izyKeDLCxE9RtaS6t2BQoTRqs3QvriyOI/+Su0dTFx3HtBWkZ oVNzSQWH4UqLbsWlJOxuKniY5awkYDzvZGkrBC3qtBtByiY4dx5aDAxVKdX9DKz72u8N 4kOFI9MnIHXEwXJRYgF2I2Tuu+kgSHKYO9idEjwMwimgj7bePMq6mELselbzY+2GHd0S 9HxruYLlwI5lQeijDQdXyaR27sVUJmGm4ZyDrZ9A3lVickrBm1HNXETMYH3b6topcGyH kFAw== X-Gm-Message-State: ALQs6tAK7/I+BNbexZfMJVF7RptU85ghwHXu+Z8MNKznVdkZnO7vqZbK q9XvYe3Kwy33B9S8jyPsiS3VQWzRjYM= X-Google-Smtp-Source: AIpwx4+1rcjbKjbZ4yp7h07b/GjTsE6lnNUbk5wdjjh0Kk5Lk6YOKcrA7TfpIEkOCKg3ndi+YTU5wg== X-Received: by 10.55.4.132 with SMTP id 126mr48819298qke.277.1523268331515; Mon, 09 Apr 2018 03:05:31 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id l52sm13856884qtc.45.2018.04.09.03.05.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 03:05:31 -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 v2 05/14] mpt3sas: Enhanced handling of Sense Buffer. Date: Mon, 9 Apr 2018 06:04:52 -0400 Message-Id: <1523268301-14453-6-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523268301-14453-1-git-send-email-chaitra.basappa@broadcom.com> References: <1523268301-14453-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,