From patchwork Thu Sep 4 19:04:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Zimmerman X-Patchwork-Id: 36756 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f71.google.com (mail-qg0-f71.google.com [209.85.192.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2473320CBB for ; Thu, 4 Sep 2014 19:06:08 +0000 (UTC) Received: by mail-qg0-f71.google.com with SMTP id f51sf31067885qge.10 for ; Thu, 04 Sep 2014 12:06:07 -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=XRpqMOjVMZJDxfuo3zEdEagA7gWa7yDqIH0PWI4XQ5s=; b=a12oMPD8VPTr6Cel2ee+FGKmR22ylUavpzrrc/qlYYKbC9v355d6gYGBfKsNd5hsc2 jqg6e9TBYh5Jy++cBYBh90dGI088FSA8afwqwUsu0MLgN7+HgQvUBFGWonR4cAzSPUpB JSc3jo1+FrONtOqJ76kTzLw80ZHTfDjvVYl6ReQo4791B1XLuh0UcxZlKaMhptv+6jFt D8pKVp2Dvs/eXbYzWdvATtkFAxCbuZISfzaC9kTOlkZbSbjn5yOUkbsQCPGr9rTOivQR BFd4lmO0fZrIFepOkStIxTz/YUdBdT50L2VUJzaFfNLFWZm4LrUYZnw5DiRHbQTXY/Mm tN0w== X-Gm-Message-State: ALoCoQl2D2ALyHQGWj3wZ5LOr5ABDTlRSmDiRZLcUSzewIf2QddWOVh/Dtnwyizj8zk3ii1L0LoW X-Received: by 10.236.84.174 with SMTP id s34mr3404924yhe.21.1409857567917; Thu, 04 Sep 2014 12:06:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.35 with SMTP id n32ls415751qga.25.gmail; Thu, 04 Sep 2014 12:06:07 -0700 (PDT) X-Received: by 10.220.112.143 with SMTP id w15mr3699956vcp.41.1409857567815; Thu, 04 Sep 2014 12:06:07 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id sq9si3707082vdb.90.2014.09.04.12.06.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Sep 2014 12:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so11149687vcb.39 for ; Thu, 04 Sep 2014 12:06:07 -0700 (PDT) X-Received: by 10.52.129.200 with SMTP id ny8mr5173592vdb.27.1409857567714; Thu, 04 Sep 2014 12:06:07 -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 uj3csp885170vcb; Thu, 4 Sep 2014 12:06:07 -0700 (PDT) X-Received: by 10.70.53.138 with SMTP id b10mr12255749pdp.44.1409857566759; Thu, 04 Sep 2014 12:06:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wx5si5248184pbc.143.2014.09.04.12.06.01 for ; Thu, 04 Sep 2014 12:06:01 -0700 (PDT) Received-SPF: none (google.com: linux-usb-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 S1755099AbaIDTFt (ORCPT + 2 others); Thu, 4 Sep 2014 15:05:49 -0400 Received: from smtprelay4.synopsys.com ([198.182.44.111]:55333 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797AbaIDTFs (ORCPT ); Thu, 4 Sep 2014 15:05:48 -0400 Received: from us01secmta2.synopsys.com (us01secmta2.synopsys.com [10.9.203.102]) by smtprelay.synopsys.com (Postfix) with ESMTP id BE3E124E0023; Thu, 4 Sep 2014 12:05:48 -0700 (PDT) Received: from us01secmta2.internal.synopsys.com (us01secmta2.internal.synopsys.com [127.0.0.1]) by us01secmta2.internal.synopsys.com (Service) with ESMTP id B1ED4A4112; Thu, 4 Sep 2014 12:05:48 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by us01secmta2.internal.synopsys.com (Service) with ESMTP id 85866A4102; Thu, 4 Sep 2014 12:05:48 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 755706D3; Thu, 4 Sep 2014 12:05:48 -0700 (PDT) Received: from us01dwvnc004.internal.synopsys.com (us01dwvnc004.internal.synopsys.com [10.15.114.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 6A7896D2; Thu, 4 Sep 2014 12:05:48 -0700 (PDT) Received: from us01dwvnc004.internal.synopsys.com (localhost [127.0.0.1]) by us01dwvnc004.internal.synopsys.com (8.13.1/8.12.3) with ESMTP id s84J5mS7005199; Thu, 4 Sep 2014 12:05:48 -0700 Received: (from paulz@localhost) by us01dwvnc004.internal.synopsys.com (8.13.1/8.13.1/Submit) id s84J5h71005198; Thu, 4 Sep 2014 12:05:43 -0700 From: Paul Zimmerman To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, r.baldyga@samsung.com, Marek Szyprowski , Paul Zimmerman Subject: [PATCH RESEND v3 06/12] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Date: Thu, 4 Sep 2014 12:04:28 -0700 Message-Id: <1409857474-4497-7-git-send-email-paulz@synopsys.com> X-Mailer: git-send-email 1.7.0.5 In-Reply-To: <1409857474-4497-1-git-send-email-paulz@synopsys.com> References: <1409857474-4497-1-git-send-email-paulz@synopsys.com> Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: paul.zimmerman@synopsys.com 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.180 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 Signed-off-by: Paul Zimmerman --- 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 d737192..86e4fd9 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 */