From patchwork Tue Aug 19 08:54:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 35577 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EF4422136C for ; Tue, 19 Aug 2014 09:01:18 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf28415219iga.6 for ; Tue, 19 Aug 2014 02:01:18 -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=q81SawFrI3+90Qnn/fMJjZ5ieQnDnI8UwGG2dDkhmCA=; b=Op/JF/cE2jiRqcdIHRROdyCrNyp/+leyruycEApuQIEtoSpUQUQEquupnBk3xWzipy fuVrCi05QWWJlpniHsvxr2ShDeYQz9ywd8Njdgg8ujub/9nZCHkRzwaP3HBec4iDAkiC S8lWVpTidHtPZ3Ic9wUxfyuiOzuTL1+mY82OgU5FfFHqmg6WRehycjOefnPSvbf3FmE/ 2dwXusrOkJmtPt4aV7c1QiTB4QUZvWBqdTSDWVzerV/AF/lHeMXWIMglBQnHp31wlcry hWLn2p+bJDypgvLd5V/dTIXDux1nrTYkGNoW79WLAxk9Aathj9huHdi83H1p0y0BTuED rpbA== X-Gm-Message-State: ALoCoQmjjFue1km+HutFWtYr14aGQbCGoDjkqF+uA9ccX6QxjeKksClPjC2eJGjWA7mrQzKkSLTw X-Received: by 10.50.112.68 with SMTP id io4mr10489658igb.0.1408438878508; Tue, 19 Aug 2014 02:01:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.33.246 with SMTP id j109ls614927qgj.83.gmail; Tue, 19 Aug 2014 02:01:18 -0700 (PDT) X-Received: by 10.52.87.144 with SMTP id ay16mr317461vdb.43.1408438878383; Tue, 19 Aug 2014 02:01:18 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id 20si8354345vcj.99.2014.08.19.02.01.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Aug 2014 02:01:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hq11so7048585vcb.38 for ; Tue, 19 Aug 2014 02:01:18 -0700 (PDT) X-Received: by 10.221.61.5 with SMTP id wu5mr29153418vcb.13.1408438878265; Tue, 19 Aug 2014 02:01:18 -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.37.5 with SMTP id tc5csp221827vcb; Tue, 19 Aug 2014 02:01:17 -0700 (PDT) X-Received: by 10.68.177.68 with SMTP id co4mr6668399pbc.93.1408438876944; Tue, 19 Aug 2014 02:01:16 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zr6si25838957pac.49.2014.08.19.02.01.08 for ; Tue, 19 Aug 2014 02:01:09 -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 S1752064AbaHSI6i (ORCPT + 20 others); Tue, 19 Aug 2014 04:58:38 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:15198 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751887AbaHSI6e (ORCPT ); Tue, 19 Aug 2014 04:58:34 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NAJ001AOQ9KZFD0@mailout3.samsung.com>; Tue, 19 Aug 2014 17:58:32 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-da-53f311b821d9 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 15.55.04943.8B113F35; Tue, 19 Aug 2014 17:58:32 +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 <0NAJ0011RQ2NYC00@mmp2.samsung.com>; Tue, 19 Aug 2014 17:58:32 +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, m.szyprowski@samsung.com, andrzej.p@samsung.com, Robert Baldyga Subject: [PATCH RESEND v3 06/12] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Date: Tue, 19 Aug 2014 10:54:12 +0200 Message-id: <1408438458-3317-7-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1408438458-3317-1-git-send-email-r.baldyga@samsung.com> References: <1408438458-3317-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGLMWRmVeSWpSXmKPExsVy+t9jQd0dgp+DDabtlbWY9bKdxeLg/XqL 5sXr2Swu75rDZrFoWSuzxdojd9ktHj3cymrx4PBOdgcOj/1z17B79G1ZxeixZf9nRo/jN7Yz eXzeJBfAGsVlk5Kak1mWWqRvl8CV8e6hUcFE4YqWJRdYGxg38XcxcnJICJhIPHt3hg3CFpO4 cG89kM3FISQwnVHi0b33jBBOO5PErxn9TCBVbAI6Elu+T2AEsUUE5CWub7zJAlLELHCIUeLV nWNgRcICaRInj81n72Lk4GARUJW41O8PYvIKuEjs+y4IsUwOqGIyK4jNKeAq8XbfLHYQWwio ZHPrGbYJjLwLGBlWMYqmFiQXFCel5xrqFSfmFpfmpesl5+duYgSH1jOpHYwrGywOMQpwMCrx 8Cp8+RgsxJpYVlyZC3QLB7OSCK/ji0/BQrwpiZVVqUX58UWlOanFhxilOViUxHkPtFoHCgmk J5akZqemFqQWwWSZODilGhiPz3/xx90ibm3f1WtiCt/K9Ny9J27vOtGy3kOS+fntq0I5MRZi y368cOC657zHYHbEGXWN2Gt/muUnm5/yFY1i+vWW0V/j/+LnDod6HnTf5fzdYXyBq/9rrMsm CyWm5/pbuh4K7T4SE5ncdNbs1/Kii7OcnNhv1HC6CJznZPaQqeWq/h15TEKJpTgj0VCLuag4 EQD+fMW4KQIAAA== 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.179 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 6d20ae9..3faa4f3 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); } /** @@ -3492,8 +3497,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); /* hsotg->num_of_eps holds number of EPs other than ep0 */