From patchwork Wed Jul 16 10:22:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 33715 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4EE25201F1 for ; Wed, 16 Jul 2014 10:23:39 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id nu7sf4009837obb.3 for ; Wed, 16 Jul 2014 03:23:38 -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=FrihRa1ojz2Z2e7iPJksF53DBpW0qQlbsITOFXG8Ysw=; b=I1cBHsXIp3S4k3Q4stmmhmSINDnAP8XeKtTbPQLtXrkH79r/ysIMpaA6hwHkjipPfB qLCaW16xPZ6lEK6Kvkxr3TFqynpsz37HLZ5eVVCrOOLVlAURvdjT2aYdNGgl4N1CqoJW wcdbtQxio/5fzolhyV0fMJb4R8ohSTLtQbggXGlB8gMtMaZmf+ZBv199NSWmcWJP1Zt/ QWGThCK/se2tgyLaXvMN+sNgDtvAJ6o9s5IyMjcJg9662PZJMuhBCrVXa9NVUT5gS/ec eDTQ5G/cAkYervhxvTib3oqjKFBce1a9oyS2r76LbJQn5wTcgvnG0AT8KdQAmymObb/T gLKQ== X-Gm-Message-State: ALoCoQkKoEayqBrdosECdMooe3UGCctNBGH4O1JgoMMdc+ch/Bxn2wH5Ee3tURpsq239zU3zIHbT X-Received: by 10.42.15.197 with SMTP id m5mr14879947ica.31.1405506218493; Wed, 16 Jul 2014 03:23:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.80 with SMTP id y74ls360502qgd.0.gmail; Wed, 16 Jul 2014 03:23:38 -0700 (PDT) X-Received: by 10.52.157.41 with SMTP id wj9mr22762743vdb.1.1405506218407; Wed, 16 Jul 2014 03:23:38 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id or9si8072701vcb.81.2014.07.16.03.23.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Jul 2014 03:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so1198159vcb.29 for ; Wed, 16 Jul 2014 03:23:38 -0700 (PDT) X-Received: by 10.52.37.81 with SMTP id w17mr223431vdj.95.1405506218318; Wed, 16 Jul 2014 03:23:38 -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 tc5csp285337vcb; Wed, 16 Jul 2014 03:23:37 -0700 (PDT) X-Received: by 10.68.69.71 with SMTP id c7mr6372470pbu.43.1405506217172; Wed, 16 Jul 2014 03:23:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rn1si14089807pbc.172.2014.07.16.03.23.36; Wed, 16 Jul 2014 03:23:36 -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 S1758913AbaGPKXJ (ORCPT + 3 others); Wed, 16 Jul 2014 06:23:09 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:18030 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758894AbaGPKXG (ORCPT ); Wed, 16 Jul 2014 06:23:06 -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 <0N8S00009VIHWJ70@mailout3.samsung.com>; Wed, 16 Jul 2014 19:23:05 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-85-53c65288ba7e Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id DC.10.04943.88256C35; Wed, 16 Jul 2014 19:23:05 +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 <0N8S00MJHVHJNH00@mmp2.samsung.com>; Wed, 16 Jul 2014 19:23:04 +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 v2 06/12] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Date: Wed, 16 Jul 2014 12:22:24 +0200 Message-id: <1405506150-16185-7-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1405506150-16185-1-git-send-email-r.baldyga@samsung.com> References: <1405506150-16185-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBLMWRmVeSWpSXmKPExsVy+t9jQd3OoGPBBnPms1jMetnOYnHwfr1F 8+L1bBaXd81hs1i0rJXZYu2Ru+wW26dMZ7J4cHgnuwOHx/65a9g9+rasYvTYsv8zo8fxG9uZ PD5vkgtgjeKySUnNySxLLdK3S+DK+DCni61gonDF34WTmBoYN/F3MXJySAiYSHzf+ZcZwhaT uHBvPVsXIxeHkMB0RomvS+6yQjjtTBLn1nezgVSxCehIbPk+gRHEFhEQkFj/4hI7SBGzwAlG iY7/F8CKhAXiJSY+/skCYrMIqEqs3bYKaAUHB6+Aq8SSR4kQ2+QkTh6bzApicwq4Sax53cwO YgsBlRxft4xpAiPvAkaGVYyiqQXJBcVJ6bmGesWJucWleel6yfm5mxjB4fVMagfjygaLQ4wC HIxKPLwbQo4GC7EmlhVX5h5ilOBgVhLhdfA/FizEm5JYWZValB9fVJqTWnyIUZqDRUmc90Cr daCQQHpiSWp2ampBahFMlomDU6qBcfPsX7qJ3iVbLaNqzZ3dezYcmFFfrhup2TqjI7fcpMou 5fGrH1r7Z6/6qD7L6V5ytpzp/7MPTOKTk6YvvX69WUz51j7H38qPJHNd7b5lsnh9Fanb+J5T /22XUL3hlmv/pKzf3ZA1dP6bLKTbox+YYqbdKVK32cxPVu+KxLPKL05+PBJpH6qUWIozEg21 mIuKEwFZ1KzFKwIAAA== 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: patch@linaro.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.170 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 */