From patchwork Fri Jul 18 11:39:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 33831 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 B9B25208CF for ; Fri, 18 Jul 2014 11:41:06 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf24148362pdb.9 for ; Fri, 18 Jul 2014 04:41:02 -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=EZUj0j9Zd8s4uAuaojjoKpkFGXhjJNtN8AKiI7tA7Vo=; b=Ii1MzmKxEX2kmBzXbUEFPogk8xu+L/6UfVjn45MJ7Y6Gaw8S5F0G5NeBwJbVbS28GL Pw9RheTdAq2sTW/53I4alZQOZr66F5rzhtWOECcr7xpdX5Sh/MXqGawQFrLqg2J/2HvC AyPYgs7asl5ENwzAX4WzWsxV9NlEKAbETHLi/d1goASAczW4EqKqnrCINeYM3/LZoSQW WCCEVwUv2YJ7P8f8BshY1Fkhf0jP/BMxjumx/qHR4fzj1Mazo9tXcZk9UbX1aAIK+zbZ HdQqj2bVjztl30iSH1RNaPBhaMj+Z5UknHgKbz6BCxFeBqpGRC6ES5/L3Lfqr26npUKc df6w== X-Gm-Message-State: ALoCoQk1Q44H6vxbGZOJ9PSWMWCUg1d/8oYPVL0LfR1yUiP/bvdS4tC77hpmUPlq3IzLCnYFODVu X-Received: by 10.66.65.108 with SMTP id w12mr1967553pas.46.1405683661041; Fri, 18 Jul 2014 04:41:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.16 with SMTP id 16ls963091qgg.57.gmail; Fri, 18 Jul 2014 04:41:00 -0700 (PDT) X-Received: by 10.220.203.134 with SMTP id fi6mr4974399vcb.18.1405683660936; Fri, 18 Jul 2014 04:41:00 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id s6si5281088vdz.85.2014.07.18.04.41.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Jul 2014 04:41:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id hu12so7234426vcb.28 for ; Fri, 18 Jul 2014 04:41:00 -0700 (PDT) X-Received: by 10.52.248.146 with SMTP id ym18mr4198977vdc.8.1405683660820; Fri, 18 Jul 2014 04:41:00 -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 tc5csp3147vcb; Fri, 18 Jul 2014 04:41:00 -0700 (PDT) X-Received: by 10.68.225.105 with SMTP id rj9mr4295639pbc.108.1405683659651; Fri, 18 Jul 2014 04:40:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ct2si5653331pbc.92.2014.07.18.04.40.54; Fri, 18 Jul 2014 04:40:54 -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 S1761656AbaGRLkO (ORCPT + 24 others); Fri, 18 Jul 2014 07:40:14 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:25735 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761618AbaGRLkJ (ORCPT ); Fri, 18 Jul 2014 07:40:09 -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 <0N8W00IC1OEWIW90@mailout3.samsung.com>; Fri, 18 Jul 2014 20:40:08 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-ec-53c9079818b2 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id C4.67.04943.89709C35; Fri, 18 Jul 2014 20:40:08 +0900 (KST) Received: from AMDC2122.DIGITAL.local ([106.120.53.17]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N8W002CQOE11160@mmp1.samsung.com>; Fri, 18 Jul 2014 20:40:08 +0900 (KST) From: Robert Baldyga To: balbi@ti.com Cc: paulz@synopsys.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, m.szyprowski@samsung.com, andrzej.p@samsung.com, Robert Baldyga Subject: [PATCH v3 06/12] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Date: Fri, 18 Jul 2014 13:39:31 +0200 Message-id: <1405683577-11226-7-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1405683577-11226-1-git-send-email-r.baldyga@samsung.com> References: <1405683577-11226-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOLMWRmVeSWpSXmKPExsVy+t9jAd0Z7CeDDRa/FbOY9bKdxeLg/XqL 5sXr2Swu75rDZrFoWSuzxdojd9kttk+ZzmTx4PBOdgcOj/1z17B79G1ZxeixZf9nRo/jN7Yz eXzeJBfAGsVlk5Kak1mWWqRvl8CV8WFOF1vBROGKvwsnMTUwbuLvYuTkkBAwkTh74jkLhC0m ceHeerYuRi4OIYFFjBJ7Vr9jhXDamSQuNn1hA6liE9CR2PJ9AiOILSIgILH+xSV2kCJmgROM Eh3/L4AVCQvES8w/fARsLIuAqsTNlVOYuxg5OHgFXCXOnjWE2CYncfLYZFYQm1PATaLt0X8W kBIhoJJpX/knMPIuYGRYxSiaWpBcUJyUnmuoV5yYW1yal66XnJ+7iREcXM+kdjCubLA4xCjA wajEw2tx83iwEGtiWXFl7iFGCQ5mJRHe7PtAId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rwHWq0D hQTSE0tSs1NTC1KLYLJMHJxSDYxdErJnIj8Yqt5S6OW+eMBt14TMusXOCwR/mQQXcgpaPEjl /i1y7sF2g0LjUo4zG869uGCyQqevME+whVH95qbELeI9qowT+Q+f//d/QkiqxTflo5r1DS7a u5nzS6+IMbBvMjr+O6hOmyFRdgrjZm/9y6+rzz6/49UUFjr1gtGklK9trnyu85RYijMSDbWY i4oTAXLifhQqAgAA 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.169 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 95b6dcb..21d21de 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -194,6 +194,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)); @@ -3030,19 +3032,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); } /** @@ -3495,8 +3500,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 */