Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3180035imw; Mon, 11 Jul 2022 03:41:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uex/0ZjnrOTl25mBfiWVxmZBeR3/mexfcURlm60+CFt6b8jADlWb6rcdONjMak8LX63hH3 X-Received: by 2002:a62:6183:0:b0:52a:c31d:11b7 with SMTP id v125-20020a626183000000b0052ac31d11b7mr8880988pfb.74.1657536098960; Mon, 11 Jul 2022 03:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657536098; cv=none; d=google.com; s=arc-20160816; b=gbmh1YWid3tm1buVKENJUOOBPWZaiQ8CIDgqHJ35RT0gfUFiGPUpNRtcpvoYuISRVH WM7VYsxxRwYonD7t8FT+qFOYPPdhr3qUprwpv6XMcydPJpzl4P3Nj1nJPHuSUMm3iF4g wyF3GSWLTO8UqBTohpIQYb0I4kxIMMfg/OuvF9H5hauy/sSDfDq/UwwZidgEfVnlKoD9 C6Qq6erkBfoKAF4afhUhG2qTq2ZccWVGxpsrR5jfeC+iYAtwh70/xoZorLDsMR8nyZTI zsakgqtDWGoI531rniH821fJaE1cbKoTugabcpBE8+ZFyaeyjGGdpvzdZP1liTEw2Lz8 aUrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tsZNFDUCLFXPVvVROT/QDSsG41jB9wznKhXANAbWR2I=; b=zz3ysO6uwuIYQ/O+QOGx42Tzyhv9pKvWJ/LjnziE0NNd6N50cWxiXZoR0Bgd4usQpG 4zUnGQg7r6FDb+AKFpnnvcYtEyr7fM9PYdHwqAtXjOoHsbD+/cUOYVoewnc0jSG8YtM0 jCpZnFlH4oXFyzHOS5jiAMTo5mzkb0dWl8lpPR2aAn9cMAh+auXAM3tGTFhgvCXKPWmV Eo8pd14IbZySDiSStjuOEhBp4i1miVM7tZrNmNXSm1H9Eqt+sY3kMpVBluHu9Eq3sjyw LjwCZMTjr3t4XDbXJCRosDo5vulWh+txFiYl6SaHPcq6rR1UX7P9NAcaorEgZrU355Wk lPTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DS5XBgfc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a170902eb8800b001635111a63csi8580320plg.432.2022.07.11.03.41.26; Mon, 11 Jul 2022 03:41:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DS5XBgfc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234554AbiGKKD5 (ORCPT + 99 others); Mon, 11 Jul 2022 06:03:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234434AbiGKKDZ (ORCPT ); Mon, 11 Jul 2022 06:03:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D850A67595; Mon, 11 Jul 2022 02:29:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 87AC1B80D2C; Mon, 11 Jul 2022 09:29:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFDF6C34115; Mon, 11 Jul 2022 09:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531751; bh=FM/xnDTajo5tg/nDWYB6juALM7uDbh8bArFdijDwNc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DS5XBgfcz8q8Vom+REhCMxJ+9oTvFhtjLDAxdvdKbY/bfbDcsf5tCMjHKSnUaxrC+ 4qKB+1OWBOHWhqJg1AojfB2jqodbURqnjWJSleuX5yJar0BEigmFVYmhGczMtBNMHh FR3fuJqOBwfnBPqqxCRRbRbZoJOSHptA7bAVjaJc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , stable Subject: [PATCH 5.15 216/230] misc: rtsx_usb: fix use of dma mapped buffer for usb bulk transfer Date: Mon, 11 Jul 2022 11:07:52 +0200 Message-Id: <20220711090610.229544893@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shuah Khan commit eb7f8e28420372787933eec079735c35034bda7d upstream. rtsx_usb driver allocates coherent dma buffer for urb transfers. This buffer is passed to usb_bulk_msg() and usb core tries to map already mapped buffer running into a dma mapping error. xhci_hcd 0000:01:00.0: rejecting DMA map of vmalloc memory WARNING: CPU: 1 PID: 279 at include/linux/dma-mapping.h:326 usb_ hcd_map_urb_for_dma+0x7d6/0x820 ... xhci_map_urb_for_dma+0x291/0x4e0 usb_hcd_submit_urb+0x199/0x12b0 ... usb_submit_urb+0x3b8/0x9e0 usb_start_wait_urb+0xe3/0x2d0 usb_bulk_msg+0x115/0x240 rtsx_usb_transfer_data+0x185/0x1a8 [rtsx_usb] rtsx_usb_send_cmd+0xbb/0x123 [rtsx_usb] rtsx_usb_write_register+0x12c/0x143 [rtsx_usb] rtsx_usb_probe+0x226/0x4b2 [rtsx_usb] Fix it to use kmalloc() to get DMA-able memory region instead. Signed-off-by: Shuah Khan Cc: stable Link: https://lore.kernel.org/r/667d627d502e1ba9ff4f9b94966df3299d2d3c0d.1656642167.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/misc/cardreader/rtsx_usb.c | 13 +++++++------ include/linux/rtsx_usb.h | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) --- a/drivers/misc/cardreader/rtsx_usb.c +++ b/drivers/misc/cardreader/rtsx_usb.c @@ -631,8 +631,7 @@ static int rtsx_usb_probe(struct usb_int ucr->pusb_dev = usb_dev; - ucr->iobuf = usb_alloc_coherent(ucr->pusb_dev, IOBUF_SIZE, - GFP_KERNEL, &ucr->iobuf_dma); + ucr->iobuf = kmalloc(IOBUF_SIZE, GFP_KERNEL); if (!ucr->iobuf) return -ENOMEM; @@ -668,8 +667,9 @@ static int rtsx_usb_probe(struct usb_int out_init_fail: usb_set_intfdata(ucr->pusb_intf, NULL); - usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf, - ucr->iobuf_dma); + kfree(ucr->iobuf); + ucr->iobuf = NULL; + ucr->cmd_buf = ucr->rsp_buf = NULL; return ret; } @@ -682,8 +682,9 @@ static void rtsx_usb_disconnect(struct u mfd_remove_devices(&intf->dev); usb_set_intfdata(ucr->pusb_intf, NULL); - usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf, - ucr->iobuf_dma); + kfree(ucr->iobuf); + ucr->iobuf = NULL; + ucr->cmd_buf = ucr->rsp_buf = NULL; } #ifdef CONFIG_PM --- a/include/linux/rtsx_usb.h +++ b/include/linux/rtsx_usb.h @@ -55,7 +55,6 @@ struct rtsx_ucr { struct usb_interface *pusb_intf; struct usb_sg_request current_sg; unsigned char *iobuf; - dma_addr_t iobuf_dma; struct timer_list sg_timer; struct mutex dev_mutex;