From patchwork Thu Apr 5 06:55:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 132843 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp5940650ljb; Wed, 4 Apr 2018 23:55:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx48/aK083r6F7WjC2RKHoHzRzVer8s+gDbxRp4AGDqrTCm9egv3krMQvu/w+ENedC8J0WLBY X-Received: by 2002:a17:902:6acc:: with SMTP id i12-v6mr22045134plt.353.1522911356665; Wed, 04 Apr 2018 23:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522911356; cv=none; d=google.com; s=arc-20160816; b=bUeaysvWcjSXFef4qpg94XKESHDm5OeQCB4LsY07FD4HMAO1JbCWkZbEoWYLv5THY8 3Iu5gUl8WlWvbqqnY8v+lQSX7VZg8pyb96yrYWwpHKP7BLYhFOH5ewU6EaObz1eXs/a2 AedhHHhkC+HWoiaoMLomuMrUIB177+cLuhrC1VlIBUks7mkU+MJ3Zf4grrM5vwivOsGM pv0G3d6WUJ/zUDsry4DnKXJzJDu/vS6O2GsZcyYsfB+bd1DC/hmXtq0KVqU4Z83ZxCDg evWz8Y4VWmrZyyAXoZx3ID1KjelZlLwzxboM/1hvAFwf0MlxKpTrDgQIiliQwOLPz2tV l+PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=SJr1nM9uBKhceCYvo5nj+VDoFQkEerJtCfSDnmI+4AM=; b=b5hnMoLAZVL40ZI8arIEoBK6nOLzDclZ2fH9OUgon/5TipjUTpp3H8tv9llk5sDk/6 poQr82WH8M16rXaQ6mVnynYFeyyFBNoJei2H2gh3FFA+EhzHF7zNcNxmCJkCGlJ+scpZ KmTfBEafscW6UEj7yZM2mKClk6F6UeV997mpBTdo9wS+WqVmvM8gAo+FpIEeeWvUmTI8 9JOkkvBxIVhzHjuB5cuf2Z7qh7zWSDJ9xXInLDXGW1nXhYiRjgLSEqm/Bq9YZYsEI/E5 i0ncR3WcA34obGyTGpMXjT7kZVEwj/QNwTavZTn7U5Hcz+XDg7eYd1H7V4u+aKMyzy/o CWDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=mtQ2M8El; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 9si5636656pfh.242.2018.04.04.23.55.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Apr 2018 23:55:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=mtQ2M8El; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8B3B6E6A2; Thu, 5 Apr 2018 06:55:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id C9B216E6A2 for ; Thu, 5 Apr 2018 06:55:51 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w356tlEx012409; Thu, 5 Apr 2018 01:55:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522911347; bh=9MSRBzH9PZOVDmZfK88bC1zhcTEnI1O5cY1ZUy46Lb8=; h=From:To:CC:Subject:Date; b=mtQ2M8El6kW0ZzGLiduSfolESZGl8dvHBLXoCxlbMHvnB+SOzOIuq2Cl0rFn7q9BR GeNn19pPoRknJl6s6eZQb97OZJGdL58sDAZGZ88xTi6ikcbujXbE8tGvCyOu8dfuyH 3AVdJaZp8HfdEACY8jDtF5pJR0C5LnGu4751geo0= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w356tl13014104; Thu, 5 Apr 2018 01:55:47 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Thu, 5 Apr 2018 01:55:46 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Thu, 5 Apr 2018 01:55:45 -0500 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w356ti0l032067; Thu, 5 Apr 2018 01:55:44 -0500 From: Tomi Valkeinen To: Subject: [PATCH] drm/omap: fix crash if there's no video PLL Date: Thu, 5 Apr 2018 09:55:37 +0300 Message-ID: <20180405065537.29818-1-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keerthy , Tomi Valkeinen , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit 8a7eda7686675b73d74c22c0d5b83059f9d783f6 ("drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions") made dpi.c use ctx->pll even when there's no PLL, causing a crash at modeset on AM4 EVM, and presumably all OMAP2/3 boards. Fix this by having struct dpi_data pointer in the ctx instead, giving access to dispc without going through the pll. Signed-off-by: Tomi Valkeinen Reported-by: Keerthy Cc: Laurent Pinchart Tested-by: Keerthy Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/dpi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index fb1c27f69e3a..3d662e6805eb 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -142,7 +142,7 @@ static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi) } struct dpi_clk_calc_ctx { - struct dss_pll *pll; + struct dpi_data *dpi; unsigned int clkout_idx; /* inputs */ @@ -191,7 +191,7 @@ static bool dpi_calc_hsdiv_cb(int m_dispc, unsigned long dispc, ctx->pll_cinfo.mX[ctx->clkout_idx] = m_dispc; ctx->pll_cinfo.clkout[ctx->clkout_idx] = dispc; - return dispc_div_calc(ctx->pll->dss->dispc, dispc, + return dispc_div_calc(ctx->dpi->dss->dispc, dispc, ctx->pck_min, ctx->pck_max, dpi_calc_dispc_cb, ctx); } @@ -208,8 +208,8 @@ static bool dpi_calc_pll_cb(int n, int m, unsigned long fint, ctx->pll_cinfo.fint = fint; ctx->pll_cinfo.clkdco = clkdco; - return dss_pll_hsdiv_calc_a(ctx->pll, clkdco, - ctx->pck_min, dss_get_max_fck_rate(ctx->pll->dss), + return dss_pll_hsdiv_calc_a(ctx->dpi->pll, clkdco, + ctx->pck_min, dss_get_max_fck_rate(ctx->dpi->dss), dpi_calc_hsdiv_cb, ctx); } @@ -219,7 +219,7 @@ static bool dpi_calc_dss_cb(unsigned long fck, void *data) ctx->fck = fck; - return dispc_div_calc(ctx->pll->dss->dispc, fck, + return dispc_div_calc(ctx->dpi->dss->dispc, fck, ctx->pck_min, ctx->pck_max, dpi_calc_dispc_cb, ctx); } @@ -230,7 +230,7 @@ static bool dpi_pll_clk_calc(struct dpi_data *dpi, unsigned long pck, unsigned long clkin; memset(ctx, 0, sizeof(*ctx)); - ctx->pll = dpi->pll; + ctx->dpi = dpi; ctx->clkout_idx = dss_pll_get_clkout_idx_for_src(dpi->clk_src); clkin = clk_get_rate(dpi->pll->clkin); @@ -244,7 +244,7 @@ static bool dpi_pll_clk_calc(struct dpi_data *dpi, unsigned long pck, pll_min = 0; pll_max = 0; - return dss_pll_calc_a(ctx->pll, clkin, + return dss_pll_calc_a(ctx->dpi->pll, clkin, pll_min, pll_max, dpi_calc_pll_cb, ctx); } else { /* DSS_PLL_TYPE_B */ @@ -275,6 +275,7 @@ static bool dpi_dss_clk_calc(struct dpi_data *dpi, unsigned long pck, bool ok; memset(ctx, 0, sizeof(*ctx)); + ctx->dpi = dpi; if (pck > 1000 * i * i * i) ctx->pck_min = max(pck - 1000 * i * i * i, 0lu); else