Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp168617imd; Wed, 31 Oct 2018 16:42:09 -0700 (PDT) X-Google-Smtp-Source: AJdET5fNhyHzWsusLEY7ERfg3QUR49c8cKSNYRWSx2F/kGtZioHydW+5irca+iLi41woFc8uk/Aa X-Received: by 2002:a17:902:28a2:: with SMTP id f31-v6mr5380141plb.312.1541029329605; Wed, 31 Oct 2018 16:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029329; cv=none; d=google.com; s=arc-20160816; b=MFcUVY4Q9nXiJXRmRzj8XUW/IgGJ6fBO2Ofe0jvricrVt1CLXM9MycF0rdyC2YwO1Z uufIKOj43RSKPk3Ex18n4R1cysiSNogoo+gA2E6fnZUPzlCuq12ljhPdUJm9SlRv/7f3 E5H0DwcQ1iExfHnmYlaQdYufrdS91LzEupDww96pbLbwF652lZ3tnEe4v1ChbqDzzl4z Se3edDt72GN8iLZYbPxgl8RE9XUeNr8gR9nhJXWIQac3NHHbT4IIBEGTeUkECYn2Xpda 3eo6WkRgnDM7yl1mb8sjZQY5/K3ge8HTQoLM4hGfyVoU4061wX8o79q3JC6dCGLQ70WJ P9OA== 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=pu8nRrGMDQi68ogihHfy2fdLaAqpGDfYSMGnzqQZHsA=; b=qwWQLnm3PhCsxecainzlnidEfS5y2W3WXA/rLRxk9axLcK+sBXgPfyCLjPjL2QMXlw bmfpX8fDzmYkCzWu1xrudP239GCmNHsnRHw2lSoz3j51dBaaFHFasAy1sMSYYeHr5vVy aamw2Ih0mhm6DxRspgEthfW+NWVTFmbYWvOjD1tl1pB1IfYPwISHt5MCFaQ3oIPVCr6l dyrevnc8/N+lJu+jaLu1IfXbMORBkllkH3avf1sN2Mx11H/dv1zZkM73tpdM29mvQ4CZ 7mT/9KfYcmdP+x7i9L4aGe+iuAbhE4Pq9gXjtk0ulnK6sD8HZRvysZ1VXBdGoO4XGyMo j83Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yuOratOF; 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 33-v6si11655038plg.96.2018.10.31.16.41.54; Wed, 31 Oct 2018 16:42:09 -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=yuOratOF; 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 S1729622AbeKAIl4 (ORCPT + 99 others); Thu, 1 Nov 2018 04:41:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:56512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729304AbeKAIIE (ORCPT ); Thu, 1 Nov 2018 04:08:04 -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 CCA6D20843; Wed, 31 Oct 2018 23:07:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027273; bh=IPq/2lgfLKUrjyz9hFxEXVQvLlf+pd1XazmRXOghw7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yuOratOFibD6b5sxFBIvWk/avkyR07XYtZ62mK+QQ1DmyyS3uG+Rk9zGwqYRB6XRL eoltwoMTp4mmnBKSoN/7VnqrF2SFjUkXSVDClknbsvlBs4hO6Nuu6u9YYiCH9cq8Lb +9YL4x0v9l0FLF7X35kK7Lg9eBRRYMydIrnTlFyg= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH AUTOSEL 4.19 146/146] ALSA: hda: Check the non-cached stream buffers more explicitly Date: Wed, 31 Oct 2018 19:05:41 -0400 Message-Id: <20181031230541.28822-146-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-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 a68e75b00ea3..53c3cd28bc99 100644 --- a/sound/pci/hda/hda_controller.h +++ b/sound/pci/hda/hda_controller.h @@ -160,6 +160,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 aa4c672dbaf7..e54e8a552111 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -412,7 +412,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); @@ -1678,6 +1678,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; } @@ -1698,8 +1699,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) @@ -2138,7 +2143,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