Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2983067imu; Mon, 19 Nov 2018 08:58:44 -0800 (PST) X-Google-Smtp-Source: AJdET5fzyfl2raETWasuv6wWi3A0MreV0WH/GhegcGL89kUNBsLWI9vGOu0NuvIyHRjFGJE2W4g6 X-Received: by 2002:a63:4c6:: with SMTP id 189mr20996949pge.391.1542646724250; Mon, 19 Nov 2018 08:58:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542646724; cv=none; d=google.com; s=arc-20160816; b=lFg7nJmmcUuA+3YNFOF2n5NRrRD7DD2t0Sh78vx/ttVZ0WIwvpX4rYA/VkLdWb3UZU HXI9+T7l6b8gsXSvGIAo1DDzbHKUgYPK7ZTopkukEA/r0LkXemdeVlLvwmVEW4o+LWR4 RL21U5lm5pgwLZmfg5VYzePxFOGhl7fzVoJ1952G33nNuseZbx1xtWycYGKP3PIJqzQ4 Syj5Jx0uCPR4KR9oEtede1M13VLQiNJd1sGNK7PBx+y3hrd1lT5uTpJ26uqUiblgsQD6 uGFrgFhv0Ib5eP91O3r/5bkp8/xQuUmUT+HoHxl00SyAEl1SjH+X0P2Ki3whpUtkrrTC DjhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m+2NmU8NyXSekFLTdcnB38TBHmqUhqoWl+UA89iRzhI=; b=RcJ9kxjQYHpRB7nlyDDbaBVLdNYR6iZBFSLiNoamHoLGjO6ynFGwlVrxETFMY0ISH/ 6RtyBrWs782am22zB/HF6iX8QQ7D9bm56QTPemWJDXWv5Ow8C7USFVhbswzQPuUn7Ont uWxt7jZHPE5O/j6co0Af88cSFco4TCO5MtCLqChxTbWuq6FYOgZRFOUYoDJkO9Gb1wAE gzIC4ww6RRHkLmXG5kWuQpQ+mbjSpFU48CJ7pQ90HUuhU1uVKQJERt57g5n1QnMi8ULP PDsZ2SQovuBhV+6xUU4ZKg+AXgwR/ZIX7UIBBFCMCOVGCXRK1HUbTpcVBZPgM/irgyqB WYow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S6He4crp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si17202373pgh.583.2018.11.19.08.58.28; Mon, 19 Nov 2018 08:58:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S6He4crp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404621AbeKTDWA (ORCPT + 99 others); Mon, 19 Nov 2018 22:22:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:33528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403956AbeKTDV7 (ORCPT ); Mon, 19 Nov 2018 22:21:59 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0F1DC208E3; Mon, 19 Nov 2018 16:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646664; bh=KaCNKKTcdGEn8f/JBSXxA5a/vEc30L98hybhqQchjX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6He4crpEM1FbJd6H6Z/PTEPwQSnPyZrWUWaEMOjsV33w8IdVyqse0YgmOMPOKPsO OzXuyRUWZVuM/6kujalrgN3w4JJPbMqwaf4rmfhNxSAk1d+GCleMua07dWAnHFekUY I8BS2s7+CDj/Avgli2TOFBk6ejtfhdgL0c3k/KKA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Sasha Levin Subject: [PATCH 4.4 043/160] ALSA: hda: Check the non-cached stream buffers more explicitly Date: Mon, 19 Nov 2018 17:28:02 +0100 Message-Id: <20181119162635.538141738@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162630.031306128@linuxfoundation.org> References: <20181119162630.031306128@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai [ Upstream commit 78c9be61c3a5cd9e2439fd27a5ffad73a81958c7 ] Introduce a new flag, uc_buffer, to indicate that the controller requires the non-cached pages for stream buffers, either as a chip-specific requirement or specified via snoop=0 option. This improves the code-readability. Also, this patch fixes the incorrect behavior for C-Media chip where the stream buffers were never handled as non-cached due to the check of driver_type even if you pass snoop=0 option. Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/hda_controller.h | 1 + sound/pci/hda/hda_intel.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) --- a/sound/pci/hda/hda_controller.h +++ b/sound/pci/hda/hda_controller.h @@ -151,6 +151,7 @@ struct azx { unsigned int msi:1; unsigned int probing:1; /* codec probing phase */ unsigned int snoop:1; + unsigned int uc_buffer:1; /* non-cached pages for stream buffers */ unsigned int align_buffer_size:1; unsigned int region_requested:1; unsigned int disabled:1; /* disabled by vga_switcheroo */ --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -401,7 +401,7 @@ static void __mark_pages_wc(struct azx * #ifdef CONFIG_SND_DMA_SGBUF if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) { struct snd_sg_buf *sgbuf = dmab->private_data; - if (chip->driver_type == AZX_DRIVER_CMEDIA) + if (!chip->uc_buffer) return; /* deal with only CORB/RIRB buffers */ if (on) set_pages_array_wc(sgbuf->page_table, sgbuf->pages); @@ -1538,6 +1538,7 @@ static void azx_check_snoop_available(st dev_info(chip->card->dev, "Force to %s mode by module option\n", snoop ? "snoop" : "non-snoop"); chip->snoop = snoop; + chip->uc_buffer = !snoop; return; } @@ -1558,8 +1559,12 @@ static void azx_check_snoop_available(st snoop = false; chip->snoop = snoop; - if (!snoop) + if (!snoop) { dev_info(chip->card->dev, "Force to non-snoop mode\n"); + /* C-Media requires non-cached pages only for CORB/RIRB */ + if (chip->driver_type != AZX_DRIVER_CMEDIA) + chip->uc_buffer = true; + } } static void azx_probe_work(struct work_struct *work) @@ -1958,7 +1963,7 @@ static void pcm_mmap_prepare(struct snd_ #ifdef CONFIG_X86 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct azx *chip = apcm->chip; - if (!azx_snoop(chip) && chip->driver_type != AZX_DRIVER_CMEDIA) + if (chip->uc_buffer) area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); #endif }