From patchwork Mon Jun 23 07:51:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 32331 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F084B203AC for ; Mon, 23 Jun 2014 07:53:42 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf41392357oac.3 for ; Mon, 23 Jun 2014 00:53:42 -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=Xkb3eZVM8h6DziHSwNiz4YSiohRW0KzUDwyrlL+/iyolV1i3VY287klUi2PyG2j9ab 0J4iv3TuxRNk06yDxSmVZIqaYnJJRyWxo1+M9a98gZlGD7aBKeBU0rxFY9uPnNSg8ax8 dwXMAlJQona/J0njjX4VtCitWIo/0Drr+Wp3sWBW5Hk2vpL9m+L/KYuZl0LOrqbTyMxI bGoHcRv7BnKmQUZANlHhqnxl5MHP8Q8P1hDJ4e878P0cAHfbjr2nwZvxkJ9FZP5xyfqY EA8+G5yq4EU0HgigSs9IUSVhh1Y0K3QxMLZXpxBdcvvxtxKre7FP7BaWzZmQWzDyGf+s fZ4A== X-Gm-Message-State: ALoCoQklkZykm7X2ubFuug6404VSi17o/207K/d+GlOQIhDWVvehd4LCXryYvqJZsiDfRxAZn2w5 X-Received: by 10.50.55.35 with SMTP id o3mr9027432igp.6.1403510022548; Mon, 23 Jun 2014 00:53:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.33 with SMTP id 30ls1144575qgw.13.gmail; Mon, 23 Jun 2014 00:53:42 -0700 (PDT) X-Received: by 10.52.232.133 with SMTP id to5mr14952128vdc.16.1403510022450; Mon, 23 Jun 2014 00:53:42 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id u6si2829072vdo.34.2014.06.23.00.53.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Jun 2014 00:53:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id db11so5758901veb.32 for ; Mon, 23 Jun 2014 00:53:42 -0700 (PDT) X-Received: by 10.58.69.76 with SMTP id c12mr1859244veu.35.1403510022323; Mon, 23 Jun 2014 00:53:42 -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 tc5csp112356vcb; Mon, 23 Jun 2014 00:53:41 -0700 (PDT) X-Received: by 10.68.129.42 with SMTP id nt10mr26799384pbb.134.1403510021558; Mon, 23 Jun 2014 00:53:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rb7si20649742pbb.89.2014.06.23.00.53.40; Mon, 23 Jun 2014 00:53:40 -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 S1752552AbaFWHxh (ORCPT + 9 others); Mon, 23 Jun 2014 03:53:37 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:19324 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752489AbaFWHxe (ORCPT ); Mon, 23 Jun 2014 03:53:34 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N7M00BJ6399FCE0@mailout4.samsung.com>; Mon, 23 Jun 2014 16:53:33 +0900 (KST) X-AuditID: cbfee61b-f79f86d00000144c-62-53a7dcfd7a3d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 90.C1.05196.DFCD7A35; Mon, 23 Jun 2014 16:53:33 +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 <0N7M00JX335V68O0@mmp2.samsung.com>; Mon, 23 Jun 2014 16:53:32 +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 06/11] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Date: Mon, 23 Jun 2014 09:51:25 +0200 Message-id: <1403509890-14103-7-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1403509890-14103-1-git-send-email-r.baldyga@samsung.com> References: <1403509890-14103-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJLMWRmVeSWpSXmKPExsVy+t9jQd2/d5YHG+w4wWEx62U7i8XB+/UW zYvXs1lc3jWHzWLRslZmi7VH7rJbbJ8yncniweGd7A4cHvvnrmH36NuyitFjy/7PjB7Hb2xn 8vi8SS6ANYrLJiU1J7MstUjfLoEr48OcLraCicIVfxdOYmpg3MTfxcjJISFgIrH3zzEmCFtM 4sK99WxdjFwcQgLTGSVu9B1kgnDamSR27OhjA6liE9CR2PJ9AiOILSIgILH+xSV2kCJmgROM Eh3/L4AVCQvESNw79gHMZhFQlXjdfZQFxOYVcJVY2/udHWKdnMTJY5NZQWxOATeJ9TcXgsWF gGoWnZ7GPoGRdwEjwypG0dSC5ILipPRcI73ixNzi0rx0veT83E2M4AB7Jr2DcVWDxSFGAQ5G JR5eDbflwUKsiWXFlbmHGCU4mJVEeBsbgEK8KYmVValF+fFFpTmpxYcYpTlYlMR5D7ZaBwoJ pCeWpGanphakFsFkmTg4pRoYp/gkTTiewKrvP0tq3mPHM4KTkna91ZZ1S70pOvVehFS1AtdX 7+ILmmWLLn48n/joSvDUl2dttSWfeLLvjm/xFg5ZoCCaeluk93ju9MsmCnfYUn5ox7e8kP0f xH6twvLoH3PbBtb/WoFyQjfuzDp7z/pcqt2EVXFPI7Qu5l37ssLLSsG99O4WJZbijERDLeai 4kQAYw7ZNSwCAAA= 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.128.173 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 */