Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp144946imd; Wed, 31 Oct 2018 16:13:07 -0700 (PDT) X-Google-Smtp-Source: AJdET5e9p3L1H/FJ48/INrX7BfJO0GXIDiuj/1Cjst9Btkl7kKmfJklUTPN5ciCSB/xZMtUBtq0j X-Received: by 2002:a17:902:4624:: with SMTP id o33-v6mr5317192pld.285.1541027587937; Wed, 31 Oct 2018 16:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541027587; cv=none; d=google.com; s=arc-20160816; b=GxgpVvSQ1plrvhMV6+DMQJFnR4Gr4/CxZqjwz6AI+A7lxnKVNuhuDdT9A9hTtgimI0 6Mch1UZkMmNZo+ZZN2unLjzYVL4jhTu56R8oGfaCoUS6hfO6XoZZCCAK5iXQ61h2Dvg0 d9Jo4/CJ6dn6pq/7O6zTMH4+/9je17Lo/bv1VrcEZPu4x8u5wmN/7UG20pT0AS6gupd4 69Xd3Cm8pGZpQ91Rd9OSi3IMPIw867jui5Y65PEY68UDitSRAo9IdNBo8pTwYJmznFXU D2+X+NgvHEnFx8A3djtsJh1HvCNu0BDYtGmtZuN93FaVWl8x3gfwTPa2kU39Jjy2yDVL Udsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=yh7xTPU28yTGtDcsm91T0fezbAQ9kV+fVpa/vZFo6qY=; b=oy1XSUtCMMUhQpZ2PufPDkgFvn5LE9quh/Bi7msE1U8dA7Uyo8m/1ODlHh6WAMjhjw QfC3SunO5EqkPsE4QS9z2u04qb/I2lyg/MyaPDGO35bae2Ugu+m+1zmUp0ueYFTMkKQA OzXngfYfi2rJ3IuYcS898DwGQmNDKoQy0IIFPxeB29vpdEk3Hk7bepgEUIMq+CeUX6Ef /StqIRP3zlkA4CTJBxyTAZUKbj8AYoiqr1DUun3HATPj7a+CGGP4qd25qDQKwc91/wys hvJ32lY0qmSRZJLqBBTdfTkRuQw0lX472U3IYfGDwwF94LEA7f+MDS7cmsAP2PeU/Ja0 xhjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tuhlzLSv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 10-v6si20452722pgk.480.2018.10.31.16.12.53; Wed, 31 Oct 2018 16:13:07 -0700 (PDT) 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=tuhlzLSv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732201AbeKAIMU (ORCPT + 99 others); Thu, 1 Nov 2018 04:12:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:37070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732144AbeKAIMT (ORCPT ); Thu, 1 Nov 2018 04:12:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C3D1220840; Wed, 31 Oct 2018 23:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027526; bh=8md8agzMmlsqjxC+vUx51MUiHf9HtsrfFvrjDkd3nd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tuhlzLSvyewWoHvPbo0s5RdHkTVlmy2az1hU/FyibrDSYc/it10VzCHcsHlGDygnS FE4eAqX9qw0q8TnPjCRSLbkt8lPZkIJQjrirmtA6gEwvurtARhef3f2b4RlURLk0HB PI5l2oMetKWVm+FIonjFhBgmyO5c3pkv2N3veAqU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH AUTOSEL 4.4 32/32] ALSA: hda: Check the non-cached stream buffers more explicitly Date: Wed, 31 Oct 2018 19:11:37 -0400 Message-Id: <20181031231137.29429-32-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031231137.29429-1-sashal@kernel.org> References: <20181031231137.29429-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- sound/pci/hda/hda_controller.h | 1 + sound/pci/hda/hda_intel.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h index b17539537b2e..55ec4470f6b6 100644 --- 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 */ diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 95a82e428f37..ecb07fb036af 100644 --- 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 *chip, struct snd_dma_buffer *dmab, bool #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(struct azx *chip) 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(struct azx *chip) 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_pcm_substream *substream, #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 } -- 2.17.1