From patchwork Tue Apr 16 15:16:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 1086374 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="odmYtle+"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44k89F4szQz9s3l for ; Wed, 17 Apr 2019 01:16:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbfDPPQs (ORCPT ); Tue, 16 Apr 2019 11:16:48 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37563 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725796AbfDPPQs (ORCPT ); Tue, 16 Apr 2019 11:16:48 -0400 Received: by mail-wr1-f66.google.com with SMTP id w10so27661819wrm.4 for ; Tue, 16 Apr 2019 08:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3wkqfGSkCk2bjLz8VHkTYkzdjoHE4h93rGkS/zAicZQ=; b=odmYtle+0v6XLK4cNtIczw2H6QOtMlnJGB8xx+mmj8VizKFft6ODNr9K8QOA20oGRh F0e2Rqt+DSzRs8IHrsU8pwPpKpT5VumyyvbW67AEjsdTIn5l1rGt/Ji9SH9/tEgZKNmP Frzx/73q4+zKO8RERv3GxS3PEHF5i80WwIiOARhvBHq8O4szJy6LGHQuw02WqQSnohZG LSBASO+97VY053NsklwbduZxb3kIgpW99TdkwtPIh8GA/VYy3xR+OKSWlNd17ayTBstr nR88mtxrJ3MpIDI9Sh2r6SoDZX2mNiwByf+cNUinT1JcS3SYc0x1k0PzjNlyYZAaYIx+ rZeg== 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:mime-version :content-transfer-encoding; bh=3wkqfGSkCk2bjLz8VHkTYkzdjoHE4h93rGkS/zAicZQ=; b=iYs5nEqj672d6ybbFtBbr2h4kyO4ugMRDB2qnyP2eiGPihb9VJXZ2dbaJmekM6ICiY jgyI/0cDTWTRoJ+x1qjnVuhFNPN+ETmBE2pmwllKLxILGFKJK4dUAndcMvXRvtBqCjw8 arMwd5qKYvkgw1RIbmK7OHnCPTYxWWM6oGYj7JfQyPmpNyXriezAJ4oFwNm1ieU01VZc iZ0oJCZ4Y0js9XjRQYFUo6U0qAIdGd5Y2p0ErwwI4r8pChEbYeFmJ/w9kcHsBg5DAYj0 f8PcTLWRZW/8YIxC1k72Uuq4iyS1g6nullX169u+4IWlrUp4zpL2k+x5YdvE7V4HKgVl bHPA== X-Gm-Message-State: APjAAAX2EE/a6M4pP/s7ypnC6Yl/cWQMBGuKIhOTe7mfZG+8hBxiQoRI zg5K3cYE4Q81VRWPOBiAkq1w/s7q X-Google-Smtp-Source: APXvYqzoPq3NngMrCpKlA8PBtwxS7N2JIZnnIQrjvO/s9GkY+GSrSzSei8uYtPHg3AENLOXamchqlw== X-Received: by 2002:adf:f78c:: with SMTP id q12mr32436054wrp.172.1555427806833; Tue, 16 Apr 2019 08:16:46 -0700 (PDT) Received: from localhost (p2E5BE61D.dip0.t-ipconnect.de. [46.91.230.29]) by smtp.gmail.com with ESMTPSA id j3sm127407476wre.51.2019.04.16.08.16.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Apr 2019 08:16:45 -0700 (PDT) From: Thierry Reding To: Thierry Reding Cc: Marcel Ziswiler , Dmitry Osipenko , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org Subject: [PATCH v2] drm/tegra: hdmi: Setup audio only if configured Date: Tue, 16 Apr 2019 17:16:44 +0200 Message-Id: <20190416151644.30974-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Thierry Reding The audio configuration is only valid if the HDMI codec has been properly set up. Do not attempt to set up audio before that happens because it causes a division by zero. Note that this is only problematic on Tegra20 and Tegra30. Later chips implement the division instructions which return zero when dividing by zero and don't throw an exception. Fixes: db5adf4d6dce ("drm/tegra: hdmi: Fix audio to work with any pixel clock rate") Reported-by: Marcel Ziswiler Signed-off-by: Thierry Reding Tested-by: Dmitry Osipenko --- Changes in v2: - setup audio at ->enable() time if it has been configured, otherwise audio playback needs to be restarted after the display goes through a disable/enable cycle drivers/gpu/drm/tegra/hdmi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c index 47c55974756d..d23c4bfde790 100644 --- a/drivers/gpu/drm/tegra/hdmi.c +++ b/drivers/gpu/drm/tegra/hdmi.c @@ -1260,9 +1260,15 @@ static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder) hdmi->dvi = !tegra_output_is_hdmi(output); if (!hdmi->dvi) { - err = tegra_hdmi_setup_audio(hdmi); - if (err < 0) - hdmi->dvi = true; + /* + * Make sure that the audio format has been configured before + * enabling audio, otherwise we may try to divide by zero. + */ + if (hdmi->format.sample_rate > 0) { + err = tegra_hdmi_setup_audio(hdmi); + if (err < 0) + hdmi->dvi = true; + } } if (hdmi->config->has_hda)