Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FE53C43387 for ; Wed, 19 Dec 2018 17:27:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BAA6920989 for ; Wed, 19 Dec 2018 17:27:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nextdimension.cc header.i=@nextdimension.cc header.b="QYYsFrfz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730411AbeLSR1M (ORCPT ); Wed, 19 Dec 2018 12:27:12 -0500 Received: from bonobo.maple.relay.mailchannels.net ([23.83.214.22]:28129 "EHLO bonobo.maple.relay.mailchannels.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728582AbeLSR1L (ORCPT ); Wed, 19 Dec 2018 12:27:11 -0500 X-Sender-Id: dreamhost|x-authsender|brad@b-rad.cc Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 64AFE123F92; Wed, 19 Dec 2018 17:27:03 +0000 (UTC) Received: from pdx1-sub0-mail-a53.g.dreamhost.com (unknown [100.96.36.160]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B919D1241B8; Wed, 19 Dec 2018 17:27:02 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|brad@b-rad.cc Received: from pdx1-sub0-mail-a53.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Wed, 19 Dec 2018 17:27:03 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|brad@b-rad.cc X-MailChannels-Auth-Id: dreamhost X-Arch-Abiding: 492d1b4e048d5e7d_1545240423224_3091080074 X-MC-Loop-Signature: 1545240423224:1887303933 X-MC-Ingress-Time: 1545240423223 Received: from pdx1-sub0-mail-a53.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a53.g.dreamhost.com (Postfix) with ESMTP id 2FC0C80430; Wed, 19 Dec 2018 09:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=nextdimension.cc; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s= nextdimension.cc; bh=YilCur7J++d5rxxJ+oIeBQSKhy4=; b=QYYsFrfz7cd 9rDkZkhSSx8uvuxvGPZCzjS4yJMzQ2J97FBxXjHZOK9hX+zdlg7SQKXZv23eLvdg Do7mvwPzAq+tNwJAecERcmPCb9dxwsJL9+B6r3KXnd1kj3fdcBCIqrYepy68Lt8M BgkNeUl5TSlssO1AjpV0Or9FacC/PYy8= Received: from [192.168.0.21] (66-90-189-166.dyn.grandenetworks.net [66.90.189.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: brad@b-rad.cc) by pdx1-sub0-mail-a53.g.dreamhost.com (Postfix) with ESMTPSA id 12B7980413; Wed, 19 Dec 2018 09:27:00 -0800 (PST) Subject: Re: [PATCH v2] cx23885: only reset DMA on problematic CPUs To: Alex Deucher , Brad Love Cc: linux-media , mchehab@kernel.org, Markus Dobel References: <20181206173204.21b9366e@coco.lan> <1545173976-16992-1-git-send-email-brad@nextdimension.cc> X-DH-BACKEND: pdx1-sub0-mail-a53 From: Brad Love Openpgp: preference=signencryp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0waLkrA0U7vJ3PiVEhJR/3u6F5FFgcUMMgOkps2j3IfWmdt4 c4p7tHTWtONMiMv65fQoTN03vfAmluInHcNsmtJaZjCW4mINpKYp5z+tABEBAAGJAh8EGAEI AAkFAljBn7UCGwwACgkQnzntUMfs450Yzg//d385d7DYyA4pH5maHEZVV86CDm2dSSHo262J 55eH49++ox8xbe3Ov46T5eKVkBVBQ99OacO2dLkzsMfngC+vM6TeqR1JVy62wmNaccy7HDBa aMdrIM0AnWABbOR4K5i2jAGcoXIlbDtRZ0Rnrp6Ql7Ah/SvdymD0qOh0Rs4+tI+ujN9OPNU3 BR2DFUKl3+X1T9RvPwX2egLSTG672hi99noLhFzqz/G8ae5ylMIJMvKzR3tUOApwOgd62e3K 1q+wDo4C7+DgLazGknZnjn/4eKJBah27njKr44qVx0CG4dCazkBwlwqKZEzqKLKo8PlyOHwA sQCREcTcE7lFsrf7z/G7PaluElEm5mH5uVFSWDYQzn6ZX18hjGuW+hkRgy1k/246X+D6FG+W MJu0Divd5Cd+Ly7cMF2WT3NQYET5Ma75h1JxTyXQ9HNQqumy0kyws4EL9ARaZDYO3F5JwkKK Om93LaUGEs5Cqb/hUv9k6eqjjQre9mB0ImDsGXkuuP0X6eN6yrstcaPAYl82NW+PGJ1Zz2ai AHkvsjIskeau68XRcm301QJI3qAZghhD7uJUH/NWBlr+w+F9vLlCgKvJLpahrd3PGHwgJnfV 1qqhouQNjsUrwpkXdQjTbSwtZaDPzCeSUSMArNjQMp21IYg/LhafLMzBqVODgaTsFDuVyRg= Message-ID: Date: Wed, 19 Dec 2018 11:26:59 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-GB X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -85 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejtddguddtudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdduhedmnecujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomhepuehrrgguucfnohhvvgcuoegsrhgrugesnhgvgihtughimhgvnhhsihhonhdrtggtqeenucffohhmrghinhepohhpvghnsggvnhgthhhmrghrkhhinhhgrdhorhhgnecukfhppeeiiedrledtrddukeelrdduieeinecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopegludelvddrudeikedrtddrvddungdpihhnvghtpeeiiedrledtrddukeelrdduieeipdhrvghtuhhrnhdqphgrthhhpeeurhgrugcunfhovhgvuceosghrrggusehnvgigthguihhmvghnshhiohhnrdgttgeqpdhmrghilhhfrhhomhepsghrrggusehnvgigthguihhmvghnshhiohhnrdgttgdpnhhrtghpthhtoheprghlvgiguggvuhgthhgvrhesghhmrghilhdrtghomhenucevlhhushhtvghrufhiiigvpedt Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Alex, On 18/12/2018 17.49, Alex Deucher wrote: > On Tue, Dec 18, 2018 at 5:59 PM Brad Love wrote: >> 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 >> --- >> Changes since v1: >> - Added module option for three way control >> - Removed '7' from pci id description, Ryzen 3 is the same id >> >> drivers/media/pci/cx23885/cx23885-core.c | 54 ++++++++++++++++++++++++++++++-- >> drivers/media/pci/cx23885/cx23885.h | 2 ++ >> 2 files changed, 54 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c >> index 39804d8..fb721c7 100644 >> --- 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 "); >> MODULE_LICENSE("GPL"); >> MODULE_VERSION(CX23885_VERSION); >> >> +/* >> + * Some platforms have been found to require periodic resetting of the DMA >> + * engine. Ryzen and XEON platforms are known to be affected. The symptom >> + * encountered is "mpeg risc op code error". Only Ryzen platforms employ >> + * this workaround if the option equals 1. The workaround can be explicitly >> + * disabled for all platforms by setting to 0, the workaround can be forced >> + * on for any platform by setting to 2. >> + */ >> +static unsigned int dma_reset_workaround = 1; >> +module_param(dma_reset_workaround, int, 0644); >> +MODULE_PARM_DESC(dma_reset_workaround, "periodic RiSC dma engine reset; 0-force disable, 1-driver detect (default), 2-force enable"); >> + >> static unsigned int debug; >> module_param(debug, int, 0644); >> MODULE_PARM_DESC(debug, "enable debug messages"); >> @@ -603,8 +616,13 @@ static void cx23885_risc_disasm(struct cx23885_tsport *port, >> >> static void cx23885_clear_bridge_error(struct cx23885_dev *dev) >> { >> - uint32_t reg1_val = cx_read(TC_REQ); /* read-only */ >> - uint32_t reg2_val = cx_read(TC_REQ_SET); >> + uint32_t reg1_val, reg2_val; >> + >> + if (!dev->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,36 @@ void cx23885_gpio_enable(struct cx23885_dev *dev, u32 mask, int asoutput) >> /* 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 }, > Does this issue only happen with the IOMMU is enabled? Is it only for > p2p transfers? Until recently the DMA and PCI subsystems didn't > actually support p2p properly when the IOMMU was enabled. that might > explain some of the issues. Additionally, if you match based on the > IOMMU id, you won't match if the user disables the IOMMU in the sbios. > Is this only an issue with the IOMMU enabled? > > Alex I'm unsure of the answers to your questions. I do still have my Ryzen3 system around, I'll see if I can disable IOMMU and do some tests. Regards, Brad >> +}; >> + >> +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 < sizeof(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 +2117,8 @@ static int cx23885_initdev(struct pci_dev *pci_dev, >> 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; >> diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h >> index d54c7ee..cf965ef 100644 >> --- 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) >> -- >> 2.7.4 >>