Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp646451imu; Fri, 11 Jan 2019 06:44:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN55ocNPsziSLZioo+elBlqAy09DBFsTqw7CfJsiDKV/auWx8pCP+Xb5MlgB7Rl18HuOUjBB X-Received: by 2002:a62:cd1:: with SMTP id 78mr14811279pfm.219.1547217890090; Fri, 11 Jan 2019 06:44:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547217890; cv=none; d=google.com; s=arc-20160816; b=ryLitj+MOtbDSbVVriu/fGsFxXd9Hwu9pm8oQg4ZYDZOTRg6ihaGbUyykkz2tAfDaT tnq940aGpHIS+8ob1opDpJwKJQ+pV6AMJw1WmPszD41oXHKNZdWLLS8jkdHtQdFJL1a2 KVK3XVFHQSms0Hqi99cppVSaFs+tqizBNhwz4UZXRf8vKS2//zsavPC4Vh9NUnOSL1oj C9Ky/ZC3CJMPscilw83SYvE3SdXK7RtW35QjVYsEu6XiSGtP59ibJrVaEDU41EoNA7Ey BxWcj0UgB3ilgnCGWl6d5ufdbSKIqdc0nUa6HS/Aoe+fKBB4Yo+EAzRZFthAe2Zr826V /GKw== 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=xO6oae3UPGZOnDIKGhHWX6CNXlwRXZK2yjAaJ+06jck=; b=kBW55/1ovnzM51A9wbajzPrB0qyDPAhhGC+geO7H5WkS+TrJ4mzt9znVw8RWyU+ubV FgwYIIVijXGBZTlYrIiKTfWnIuVPR3HriUYuFnnPArr7eUx5lcU/VkTK95dYi0AEo/FR HwR/MvUk/o9cynIIFYVvmha5R8mUraAYqsSfXYTqVWb+LIA5XXG7xGa0BImEreFtQ+v4 QMxS7BCNdoRNwjlvDxcH9dAmxdMOnlZildGyHVmuWYOVOh8ELdYeNjs3yziGZKLN3ITY AAyZ0a5vDOK16SQ1z9cU/z6vHYudTxRll9IttxmZLfYSkxpmgmcmg2zAc7CNgIlqhOOA xQ1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yif5pbWq; 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 z5si16989571pgu.19.2019.01.11.06.44.34; Fri, 11 Jan 2019 06:44:50 -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=yif5pbWq; 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 S2404096AbfAKOmB (ORCPT + 99 others); Fri, 11 Jan 2019 09:42:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:34802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404087AbfAKOmA (ORCPT ); Fri, 11 Jan 2019 09:42:00 -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 E55362063F; Fri, 11 Jan 2019 14:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217719; bh=uqi27+toaOnvsEtnS6W99/4xTxjYELkTAh8UP530LBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yif5pbWqceBgv8AZkCdcOlcn04uRz+AGUEgUkLlJlR0OOpBLW+KsbaVw8aip5Lh07 Hzu99g+mIwatUMu4QWodei4fW/1pzhFJqeJcmdcRUXLOfEC3PquFnSyJbuUUBK8wox /ETLk1gQ1352USeu+XAxsyLrpOUyn+sbuFY+IRSs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brad Love , Mauro Carvalho Chehab Subject: [PATCH 4.20 17/65] media: cx23885: only reset DMA on problematic CPUs Date: Fri, 11 Jan 2019 15:15:03 +0100 Message-Id: <20190111131058.815430757@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Brad Love commit 4bd46aa0353e022c2401a258e93b107880a66533 upstream. It is reported that commit 95f408bbc4e4 ("media: cx23885: Ryzen DMA related RiSC engine stall fixes") caused regresssions with other CPUs. Ensure that the quirk will be applied only for the CPUs that are known to cause problems. A module option is added for explicit control of the behaviour. Fixes: 95f408bbc4e4 ("media: cx23885: Ryzen DMA related RiSC engine stall fixes") Signed-off-by: Brad Love Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/pci/cx23885/cx23885-core.c | 55 +++++++++++++++++++++++++++++-- drivers/media/pci/cx23885/cx23885.h | 2 + 2 files changed, 55 insertions(+), 2 deletions(-) --- a/drivers/media/pci/cx23885/cx23885-core.c +++ b/drivers/media/pci/cx23885/cx23885-core.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,18 @@ MODULE_AUTHOR("Steven Toth need_dma_reset) + return; + + reg1_val = cx_read(TC_REQ); /* read-only */ + reg2_val = cx_read(TC_REQ_SET); if (reg1_val && reg2_val) { cx_write(TC_REQ, reg1_val); @@ -2058,6 +2076,37 @@ void cx23885_gpio_enable(struct cx23885_ /* TODO: 23-19 */ } +static struct { + int vendor, dev; +} const broken_dev_id[] = { + /* According with + * https://openbenchmarking.org/system/1703021-RI-AMDZEN08075/Ryzen%207%201800X/lspci, + * 0x1451 is PCI ID for the IOMMU found on Ryzen + */ + { PCI_VENDOR_ID_AMD, 0x1451 }, +}; + +static bool cx23885_does_need_dma_reset(void) +{ + int i; + struct pci_dev *pdev = NULL; + + if (dma_reset_workaround == 0) + return false; + else if (dma_reset_workaround == 2) + return true; + + for (i = 0; i < ARRAY_SIZE(broken_dev_id); i++) { + pdev = pci_get_device(broken_dev_id[i].vendor, + broken_dev_id[i].dev, NULL); + if (pdev) { + pci_dev_put(pdev); + return true; + } + } + return false; +} + static int cx23885_initdev(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) { @@ -2069,6 +2118,8 @@ static int cx23885_initdev(struct pci_de if (NULL == dev) return -ENOMEM; + dev->need_dma_reset = cx23885_does_need_dma_reset(); + err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev); if (err < 0) goto fail_free; --- a/drivers/media/pci/cx23885/cx23885.h +++ b/drivers/media/pci/cx23885/cx23885.h @@ -451,6 +451,8 @@ struct cx23885_dev { /* Analog raw audio */ struct cx23885_audio_dev *audio_dev; + /* Does the system require periodic DMA resets? */ + unsigned int need_dma_reset:1; }; static inline struct cx23885_dev *to_cx23885(struct v4l2_device *v4l2_dev)