From patchwork Sun Jun 17 14:36:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matwey V. Kornilov" X-Patchwork-Id: 10468937 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 BCE3A600F4 for ; Sun, 17 Jun 2018 14:37:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70EA328698 for ; Sun, 17 Jun 2018 14:37:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 648FD28770; Sun, 17 Jun 2018 14:37:29 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable 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 D550B28698 for ; Sun, 17 Jun 2018 14:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755347AbeFQOhJ (ORCPT ); Sun, 17 Jun 2018 10:37:09 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:44234 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752077AbeFQOgy (ORCPT ); Sun, 17 Jun 2018 10:36:54 -0400 Received: by mail-lf0-f66.google.com with SMTP id p23-v6so9242014lfh.11; Sun, 17 Jun 2018 07:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4HGJcUTd62dWLpX0OGv003PWyZ09geI3ZVsKo3Qqsm0=; b=YYWg0Mbcj6CRaemhVu7fULEBYrY89ALdV1qCquKBkHbnRCdQxGy0TUDboQMKGPGKIV HyeThqmm4ESZc0+ely9hzJdKGBQJPjbSfAJJ5uTzvecXpqNOTo6zlj4edRJnC8zG5hqP WtB+p8E0I6q6FBqskHd9g8lSJNamfri2EVuuwelEU+RGoHRVobC9LSR/TWf+z35EL9Sp FfTdsGGHvUCii0ZbvQg5SVRny4IDuLmAKKusxCR3Tr1NbUqc7TMV2O8k05fMdwYVQyQs oGBT/XRNHgEyU6NLyM2APIcyhZkHueaoq9iFH0Pyad0nIgT2yyaOgoWGYKkA8oZ1JiOr dyZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=4HGJcUTd62dWLpX0OGv003PWyZ09geI3ZVsKo3Qqsm0=; b=S7VLGiYp+5E60N/cwLM2F/ec41YGORmtPO5ugaJE0W7sFzFp3ELjImwWMXMgQZor6e PR7neTZ/WwPIWqevzhLXTkkV8QAeLhc6Q6r97n4YUMGIP8H6sVipqNyNda5tQLeR7M2x 7uJ1W4MvSqBJa7NII3NPopBTJI11L1Otyl+74az7oIRuAHIoyXWwcIc4A4Iuc6iR9eaT VoLO6geYPQlsZj9eF6SRnCBQt/EYz26dI8PT7dLL1rJbDh8Wc+3SFpPAV/zrqpGf66qn vQrAPC8OycY6kFgWMvHUbOfq/tmI8C+r7vgXED0IupJappgc7xPgMx/LXyIFAB3HvqFA MHvQ== X-Gm-Message-State: APt69E2o6cor0BFQOhT0GBE5+eb2LjNFKNomksTKUdfHSYHzRFtfnr2Z k1eLGknumRxYZKagnnuymsk= X-Google-Smtp-Source: ADUXVKKwH0agsods0X5mxBW4uNcliO9ZWMaCbXSqm63tibU1Ss5mfKHCScsktXfu0SjWVriTPtYjzw== X-Received: by 2002:a2e:1010:: with SMTP id j16-v6mr6118729lje.94.1529246212250; Sun, 17 Jun 2018 07:36:52 -0700 (PDT) Received: from linux-2y6e.local ([92.243.181.209]) by smtp.gmail.com with ESMTPSA id l19-v6sm2381120lfk.30.2018.06.17.07.36.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 07:36:51 -0700 (PDT) From: "Matwey V. Kornilov" To: hverkuil@xs4all.nl, mchehab@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, isely@pobox.com, bhumirks@gmail.com, colin.king@canonical.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, "Matwey V. Kornilov" Subject: [PATCH 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer Date: Sun, 17 Jun 2018 17:36:25 +0300 Message-Id: <20180617143625.32133-2-matwey@sai.msu.ru> X-Mailer: git-send-email 2.16.0-rc1 In-Reply-To: <20180617143625.32133-1-matwey@sai.msu.ru> References: <20180617143625.32133-1-matwey@sai.msu.ru> 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 DMA cocherency slows the transfer down on systems without hardware coherent DMA. Based on previous commit the following performance benchmarks have been carried out. Average memcpy() data transfer rate (rate) and handler completion time (time) have been measured when running video stream at 640x480 resolution at 10fps. x86_64 based system (Intel Core i5-3470). This platform has hardware coherent DMA support and proposed change doesn't make big difference here. * kmalloc: rate = (4.4 +- 1.0) GBps time = (2.4 +- 1.2) usec * usb_alloc_coherent: rate = (4.1 +- 0.9) GBps time = (2.5 +- 1.0) usec We see that the measurements agree well within error ranges in this case. So no performance downgrade is introduced. armv7l based system (TI AM335x BeagleBone Black). This platform has no hardware coherent DMA support. DMA coherence is implemented via disabled page caching that slows down memcpy() due to memory controller behaviour. * kmalloc: rate = (190 +- 30) MBps time = (50 +- 10) usec * usb_alloc_coherent: rate = (33 +- 4) MBps time = (3000 +- 400) usec Note, that quantative difference leads (this commit leads to 5 times acceleration) to qualitative behavior change in this case. As it was stated before, the video stream can not be successfully received at AM335x platforms with MUSB based USB host controller due to performance issues [1]. [1] https://www.spinics.net/lists/linux-usb/msg165735.html Signed-off-by: Matwey V. Kornilov --- drivers/media/usb/pwc/pwc-if.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c index 5775d1f60668..6a3cd9680a7f 100644 --- a/drivers/media/usb/pwc/pwc-if.c +++ b/drivers/media/usb/pwc/pwc-if.c @@ -427,11 +427,8 @@ static int pwc_isoc_init(struct pwc_device *pdev) urb->interval = 1; // devik urb->dev = udev; urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint); - urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; - urb->transfer_buffer = usb_alloc_coherent(udev, - ISO_BUFFER_SIZE, - GFP_KERNEL, - &urb->transfer_dma); + urb->transfer_flags = URB_ISO_ASAP; + urb->transfer_buffer = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL); if (urb->transfer_buffer == NULL) { PWC_ERROR("Failed to allocate urb buffer %d\n", i); pwc_isoc_cleanup(pdev); @@ -491,10 +488,7 @@ static void pwc_iso_free(struct pwc_device *pdev) if (pdev->urbs[i]) { PWC_DEBUG_MEMORY("Freeing URB\n"); if (pdev->urbs[i]->transfer_buffer) { - usb_free_coherent(pdev->udev, - pdev->urbs[i]->transfer_buffer_length, - pdev->urbs[i]->transfer_buffer, - pdev->urbs[i]->transfer_dma); + kfree(pdev->urbs[i]->transfer_buffer); } usb_free_urb(pdev->urbs[i]); pdev->urbs[i] = NULL;