From patchwork Tue Sep 9 08:44:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 37049 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B2CE720566 for ; Tue, 9 Sep 2014 08:47:52 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id ft15sf17135633pdb.9 for ; Tue, 09 Sep 2014 01:47:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=RDeQZCNYR4UayCK6YRUDs2vZnWRP23UPEGCnNxdm6Zw=; b=QK1AzUabCmH3Wrht/ibdM0pToH9tFOQUZw/5py2uKZrDDIKymP3kDd10kgPUWc5NrI OeikHIIT301uTX+r5SrmjuL/5ogByxzC9Y9Qc/eF1d2ygYvUfngNT1PgSl7lbRlzTZBO ysev9x/oefzjm9g8j/aXMeZZfesSBHDogYAOGL5D/HoIJUAzKGCEPwyTxRJZALuwp3j4 H3GmJnYbrxJe21RzAtXbOMAvv/RRkosyPRmbitIqg3uLzqm7R9JnNm47ddKeJTS37lN7 Kep9SD0nrXaeHPQQBMeexBcea0x5r47Ld8h4ZReSSRQpJJXPY32cdM9gKnDn8P3E6b6U bGCw== X-Gm-Message-State: ALoCoQmwhDPv92BVNxtXMv3iMYWCLD8JWHNFZivVMhUxQX3xFG63d75zV10F77aqGgvWbBnLcLQA X-Received: by 10.66.65.75 with SMTP id v11mr20853999pas.30.1410252472037; Tue, 09 Sep 2014 01:47:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.231 with SMTP id g94ls1885577qge.74.gmail; Tue, 09 Sep 2014 01:47:51 -0700 (PDT) X-Received: by 10.221.44.69 with SMTP id uf5mr29765322vcb.4.1410252471882; Tue, 09 Sep 2014 01:47:51 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id nu10si4936300vcb.93.2014.09.09.01.47.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 01:47:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hy10so2962015vcb.17 for ; Tue, 09 Sep 2014 01:47:51 -0700 (PDT) X-Received: by 10.220.172.8 with SMTP id j8mr14123571vcz.32.1410252471785; Tue, 09 Sep 2014 01:47:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp251453vcb; Tue, 9 Sep 2014 01:47:51 -0700 (PDT) X-Received: by 10.68.69.33 with SMTP id b1mr14588164pbu.59.1410252470831; Tue, 09 Sep 2014 01:47:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ng7si22088013pbc.58.2014.09.09.01.47.50 for ; Tue, 09 Sep 2014 01:47:50 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756191AbaIIIrp (ORCPT + 26 others); Tue, 9 Sep 2014 04:47:45 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:65080 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932350AbaIIIpW (ORCPT ); Tue, 9 Sep 2014 04:45:22 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NBM008S9LNKPR30@mailout2.samsung.com>; Tue, 09 Sep 2014 17:45:20 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-1d-540ebe20ebfd Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id A5.BB.04943.02EBE045; Tue, 09 Sep 2014 17:45:20 +0900 (KST) Received: from AMDC2122.DIGITAL.local ([106.120.53.17]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NBM00GHMLN0CSA0@mmp2.samsung.com>; Tue, 09 Sep 2014 17:45:20 +0900 (KST) From: Robert Baldyga To: Paul.Zimmerman@synopsys.com Cc: gregkh@linuxfoundation.org, balbi@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Szyprowski , Robert Baldyga Subject: [PATCH 4/6] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Date: Tue, 09 Sep 2014 10:44:55 +0200 Message-id: <1410252297-13738-5-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1410252297-13738-1-git-send-email-r.baldyga@samsung.com> References: <1410252297-13738-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCLMWRmVeSWpSXmKPExsVy+t9jQV2FfXwhBs1ztC0O3q+3aF68ns3i 8q45bBaLlrUyW6w9cpfd4tHDrawWDw7vZHdg99g/dw27R9+WVYweW/Z/ZvQ4fmM7k8fnTXIB rFFcNimpOZllqUX6dglcGf2nF7IVbBSumNhwhq2B8SJ/FyMnh4SAicTDy60sELaYxIV769m6 GLk4hASmM0p0rtjHCuG0M0msfXKEEaSKTUBHYsv3CWC2iIC8xPWNN1lAipgF9jFKTP+0jR0k ISwQJXFz02RWEJtFQFXi/4M1zCA2r4CrxKp125gg1slJnDwGUcMp4Cbx59gXsF4hoJp/c6ax TGDkXcDIsIpRNLUguaA4KT3XUK84Mbe4NC9dLzk/dxMjOKyeSe1gXNlgcYhRgINRiYc3I5gv RIg1say4MvcQowQHs5II75XdQCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8B1qtA4UE0hNLUrNT UwtSi2CyTBycUg2M0i6ZX09t5Y3xCg/cJrhbmXdR3Sfzck/R1z+0f/RJtS59yqN4pcJ/xvb+ Y83qdd8E967rOfsrqeb/xy/b/CVWhr1X1vT73K5+js9Occ6Zr+vX/+k/kmIzL9vV5+jVQ7qH Tx/6f/trJOua23/K73xTUNhdv9Ax4Y35NNGsNba/fHdKBTt/3/b5iRJLcUaioRZzUXEiAIqP wv8nAgAA Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Marek Szyprowski Print warning if FIFOs are configured in such a way that they don't fit into the SPRAM available on the s3c hsotg module. Signed-off-by: Marek Szyprowski Signed-off-by: Robert Baldyga --- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 1efd10c..067390e 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -194,6 +194,7 @@ struct s3c_hsotg { struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)]; u32 phyif; + int fifo_mem; unsigned int dedicated_fifos:1; unsigned char num_of_eps; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index f63858a..bd58756 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -192,6 +192,8 @@ static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg) for (ep = 1; ep <= 15; ep++) { val = addr; val |= size << FIFOSIZE_DEPTH_SHIFT; + WARN_ONCE(addr + size > hsotg->fifo_mem, + "insufficient fifo memory"); addr += size; writel(val, hsotg->regs + DPTXFSIZN(ep)); @@ -3029,19 +3031,22 @@ static void s3c_hsotg_initep(struct s3c_hsotg *hsotg, */ static void s3c_hsotg_hw_cfg(struct s3c_hsotg *hsotg) { - u32 cfg2, cfg4; + u32 cfg2, cfg3, cfg4; /* check hardware configuration */ cfg2 = readl(hsotg->regs + 0x48); hsotg->num_of_eps = (cfg2 >> 10) & 0xF; - dev_info(hsotg->dev, "EPs:%d\n", hsotg->num_of_eps); + cfg3 = readl(hsotg->regs + 0x4C); + hsotg->fifo_mem = (cfg3 >> 16); cfg4 = readl(hsotg->regs + 0x50); hsotg->dedicated_fifos = (cfg4 >> 25) & 1; - dev_info(hsotg->dev, "%s fifos\n", - hsotg->dedicated_fifos ? "dedicated" : "shared"); + dev_info(hsotg->dev, "EPs: %d, %s fifos, %d entries in SPRAM\n", + hsotg->num_of_eps, + hsotg->dedicated_fifos ? "dedicated" : "shared", + hsotg->fifo_mem); } /** @@ -3485,8 +3490,8 @@ static int s3c_hsotg_probe(struct platform_device *pdev) s3c_hsotg_phy_enable(hsotg); s3c_hsotg_corereset(hsotg); - s3c_hsotg_init(hsotg); s3c_hsotg_hw_cfg(hsotg); + s3c_hsotg_init(hsotg); ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0, dev_name(dev), hsotg);