From patchwork Tue May 8 21:20:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Love X-Patchwork-Id: 10387539 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2116602D8 for ; Tue, 8 May 2018 21:21:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F308C28E7D for ; Tue, 8 May 2018 21:21:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E76C328EA4; Tue, 8 May 2018 21:21:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AABC28E7D for ; Tue, 8 May 2018 21:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755714AbeEHVVT (ORCPT ); Tue, 8 May 2018 17:21:19 -0400 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:44799 "EHLO homiemail-a116.g.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755927AbeEHVU0 (ORCPT ); Tue, 8 May 2018 17:20:26 -0400 Received: from homiemail-a116.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a116.g.dreamhost.com (Postfix) with ESMTP id AA9A06000794B; Tue, 8 May 2018 14:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=nextdimension.cc; h=from :to:cc:subject:date:message-id:in-reply-to:references; s= nextdimension.cc; bh=GIsXEDeGzIzX7cvAqD3ZeUuifJ0=; b=lFasMUNCeKP v8n7dblkjg8TH0NSn5e99iBj/Xpk0nYH4apAxVKj5oJ/S2aQFpeLO4R2o7hkg/ad GbTT9Vt48/kUoY7jF6LfpZNfjErtsFLtYGkahRsqZ+CrnfO5xQfmGsHB6NUVwQ2V dFjd2un0dyocFx7bYTD8EG37zFHKPoO4= Received: from localhost.localdomain (66-90-189-166.dyn.grandenetworks.net [66.90.189.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: brad@nextdimension.ws) by homiemail-a116.g.dreamhost.com (Postfix) with ESMTPSA id 596DC6000794C; Tue, 8 May 2018 14:20:25 -0700 (PDT) From: Brad Love To: linux-media@vger.kernel.org, mchehab@kernel.org, mspieth@digivation.com.au Cc: Brad Love Subject: [PATCH 1/5] cx23885: Handle additional bufs on interrupt Date: Tue, 8 May 2018 16:20:16 -0500 Message-Id: <1525814420-25243-2-git-send-email-brad@nextdimension.cc> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525814420-25243-1-git-send-email-brad@nextdimension.cc> References: <1525814420-25243-1-git-send-email-brad@nextdimension.cc> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Ryzen systems interrupts are occasionally missed: cx23885: cx23885_wakeup: [ffff99b384b83c00/28] wakeup reg=5406 buf=5405 cx23885: cx23885_wakeup: [ffff99b40bf79400/31] wakeup reg=9537 buf=9536 This patch loops up to five times on wakeup, marking any buffers found done. Since the count register is u16, but the vb2 counter is u32, some modulo arithmetic is used to accommodate wraparound and ensure current active buffer is the buffer expected. Signed-off-by: Brad Love --- drivers/media/pci/cx23885/cx23885-core.c | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c index 019fac4..b279758 100644 --- a/drivers/media/pci/cx23885/cx23885-core.c +++ b/drivers/media/pci/cx23885/cx23885-core.c @@ -422,19 +422,30 @@ static void cx23885_wakeup(struct cx23885_tsport *port, struct cx23885_dmaqueue *q, u32 count) { struct cx23885_buffer *buf; - - if (list_empty(&q->active)) - return; - buf = list_entry(q->active.next, - struct cx23885_buffer, queue); - - buf->vb.vb2_buf.timestamp = ktime_get_ns(); - buf->vb.sequence = q->count++; - dprintk(1, "[%p/%d] wakeup reg=%d buf=%d\n", buf, - buf->vb.vb2_buf.index, - count, q->count); - list_del(&buf->queue); - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + int count_delta; + int max_buf_done = 5; /* service maximum five buffers */ + + do { + if (list_empty(&q->active)) + return; + buf = list_entry(q->active.next, + struct cx23885_buffer, queue); + + buf->vb.vb2_buf.timestamp = ktime_get_ns(); + buf->vb.sequence = q->count++; + if (count != (q->count % 65536)) { + dprintk(1, "[%p/%d] wakeup reg=%d buf=%d\n", buf, + buf->vb.vb2_buf.index, count, q->count); + } else { + dprintk(7, "[%p/%d] wakeup reg=%d buf=%d\n", buf, + buf->vb.vb2_buf.index, count, q->count); + } + list_del(&buf->queue); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + max_buf_done--; + /* count register is 16 bits so apply modulo appropriately */ + count_delta = ((int)count - (int)(q->count % 65536)); + } while ((count_delta > 0) && (max_buf_done > 0)); } int cx23885_sram_channel_setup(struct cx23885_dev *dev,