From patchwork Tue Aug 22 09:56:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9914737 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 B4AFB60381 for ; Tue, 22 Aug 2017 10:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C23A22883F for ; Tue, 22 Aug 2017 10:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B595828854; Tue, 22 Aug 2017 10:00:59 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW 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 52EA12883F for ; Tue, 22 Aug 2017 10:00:59 +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=tKZJgEdER+DxaqUwRj1tYGpYwM PnsBC5EZDC2gKDrkBHvreYaNdP1VYMmocd+N9YHTnpEcN2pVmAur7/OM8HMcvFOaUe8dbGC5iyvZG nP2I5QoL/G044mq0ExHljc1w3h6saEjKaHZwgJIwZLgflMUORLG2TP6qmQ3qL5S/YDSgkJsBf89kF 4PxWOXMaGjOK9P4h7cY1xVF1iW31bbjZkPddbKyNNWTj5YOw43GbfnZSDX2sJS1tPX+X2+oU0aH0l CWRB/wBzgDjt4YqZT11bmQTxaBF3eya07+EcbpEIXwQdrKCvCAwF4UhjOgcqf0yUDxQNZUqmUmI6i fNZxckew==; 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 1dk5zU-0001Lx-8C; Tue, 22 Aug 2017 10:00:56 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dk5xE-0006rC-NB for linux-arm-kernel@bombadil.infradead.org; Tue, 22 Aug 2017 09:58:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6NWbfqSgMxrEDTlRe0Ssfg7o4/TqvGLis3OcyfvfVOg=; b=tIAkM64oUn6dLLU3UzIlfKCAC fQjuEgSN4DAe0njeywI73hZqZo5sP62JPbUmetj2rDY8E4S7HdmYZLFUcTGOK+b3Y6KcXoJv2A7Y3 izF+fsKQ3z+4qt5+1XyRx9SGo7ixl0BZzM7NksuWYddkjmtF/fejyiB/avwDviGeGpAtXH9jpt+B2 iPBlb+/l3lVCg5lp8jzrFHggk+mIp6ly4NGamR/Y/nOAAfkBtSdXm48n71TznFNVCJwnZh3+dPxuW xTGYnDE8DeYigtJ/tlNVkG2eKk5RwaBgCEH9pkhpGSGNqh8W68i+ihtaCQovQQHUVBC8DXVAVa2cl oIvokarcw==; Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dk5xB-0001pA-Es for linux-arm-kernel@lists.infradead.org; Tue, 22 Aug 2017 09:58:35 +0000 Received: by mail-wr0-x232.google.com with SMTP id k46so45880360wre.2 for ; Tue, 22 Aug 2017 02:58:13 -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=IRcJsF0M7ZdcKTm/QC1WFhAamd0KbaPX3Bzz79Fl5oUZsYP/f/WLdDWdrXd+gW9BYA OSWmW+lAQt5HVlmh5nqz5hB6rkkQkDUqTtliuL/RPKckOmOnM1l0xAmu8A2WCrKCgaOZ 3n56Mtc/gA52AQQBoA4HTgA0mV3g8EiFDO4Qs= 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=uW9+1OipdOWI+tzo6A2BvHSQXhSHFiVaQJ0+79daBeWlcdgX4QMkvYgmFE2+p553g7 hgKPXZx/rGFahWILzOXexVjQQaNr2RSqQq9uC/JVXNPf4s98sn4aBKLAr5s41FRG58E+ C3ve6hF0/dpNEbWLkT087e2oMzgIKu1xsjCSsJpGs5VjAm+JWaJ7sCJAe7ATaOJCkoEs rsen6cZ9+/Rt/FAvwsUATlUtsECaxy3b6qqN4hKmPqGJlvJegAnQz1pqB+3xvwqU0HSE zIiq2Yen/FLJn83blqcNO9+MSsOtEux6DVcWaB/1nMuRrlboCqfEUeODNcpe1Hft4v+a +QEw== X-Gm-Message-State: AHYfb5gw8kjp/2HF29504dqUlnXkuIBpLitYyrHrjqBVDMcBIIBaJQsj FTudrqndywsidMfB X-Received: by 10.223.142.130 with SMTP id q2mr86136wrb.13.1503395891903; Tue, 22 Aug 2017 02:58:11 -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 e137sm12257913wma.29.2017.08.22.02.58.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Aug 2017 02:58:11 -0700 (PDT) From: Anup Patel To: Vinod Koul , Dan Williams Subject: [PATCH v3 07/17] dmaengine: bcm-sba-raid: Allow arbitrary number free sba_request Date: Tue, 22 Aug 2017 15:26:56 +0530 Message-Id: <1503395827-19428-8-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503395827-19428-1-git-send-email-anup.patel@broadcom.com> References: <1503395827-19428-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170822_105833_540543_1CE5F43C X-CRM114-Status: GOOD ( 15.83 ) 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: 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 +