Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3480911imu; Sun, 11 Nov 2018 16:04:51 -0800 (PST) X-Google-Smtp-Source: AJdET5cxilSlD9GIgYry53fxEjT6mvQN0LvhN4+axK0RgRDZ8zNMlC/Rn2Y4We2oapCYTfGz7S2K X-Received: by 2002:a17:902:1e3:: with SMTP id b90-v6mr14888513plb.117.1541981091264; Sun, 11 Nov 2018 16:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981091; cv=none; d=google.com; s=arc-20160816; b=YGrnHYAqRy8WHm+jtHgP+d4bcLRTvFU3tCBbYNLPnzaDIA7JNoWhtTEdwVc0PFIIj6 JRyEbG5Jrwe4u6rzqWxz6A8ZAPyoBQWZX4NfbwwC5LOzzV/abNN0LmnyLl9f1CDKTAeC TIGUmvNCVC1r5JSND7hSYueMC12sUpI+ZmulrvFKjzQ7/tjP4JO50V5bztaF+ImYn7ZJ TFq6pfjUE6SmFgvn0+AqBk4PYxUvfyGoNodfLN7ikFWgVB3st6L7izEyL9K8aNCsHc3o kEpea7Bbz5waPAWmrUe1mIRsZ5HCxVEzbSJMnLu0EQuw5QB2cp5KK+DBv08g+/ApuFea tNZQ== 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=wn2ce8rQLZUxuI2bGldbjFlJABFLNuIWBb/Imyvnki0=; b=u07H1s0MJIh/ZXpYnYJVtL39u0f7B1aivWZfcOXxZ8CaJdduCBnZ0UViXUjeIsC+RF BoBJr4xyuRUqyQvaIPTonpbiZ1H0QPKd6cj+SuqiS+Us7halqOjOdAE1KMuz4vzMYNbn J4+NyTjoPLf+EGF6GnvsqJe/CqRB+ZboQA1Gv49PW1HAmAO0XbxAbc0FH6Nu78ELZOgN 3nrT2Tbt4kIrWPQ7kohlxTHcXAT1UdpRFnoP5a9fVDXqcKtunXV1RkS3P3CQoFvppMdV HTyh9W7WJroQVbihj0WXE3u9QnvnHrxsWpKnU08HkgtkHVeWC973O603nWQtiD8Gc3de F8SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pivD053I; 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 b3-v6si17739644pfh.233.2018.11.11.16.04.36; Sun, 11 Nov 2018 16:04:51 -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=pivD053I; 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 S1732263AbeKLJxN (ORCPT + 99 others); Mon, 12 Nov 2018 04:53:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:34236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732146AbeKLIRw (ORCPT ); Mon, 12 Nov 2018 03:17:52 -0500 Received: from localhost (unknown [206.108.79.134]) (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 326D821508; Sun, 11 Nov 2018 22:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975277; bh=r0sdvK0aUyzR9mfEDE3pLJRWfvRFrW5uUucnb5QatRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pivD053IG0vzrb+bmq0MJ/0jPrDCY6ctSPSnhiUt9fX7iy7FStmEaYCklKk2RGCtd Ux38pKAUaiBHvDDZsr8yJpBfO364TlWwBi7nrsrm22umXOX4hUPcMza/wdseXZCy0l UErw+kgBo3AcIGYS1Kz9fp+y8XTqvyRD5RxjaDCI= 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.19 190/361] ALSA: hda: Check the non-cached stream buffers more explicitly Date: Sun, 11 Nov 2018 14:18:57 -0800 Message-Id: <20181111221647.124705546@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -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 */ --- 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 * #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(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; } @@ -1698,8 +1699,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) @@ -2138,7 +2143,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 }