From patchwork Thu Aug 19 06:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1518436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GqvdS4fXMz9sVw; Thu, 19 Aug 2021 16:15:24 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mGbKh-0000GZ-5n; Thu, 19 Aug 2021 06:15:19 +0000 Received: from mail-pg1-f173.google.com ([209.85.215.173]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mGbKF-0008NE-VY for kernel-team@lists.ubuntu.com; Thu, 19 Aug 2021 06:14:52 +0000 Received: by mail-pg1-f173.google.com with SMTP id n18so4882900pgm.12 for ; Wed, 18 Aug 2021 23:14:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qXfajp0TEh4fwlZMvTXTWu3mSWqgxc1FFtm3LT0V9vc=; b=rfPqEeKiPQNOP+KXIrgh1b4ExFQe5f70SAw7cYO2YytlzeK9exbkrsTibEEfMgmNGj 6pBH188f0wjIP/IoolDU3GIp6iDjlqDc3FvxDwSA4iELpwn1hA7S/KIofL2+S2rmPOYr a+wB6ehzx3EHzHhhJSsaKz0Cy1b59bRA/EnBVnOdLchH7EW70IMFSOWq25Oc8sVtLVMg JyaiOYLSJvkWobSk60N56m5Xm+xJNIL/6X309ZVA6Ipk2N5Ik7B3cNp9TL/Hq1VtgO92 ujXXiGT4k+bkPOXBqHsZd93RVaf+SL0HCJgqs9tpgp79gX7XF3F5c1xVIfy/KdEGKhJI 7L1g== X-Gm-Message-State: AOAM532yzLis4ctY4wu67ddprXUikOxuKs1ClIHeyMuYPDmhbxSGalXs 8IwfWL3Zv1pzJVodBmvUJQfuI/y4aF/oIg== X-Google-Smtp-Source: ABdhPJwE+KEKPQUveKCpA5qA4y2D1XnmunVjesywY2tWT98/EPSHVaSk+/PVJSEEZLYM/RUxEfI+KQ== X-Received: by 2002:a63:7883:: with SMTP id t125mr12467440pgc.243.1629353689926; Wed, 18 Aug 2021 23:14:49 -0700 (PDT) Received: from localhost (114-47-140-65.dynamic-ip.hinet.net. [114.47.140.65]) by smtp.gmail.com with ESMTPSA id t14sm2195567pga.62.2021.08.18.23.14.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 23:14:49 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 11/30][SRU][OEM-5.13][I][U] ALSA: hda/cs8409: Prevent I2C access during suspend time Date: Thu, 19 Aug 2021 14:14:07 +0800 Message-Id: <20210819061427.900601-12-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210819061427.900601-1-vicamo.yang@canonical.com> References: <20210819061427.900601-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.215.173; envelope-from=vicamo@gmail.com; helo=mail-pg1-f173.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Lucas Tanure BugLink: https://bugs.launchpad.net/bugs/1939541 Signed-off-by: Lucas Tanure Signed-off-by: Vitaly Rodionov Link: https://lore.kernel.org/r/20210811185654.6837-12-vitalyr@opensource.cirrus.com Signed-off-by: Takashi Iwai (cherry picked from commit a1a6c7df2b2e9e2291e4c1c621b6092b07777934) Signed-off-by: You-Sheng Yang --- sound/pci/hda/patch_cs8409.c | 14 ++++++++++++++ sound/pci/hda/patch_cs8409.h | 1 + 2 files changed, 15 insertions(+) diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c index 4ad832f5c4ba..0b13bcecd778 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -127,9 +127,13 @@ static int cs8409_i2c_wait_complete(struct hda_codec *codec) static int cs8409_i2c_read(struct hda_codec *codec, unsigned int i2c_address, unsigned int i2c_reg, unsigned int paged) { + struct cs8409_spec *spec = codec->spec; unsigned int i2c_reg_data; unsigned int read_data; + if (spec->cs42l42_suspended) + return -EPERM; + cs8409_enable_i2c_clock(codec, 1); cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, i2c_address); @@ -172,8 +176,12 @@ static int cs8409_i2c_read(struct hda_codec *codec, unsigned int i2c_address, un static int cs8409_i2c_write(struct hda_codec *codec, unsigned int i2c_address, unsigned int i2c_reg, unsigned int i2c_data, unsigned int paged) { + struct cs8409_spec *spec = codec->spec; unsigned int i2c_reg_data; + if (spec->cs42l42_suspended) + return -EPERM; + cs8409_enable_i2c_clock(codec, 1); cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, i2c_address); @@ -371,6 +379,8 @@ static void cs8409_cs42l42_reset(struct hda_codec *codec) /* wait ~10ms */ usleep_range(10000, 15000); + spec->cs42l42_suspended = 0; + mutex_lock(&spec->cs8409_i2c_mux); /* Clear interrupts, by reading interrupt status registers */ @@ -594,6 +604,9 @@ static int cs8409_suspend(struct hda_codec *codec) /* Power down CS42L42 ASP/EQ/MIX/HP */ cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1101, 0xfe, 1); mutex_unlock(&spec->cs8409_i2c_mux); + + spec->cs42l42_suspended = 1; + /* Assert CS42L42 RTS# line */ snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, 0); @@ -759,6 +772,7 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix, spec->cs42l42_hp_jack_in = 0; spec->cs42l42_mic_jack_in = 0; + spec->cs42l42_suspended = 1; /* Basic initial sequence for specific hw configuration */ snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs); diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h index 1d3ce28415fa..0f2084b6ec8e 100644 --- a/sound/pci/hda/patch_cs8409.h +++ b/sound/pci/hda/patch_cs8409.h @@ -269,6 +269,7 @@ struct cs8409_spec { unsigned int cs42l42_hp_jack_in:1; unsigned int cs42l42_mic_jack_in:1; unsigned int cs42l42_volume_init:1; + unsigned int cs42l42_suspended:1; char cs42l42_hp_volume[CS42L42_HP_CH]; char cs42l42_hs_mic_volume[CS42L42_HS_MIC_CH];