From patchwork Thu Feb 4 23:28:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 377625 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=-21.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 8894AC433DB for ; Thu, 4 Feb 2021 23:30:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50F9D64FB0 for ; Thu, 4 Feb 2021 23:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbhBDXaB (ORCPT ); Thu, 4 Feb 2021 18:30:01 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:49416 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbhBDX37 (ORCPT ); Thu, 4 Feb 2021 18:29:59 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1l7o3f-004HTA-Vw; Fri, 05 Feb 2021 00:29:07 +0100 From: Andrew Lunn To: Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Andrew Lunn , stable@vger.kernel.org Subject: [PATCH] media: pwc-if: Use USB controller device when mapping DMA buffer Date: Fri, 5 Feb 2021 00:28:51 +0100 Message-Id: <20210204232851.1020416-1-andrew@lunn.ch> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This fixes a WARN_ON_ONCE(!dev->dma_mask) in dma_map_page_attrs(). The PWC driver does not perform DMA operations itself. The USB bus controller does. Hence the mapping should be performed for that device. The bus controller has the DMA mask set, since it actually interacts with the hardware, where as the PWC driver does not. Cc: # 5.10 Signed-off-by: Andrew Lunn --- I don't hang out in the media subsystem mailing list, being a network hacker. So i don't know the local customs here. This patch is based on git://linuxtv.org/media_tree.git branch fixes. Please let me know if it needs rebasing to somewhere else. I did not do a git bisect. I do know v5.9 works, v5.10 regressed. I cannot give an exact Fixes: tag as a result. It would be nice to get it into stable for 5.10, but it does not need to go any further back. drivers/media/usb/pwc/pwc-if.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c index 61869636ec61..406cc0268c7b 100644 --- a/drivers/media/usb/pwc/pwc-if.c +++ b/drivers/media/usb/pwc/pwc-if.c @@ -461,7 +461,7 @@ static int pwc_isoc_init(struct pwc_device *pdev) urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint); urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; urb->transfer_buffer_length = ISO_BUFFER_SIZE; - urb->transfer_buffer = pwc_alloc_urb_buffer(&udev->dev, + urb->transfer_buffer = pwc_alloc_urb_buffer(udev->bus->controller, urb->transfer_buffer_length, &urb->transfer_dma); if (urb->transfer_buffer == NULL) { @@ -515,6 +515,7 @@ static void pwc_iso_stop(struct pwc_device *pdev) static void pwc_iso_free(struct pwc_device *pdev) { + struct usb_device *udev = pdev->udev; int i; /* Freeing ISOC buffers one by one */ @@ -524,7 +525,7 @@ static void pwc_iso_free(struct pwc_device *pdev) if (urb) { PWC_DEBUG_MEMORY("Freeing URB\n"); if (urb->transfer_buffer) - pwc_free_urb_buffer(&urb->dev->dev, + pwc_free_urb_buffer(udev->bus->controller, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma);