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: 9874147 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 104AB60365 for ; Tue, 1 Aug 2017 10:40:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F2EB2868B for ; Tue, 1 Aug 2017 10:40:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03B7A28695; Tue, 1 Aug 2017 10:40:42 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 22B26286A0 for ; Tue, 1 Aug 2017 10:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0AgVt3BNKXaOFtnC8U+8lPBJlUQgtlZPKKkvL7/AV1w=; b=X1QgJURESVKAw1QIYvkP31LLjJ IJvurSYemPDq3o+2P9mFQejDR7TC3+e6f/FQZjEqZ2iBJnUVLCUFstY0lcDMvPEtaVb1lXRwuiW50 1suV38qn2v+rs6qmYomoO6fjAdITFTbDKyEOCSVSeNoMX++5G0ROkL30wmSqcujDQZAZINhZYkg0z +wLGfQbRzy0pHSndqv4gEquNez5IsWkdu3cAEO1+JCYq/TzUCnlPMPp/w5FxY0dpNH3DWDtzsaq02 wqsCwjxHtMA0DSvGxxVlb85jFEtLZaBb8HmWA13ASVfNSe18ZpfmyhU0WSBFRgfs9mXkh+6qG5YA9 UfJfZivw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dcUbA-0004mG-79; Tue, 01 Aug 2017 10:40:24 +0000 Received: from mail-qt0-x229.google.com ([2607:f8b0:400d:c0d::229]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dcUaI-0003mg-8r for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2017 10:39:45 +0000 Received: by mail-qt0-x229.google.com with SMTP id v29so6437734qtv.3 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=crOBNvQoiw/QXXJDkOigb75sxp7qNnLlAd5mGKjlmiz+rbRyFza20uwTcWmrmtCA1J Pdu2OyMwN2s+vEnscktDRNxtZAL3FkAk2o4cYF0cg7GQT+uJMDXBLH9IDyo4Iyuw9MPQ kdTVckUTeNrtWPFzozeqKEl2v9NYrAMGyJrHHOL3e2EuZg27iyIS8chdGhl/W7MN5p6k ZopHhK+N9z5Gz9WaN3alF/00dpkdxKR5X/zYpCZS2YdfGm900wFj4Yok1fEVc2I2yrd1 jT+yUTblYUnQ99zcWlZ37uzUv4TUdvKAel2BieexAG+MLZ6oJuL3emXHwv1L8ngpj5hb rIXA== X-Gm-Message-State: AIVw110UIkECIMXBrSt+2RT9nNAfjDJKZLD9EMAuiqsiDzFqiP7AtGkJ BTIwbdsvi8OfKiJe 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170801_033930_884854_CE97ED12 X-CRM114-Status: GOOD ( 14.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Florian Fainelli , Anup Patel , Scott Branden , Ray Jui , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 +