Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp400186rdb; Tue, 19 Dec 2023 23:39:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEK+nmVNlKidDQKsX7GrlXhAc63zZPhbNyqNPikWpO1Jetrcrk0Y8T2ylSg6B5gbuD7fWeR X-Received: by 2002:a05:6870:472b:b0:203:cb22:9758 with SMTP id b43-20020a056870472b00b00203cb229758mr5408871oaq.50.1703057968354; Tue, 19 Dec 2023 23:39:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703057968; cv=none; d=google.com; s=arc-20160816; b=qnL/TBghvidN1YF0soYOFDkFTg0x7cGf+m/GfuK9NJikRO9NjB+R6dwOakQQGDpVaW 10X57L0KcmPzghiKNvOwHBXv28tpw8pJl9aUfB/fu+IBuwWHOz3ogMtioDChuMDWUEaa F71ENOn6/AHOtAOi9zb4fWKkTViGvX98Aotvr3Iqj0U9ckS8LAoo8k+/IXPfNd7oUn0c 0V7EdxYmrHDSqR2RDt9eOUgfznDmdVFBf/JgSbf/jRZRG99vKbr+wmf0B+oIdTNdwnbn Y3tAhU+BOO/iQnKfV7vTaAASnjxmlNxFWAshfb4tsd5cmwTRKXM74NYDvrrnFWs7zOAx to/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gxdaR881KYWxnVjE5RFuD+xNEp0CWp7EUb3EZJFwG58=; fh=QV7XdePgK3+PZjSSlhzGoV153udcGLuGJygi6aYo3Ys=; b=OojA6qS2QUIeV9bnUty1e93a80JldQlXF1uOsgl7/S1hSjrw+jiNGbklFrVMa/02L8 tzzQC1qXUF8MQ5IJ22vzyRCahXnDDlmpHXp0vGhuegJVaNYhzXywX/3Q4uiEgZgqdO3Q ArhdGkKl3gD00wUOhmTZYKgbA/UWREAs7r7bjMZqtBE3BvfRo/K3VoT4JeT6mTlEZfvp 4rZmDJ+XtnbqwtZ+6qWtkVzjm69LrE6cJCnNa+c1By7gLHGeMskiietgf939VIZs79m7 5hY1JVLtpsfyV6hS0iaJdX/eTniZKkIIwBWj+hxPQWCz4COJY3yoVRGvTVjqArMv0MIA xM/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CBFcRaF9; spf=pass (google.com: domain of linux-kernel+bounces-6499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6499-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u8-20020a631408000000b005cdbf27fdd1si1985338pgl.684.2023.12.19.23.39.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 23:39:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CBFcRaF9; spf=pass (google.com: domain of linux-kernel+bounces-6499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6499-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CD4C1B24FB8 for ; Wed, 20 Dec 2023 07:38:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FC071C680; Wed, 20 Dec 2023 07:38:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CBFcRaF9" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47FFB168B2 for ; Wed, 20 Dec 2023 07:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-553a45208ffso1791320a12.3 for ; Tue, 19 Dec 2023 23:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703057891; x=1703662691; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gxdaR881KYWxnVjE5RFuD+xNEp0CWp7EUb3EZJFwG58=; b=CBFcRaF9um8CTe/6RBFNzYJ3JxOkiLFvFntXhMzq3vF+ERECkg96EraCj02i07m3+3 UmSjzGYEEWmEy53Qfm2mmAcBg2fe+YJpNFrf7bq7WUfFSoYhhokXOFePamggOz1xz+3K NAYqun3zcUNtKHoDUSpn0mA34JQM7hsX/mTv0qhWT7mcTRA+NW88ZgQtpI6E97NdS9L0 PjAYCWcMMWKMzo3MbH6nSW3mc8sIMlLvAb1gg6muTunroGvwGDmj4VT9zvoA13Tyw3aM 9cqcXfskRALHK07Xp+91il646Sp4Ay4G5dHx3csjDk+zuDi/rlwvB1M3yRq6hD11ubiU UegA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703057891; x=1703662691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gxdaR881KYWxnVjE5RFuD+xNEp0CWp7EUb3EZJFwG58=; b=OQFRS3PG+SYvMWgLN1aRYzuyrYjf62cxzQ5sbyujz/QZm5mblgGIcmCIdM9ISQhb+E gVdQq8AaRKl96iNnCVqxlcS3kKWfpfa/Nq/uOC1gofXNLTyCt4onzAftDTBq/4q0Fv7O tpKJxiqbCeCFiub5EVzwUcOn0/aqYskCf5rYJgF1YDW4W5HRFN+Ttg4Chk5for/AqENk 4dXOSnLpHNbb9j0fBY6UCEqa9HTYu+etlEsHbffxfugFpbkvynoB6ouOckvVqApTW0ne sr5vkjVkvM8/VFtIjKtb0yfw9J3o4iW8+Blaz7DJ17Wn0ylysDbypcWjT4uKychITRK8 G8+Q== X-Gm-Message-State: AOJu0YwfIu6KWOC2A0bswlv3pgmvgXEs1sFUdIo2ZrLu4uPjsZEnPGRZ 1+WWmF5cUqfCHhqMg5gwXw== X-Received: by 2002:a50:d71a:0:b0:553:99fb:ae47 with SMTP id t26-20020a50d71a000000b0055399fbae47mr526017edi.27.1703057891414; Tue, 19 Dec 2023 23:38:11 -0800 (PST) Received: from alex-pc-ubuntu.lan (31-10-153-16.cgn.dynamic.upc.ch. [31.10.153.16]) by smtp.gmail.com with ESMTPSA id p7-20020a056402500700b0055283720ec3sm5979043eda.76.2023.12.19.23.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 23:38:11 -0800 (PST) From: Aleksandrs Vinarskis To: tiwai@suse.de Cc: alex.vinarskis@gmail.com, alsa-devel@alsa-project.org, david.rhodes@cirrus.com, james.schulman@cirrus.com, josbeir@gmail.com, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com, perex@perex.cz, sbinding@opensource.cirrus.com, stuarth@opensource.cirrus.com, tiwai@suse.com Subject: [PATCH v2 1/2] ALSA: hda: cs35l41: Safety-guard against capped SPI speed Date: Wed, 20 Dec 2023 08:38:08 +0100 Message-Id: <20231220073809.22027-2-alex.vinarskis@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231220073809.22027-1-alex.vinarskis@gmail.com> References: <87ttokpyws.wl-tiwai@suse.de> <20231220073809.22027-1-alex.vinarskis@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some devices with intel-lpss based SPI controllers may have misconfigured clock divider due to firmware bug. This would result in capped SPI speeds, which leads to longer DSP firmware loading times. This safety guards against possible hangs during wake-up by not initializing the device if lpss was not patched/fixed UEFI was not installed Signed-off-by: Aleksandrs Vinarskis --- sound/pci/hda/cs35l41_hda_property.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda_property.c b/sound/pci/hda/cs35l41_hda_property.c index c9eb70290973..cb305b093311 100644 --- a/sound/pci/hda/cs35l41_hda_property.c +++ b/sound/pci/hda/cs35l41_hda_property.c @@ -210,6 +210,19 @@ static int generic_dsd_config(struct cs35l41_hda *cs35l41, struct device *physde if (cfg->bus == SPI) { cs35l41->index = id; + /* + * Some devices with intel-lpss based SPI controllers may have misconfigured + * clock divider due to firmware bug. This would result in capped SPI speeds, + * which leads to longer DSP firmware loading times. + * Avoid initializing device if lpss was not patched/fixed UEFI was not installed + */ + spi = to_spi_device(cs35l41->dev); + if (spi->max_speed_hz < CS35L41_SPI_MAX_FREQ/2) { + dev_err(cs35l41->dev, + "SPI's max_speed_hz is capped at %u Hz, will not continue to avoid hanging\n", + spi->max_speed_hz); + return -EINVAL; + } /* * Manually set the Chip Select for the second amp in the node. * This is only supported for systems with 2 amps, since we cannot expand the @@ -219,8 +232,6 @@ static int generic_dsd_config(struct cs35l41_hda *cs35l41, struct device *physde * first. */ if (cfg->cs_gpio_index >= 0) { - spi = to_spi_device(cs35l41->dev); - if (cfg->num_amps != 2) { dev_warn(cs35l41->dev, "Cannot update SPI CS, Number of Amps (%d) != 2\n", -- 2.40.1