From patchwork Tue Aug 1 10:37:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9874125 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 D456D60365 for ; Tue, 1 Aug 2017 10:39:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C665028643 for ; Tue, 1 Aug 2017 10:39:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB2D328684; Tue, 1 Aug 2017 10:39:40 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 B5527286A4 for ; Tue, 1 Aug 2017 10:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751878AbdHAKjM (ORCPT ); Tue, 1 Aug 2017 06:39:12 -0400 Received: from mail-qt0-f172.google.com ([209.85.216.172]:37655 "EHLO mail-qt0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751938AbdHAKjJ (ORCPT ); Tue, 1 Aug 2017 06:39:09 -0400 Received: by mail-qt0-f172.google.com with SMTP id 16so6421407qtz.4 for ; Tue, 01 Aug 2017 03:39:09 -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=6NWbfqSgMxrEDTlRe0Ssfg7o4/TqvGLis3OcyfvfVOg=; b=WdNVOgTUUuNaALo2Koi5wdS0cBFS3m+8hLLQ18XDj8G1g1Dz7hVO9mJK6mfcBZllPy ir2YSZr978HOA69FiH6mgH5kICmcD8p7ztIp+JQk+aBUZInxNICR3eb2Oyc+x8Q0GCvs N7g+a0x6f+2AXhviW8zcgM5ahCZFYLzpPl9zI= 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=6NWbfqSgMxrEDTlRe0Ssfg7o4/TqvGLis3OcyfvfVOg=; b=HGMUVPRexLXEbfODSw/7fP8eSJqAlgWuitmtfWWvckc2RuH3Q5O3YPVYJNEMqM2DGE HipXR1/YqLsVjBOjqne73EjwTZUa0yav7QGfrdjEU8manLDB67INO3ug4H/Z3+9lBS4/ NRmA8XxCoL010Ne5+goySC14QipQFZIZHYftRmFnt++jJhyWdqFUox/GJ+bhLtcnbfY9 Pma/Y17NS0v4Ok6ed2YWxwzsPYVUtOmdFnm31koGMpaF7gkD9mtOUv94e095H7bUy2rT bfcMjmxW/dH7SlufvNTuGpjlAQt38kW9XzNh5DZaTuJw9lD+hkgDji+W/Yoy81XDLEOw avhg== X-Gm-Message-State: AIVw113IKx+aNDHl+0yNhk1pe3T4f60K0eyhMFkQt1RuNCD1rNTj1rn4 J958alla9CYofA3z X-Received: by 10.237.61.123 with SMTP id h56mr25251488qtf.1.1501583948857; Tue, 01 Aug 2017 03:39:08 -0700 (PDT) Received: from anup-HP-Compaq-8100-Elite-CMT-PC.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id e32sm21784162qtb.63.2017.08.01.03.39.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Aug 2017 03:39:08 -0700 (PDT) From: Anup Patel To: Rob Herring , Mark Rutland , Vinod Koul , Dan Williams Cc: Florian Fainelli , Scott Branden , Ray Jui , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dmaengine@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Anup Patel Subject: [PATCH v2 07/16] dmaengine: bcm-sba-raid: Allow arbitrary number free sba_request Date: Tue, 1 Aug 2017 16:07:51 +0530 Message-Id: <1501583880-32072-8-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501583880-32072-1-git-send-email-anup.patel@broadcom.com> References: <1501583880-32072-1-git-send-email-anup.patel@broadcom.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, we cannot have any arbitrary number of free sba_request because sba_prealloc_channel_resources() allocates an array of sba_request using devm_kcalloc() and kcalloc() cannot provide memory beyond certain size. This patch removes "reqs" (sba_request array) from sba_device and makes "cmds" as variable array (instead of pointer) in sba_request. This helps sba_prealloc_channel_resources() to allocate sba_request and associated SBA command in one allocation which in-turn allows arbitrary number of free sba_request. Signed-off-by: Anup Patel --- drivers/dma/bcm-sba-raid.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/dma/bcm-sba-raid.c b/drivers/dma/bcm-sba-raid.c index 59ef443..cd6e3cd 100644 --- a/drivers/dma/bcm-sba-raid.c +++ b/drivers/dma/bcm-sba-raid.c @@ -113,9 +113,10 @@ struct sba_request { struct list_head next; atomic_t next_pending_count; /* BRCM message data */ - struct brcm_sba_command *cmds; struct brcm_message msg; struct dma_async_tx_descriptor tx; + /* SBA commands */ + struct brcm_sba_command cmds[0]; }; enum sba_version { @@ -153,7 +154,6 @@ struct sba_device { void *cmds_base; dma_addr_t cmds_dma_base; spinlock_t reqs_lock; - struct sba_request *reqs; bool reqs_fence; struct list_head reqs_alloc_list; struct list_head reqs_pending_list; @@ -1484,26 +1484,20 @@ static int sba_prealloc_channel_resources(struct sba_device *sba) INIT_LIST_HEAD(&sba->reqs_aborted_list); INIT_LIST_HEAD(&sba->reqs_free_list); - sba->reqs = devm_kcalloc(sba->dev, sba->max_req, - sizeof(*req), GFP_KERNEL); - if (!sba->reqs) { - ret = -ENOMEM; - goto fail_free_cmds_pool; - } - for (i = 0; i < sba->max_req; i++) { - req = &sba->reqs[i]; + req = devm_kzalloc(sba->dev, + sizeof(*req) + + sba->max_cmd_per_req * sizeof(req->cmds[0]), + GFP_KERNEL); + if (!req) { + ret = -ENOMEM; + goto fail_free_cmds_pool; + } INIT_LIST_HEAD(&req->node); req->sba = sba; req->flags = SBA_REQUEST_STATE_FREE; INIT_LIST_HEAD(&req->next); atomic_set(&req->next_pending_count, 0); - req->cmds = devm_kcalloc(sba->dev, sba->max_cmd_per_req, - sizeof(*req->cmds), GFP_KERNEL); - if (!req->cmds) { - ret = -ENOMEM; - goto fail_free_cmds_pool; - } for (j = 0; j < sba->max_cmd_per_req; j++) { req->cmds[j].cmd = 0; req->cmds[j].cmd_dma = sba->cmds_base +