From patchwork Mon Jun 17 07:31:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 576 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A58B73F072 for ; Mon, 17 Jun 2019 09:36:39 +0200 (CEST) Received: by mail-pf1-f200.google.com with SMTP id z1sf6558166pfb.7 for ; Mon, 17 Jun 2019 00:36:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1560756998; cv=pass; d=google.com; s=arc-20160816; b=gy9H+rT7HuzL6ZU7jh1j7/cboydV7W/WPfKpiM1ltTg0Fdw3WkLujy6LcaKbp1CH4W uTHhftK9T3erpUDYQuQo0n3h77qIfq3/CJlH+m0EtCexZwgG2THT9oYjZh0a0QkvCBtm aH7q+UHc0DXn7HGJU3/+xykREFLxvCEfgzAs0KoFS+dm2sXiKxGVLPF+hcA5mb9IThBb FI2Bah9eJDhtGLjk+4JYRsT5+w9dZS3vZc2WvkG6TIno66uR0klzr1+LU1Gx7M4kXtLF PklcGVaFqiqEsyMYByoO+Ud1yzJ+zE7SJjji+GQdUrchTT5Kl7Qzyv0U9bVrHEp8F63P e4/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=AnP1r9463qZn2+fny0YUmxy8mz+F7vzdZsgnVQz87vw=; b=V3542KU8V9JepB/43vHkcDieriah2lJkhsnkBhCxFQ2baXsaMqdWRcmfwM1ixFOFts ywXFllhnW2MGCdBPiduMt8WS9ffjNnu+4rp/WNNrFL6b2YobKhf6Dfp9lgEWtSIPkr24 QHCuBS4H0a+L5bSSaxpTxardH1R8ilAAwC4roUQGlbJnY/QubVzqgoA+LC+7jO2ZrZQX CUs0OAjAuRR6XVmPlcO9nWZBi7c2PISX3bVgSNjbykEkEAYKrjFCK+hgqGvAklBDl9Ih UhU7mOoi7mYUiGkpR9+c0fgAtxywUE/5foc78ETXs+9D2G63kqssFW/JrDulREMXHx5m EyKw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Y/k47rD+"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=AnP1r9463qZn2+fny0YUmxy8mz+F7vzdZsgnVQz87vw=; b=F6nLqMK729zDFxU8XK0Q1K8b302eNnH/1RIBbOFhucDeA1QtxjDLfeAMld5k6gjZ3N B4+CwDe5v5/xRVSkYPCCJXpgoUgr8/01HkRp5PkUGmCOCnM+2L3uIdiMmaMwUO9ME+j1 fqv+dC6ihnm/8F8jEVH/cLdrDDR0PAUm/kN+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=AnP1r9463qZn2+fny0YUmxy8mz+F7vzdZsgnVQz87vw=; b=RD7gnMEPqOgDuOJZI5KVKEGPin3Jc0qmOm1JYQwJ2U1MVNWPwTmyHe4X6dfL/mVUgn aDtzwjYBdMFCXE+RNgxBcsmR8FpWfTLuqa+89dgjSk96Oan28jqQBRWbcombpcOSxpkA 8ixTQZnlvG4A+88Bpz+FGaxtBXf9yYwJ+o6jZHGn/DFeyejV0+bFXJQzJ+pgnVtX5umi f3gThhLTFArdrsSAoJa6VD1jLTsPErwopT89FKDxvSY2fOFTmMjdIA9u/91a+rRZxNqy hmX3vRgJPX9hOVnklcdrF9VpuNm9Im2DOyS9Jons+8MrjZSRySNF4Hx8VXI2hNToCDuS BX2g== X-Gm-Message-State: APjAAAV18tCnD5QvXjU1mrKL9jxKs+VLEV34o7fin4tYFlecqYDsiZF2 3b7wK05GkLmj54fy0MbALGts+XuW X-Google-Smtp-Source: APXvYqza8xBU8ZUDyEKiX55woVTrZHXLwYvZsZi7KHpH+ZWQbaMssLw/+CfVYnHW5DWwqTR+ynwR9g== X-Received: by 2002:a65:5684:: with SMTP id v4mr48595606pgs.160.1560756997987; Mon, 17 Jun 2019 00:36:37 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:28ca:: with SMTP id o193ls3367405pfo.10.gmail; Mon, 17 Jun 2019 00:36:37 -0700 (PDT) X-Received: by 2002:a65:498e:: with SMTP id r14mr13909520pgs.21.1560756997592; Mon, 17 Jun 2019 00:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560756997; cv=none; d=google.com; s=arc-20160816; b=ubjwQGsWa2/SDcF9qor9YWQ2zxn/9RcuKgpi7lbAKJSd2byShQ2Hyjib9Y+RVcLN6H i7GSy953T65e028CSfrHObvMc3Ady4tZUy7sO0KbdUqBRuGojW/ZO76e1WbxZZ/iZHLU twjQ2GHbtwhPvoVHhPa4q+3Ghn30N27i32yGyqXojpeiH1YAGyiG1Zz0wtkdSN0K0Oea 3OnqwbrMavN7M0btw/hRTrKm2y9hw2+X33ubqVZfV7fI/8qsCgd2EItavGc/H373UPC/ riHayfGzhcXGQyhi4lFUw8RHpX8wafdcV4tfM4EtpfyXjxDTZwQabFZmxhY0FV4XVCLG oE7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=KGsWoCn89xsxyt00F2oPoeiNyY3Uw4lqEW4tRmvYwz8=; b=1IrbWql0FrWKND3ZgYuDKmWNdG/TLHhY/6Q0quGtZpybOXuQSLDU+Bz6IzUDpV9vS+ KeF1oCuLhkr3Z98U0zb/U27N9aEkAT4hmKZ1jrrFigi4qNMkErB0eZ/Z3uz9aEauymNb S98PXtM7j08ro67zEkhndi6cLkV2rTHEoym9GWJ8pgmue+wjgRrfnCzzyHO1gLAQHiqI pfzXLAdHdxmzC2/YBrZtA638X+66hfcYVhyl/mFrlV1oejxwHRYyMlBDiqWqbNr4fxVD ufxyUEkqsDMw5OWSL6X1EvxPl1qpf7pVoOCfI/V3ciBp+5JyUxyOVP50PzkG6pJA7BlN C3Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Y/k47rD+"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p1sor12754046plo.9.2019.06.17.00.36.37 for (Google Transport Security); Mon, 17 Jun 2019 00:36:37 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:b7c1:: with SMTP id v1mr13789658plz.85.1560756997260; Mon, 17 Jun 2019 00:36:37 -0700 (PDT) Received: from localhost.localdomain ([49.206.203.245]) by smtp.gmail.com with ESMTPSA id m41sm15205998pje.18.2019.06.17.00.36.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 00:36:36 -0700 (PDT) From: Jagan Teki To: Simon Glass , Philipp Tomsich , Kever Yang , YouMin Chen , u-boot@lists.denx.de Cc: Manivannan Sadhasivam , gajjar04akash@gmail.com, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 05/99] ram: rk3399: Handle data training return types Date: Mon, 17 Jun 2019 13:01:18 +0530 Message-Id: <20190617073252.27810-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190617073252.27810-1-jagan@amarulasolutions.com> References: <20190617073252.27810-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Y/k47rD+"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , data trainings calls like ca, wl, rg, rl, wdql have proper return types with -EIO and the return type missed to handle in data_training function. This patch, add proper return type checks along with useful debug statement on each data training calls. Incidentally this would help to prevent the sdram initialization hang for single channel dram and when the code is trying to initialize second channel with proper return type of relevant data training call might failed. Signed-off-by: Jagan Teki --- drivers/ram/rockchip/sdram_rk3399.c | 50 ++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 4c09009b7a..e10bcafe32 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -877,6 +877,7 @@ static int data_training(const struct chan_info *chan, u32 channel, u32 training_flag) { u32 *denali_phy = chan->publ->denali_phy; + int ret; /* PHY_927 PHY_PAD_DQS_DRIVE RPULL offset_22 */ setbits_le32(&denali_phy[927], (1 << 22)); @@ -897,24 +898,49 @@ static int data_training(const struct chan_info *chan, u32 channel, } /* ca training(LPDDR4,LPDDR3 support) */ - if ((training_flag & PI_CA_TRAINING) == PI_CA_TRAINING) - data_training_ca(chan, channel, params); + if ((training_flag & PI_CA_TRAINING) == PI_CA_TRAINING) { + ret = data_training_ca(chan, channel, params); + if (ret < 0) { + debug("%s: data training ca failed\n", __func__); + return ret; + } + } /* write leveling(LPDDR4,LPDDR3,DDR3 support) */ - if ((training_flag & PI_WRITE_LEVELING) == PI_WRITE_LEVELING) - data_training_wl(chan, channel, params); + if ((training_flag & PI_WRITE_LEVELING) == PI_WRITE_LEVELING) { + ret = data_training_wl(chan, channel, params); + if (ret < 0) { + debug("%s: data training wl failed\n", __func__); + return ret; + } + } /* read gate training(LPDDR4,LPDDR3,DDR3 support) */ - if ((training_flag & PI_READ_GATE_TRAINING) == PI_READ_GATE_TRAINING) - data_training_rg(chan, channel, params); + if ((training_flag & PI_READ_GATE_TRAINING) == PI_READ_GATE_TRAINING) { + ret = data_training_rg(chan, channel, params); + if (ret < 0) { + debug("%s: data training rg failed\n", __func__); + return ret; + } + } /* read leveling(LPDDR4,LPDDR3,DDR3 support) */ - if ((training_flag & PI_READ_LEVELING) == PI_READ_LEVELING) - data_training_rl(chan, channel, params); + if ((training_flag & PI_READ_LEVELING) == PI_READ_LEVELING) { + ret = data_training_rl(chan, channel, params); + if (ret < 0) { + debug("%s: data training rl failed\n", __func__); + return ret; + } + } /* wdq leveling(LPDDR4 support) */ - if ((training_flag & PI_WDQ_LEVELING) == PI_WDQ_LEVELING) - data_training_wdql(chan, channel, params); + if ((training_flag & PI_WDQ_LEVELING) == PI_WDQ_LEVELING) { + ret = data_training_wdql(chan, channel, params); + if (ret < 0) { + debug("%s: data training wdql failed\n", __func__); + return ret; + } + } /* PHY_927 PHY_PAD_DQS_DRIVE RPULL offset_22 */ clrbits_le32(&denali_phy[927], (1 << 22)); @@ -1046,7 +1072,7 @@ static int switch_to_phy_index1(struct dram_info *dram, clrsetbits_le32(&denali_phy[896], (0x3 << 8) | 1, 1 << 8); ret = data_training(&dram->chan[channel], channel, params, PI_FULL_TRAINING); - if (ret) { + if (ret < 0) { debug("index1 training failed\n"); return ret; } @@ -1090,7 +1116,7 @@ static int sdram_init(struct dram_info *dram, udelay(10); if (data_training(chan, channel, params, PI_FULL_TRAINING)) { - printf("SDRAM initialization failed, reset\n"); + printf("%s: data training failed\n", __func__); return -EIO; }