Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3162473imw; Mon, 11 Jul 2022 03:15:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u2/U33XzPz6QV904VX3gDHaGFNhOTXQZSsxmd+zpHVT/d8SwM7pnk9HfEpeopmj9R3VbLj X-Received: by 2002:a17:907:160a:b0:72b:51e0:d90b with SMTP id hb10-20020a170907160a00b0072b51e0d90bmr5003024ejc.609.1657534541917; Mon, 11 Jul 2022 03:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657534541; cv=none; d=google.com; s=arc-20160816; b=p7nLdmRIZ3JXgSXHUBi9ZOYqhIFmLKf1jX4hpcW5dtt/UiT+cdFNop/WXurFrKuos9 n1IF1zYBj713PranGiN83ErA2qT8/so7e6GiISCrUU82mJQCWWfUEbD6FIa/FLnTJQKK we3Sm3KjWe/h7HvOlB8kP4VOkhioD5332XuAB+COtsrK9xjhQtz/YXWhC/oMJ+ER3sR9 ahixy/9BT3CI6IAfnjVNdj5j8W2auEoiDHbBcgl4hAiByTHE9+oRx/eF2FDMyM/EhgRh yXz7A1CXmi0MtutiJKY4BSWzhm/2FTodll/JZJPjuBHt3JEmV9gPb+q2QmZbnCKzGIMV EmUw== 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=sT4HKJMInKbtKXOr5E9lMd21obl+xH0gaWFHaZ2Gb/JKwyyPBkUiGyl+NBTerL+WCY g6OU3WXj8n5h/lDF3XMz+uE+LplbZv5Bi51CnYyUX5J56Wbu5srSqpgrmZstGo55ZrlM wuNHRPn7iM88We6cVCLa+TANCcAe3vDrVClglGCqWTDZ0wmjg0zeCwnVlPbkuDsEHsDL k0Hn7X3uMMHOzOzW/zLYAKcYGxb3vxRaNrKmwL/Bk2Gz23u6bwnaQw1AGXT/F+0nJJt/ PHzCr1SmZzVxOtQQvlck+NhXVKSNeZ03WHTWq04ETMnOZhqmYmP90OdfJDO9K6C5klvP 9djw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YcAIlJWa; 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 ho30-20020a1709070e9e00b0072b6eb1cb29si96618ejc.210.2022.07.11.03.15.16; Mon, 11 Jul 2022 03:15:41 -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=YcAIlJWa; 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 S230165AbiGKJXV (ORCPT + 99 others); Mon, 11 Jul 2022 05:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231808AbiGKJWy (ORCPT ); Mon, 11 Jul 2022 05:22:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D687D22BE9; Mon, 11 Jul 2022 02:13:33 -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 dfw.source.kernel.org (Postfix) with ESMTPS id CE590610A5; Mon, 11 Jul 2022 09:13:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF023C34115; Mon, 11 Jul 2022 09:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530812; bh=FM/xnDTajo5tg/nDWYB6juALM7uDbh8bArFdijDwNc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YcAIlJWao9dFiq0zwamoERhckZwDlmzzaC6yPXbZda+WyNqfIfspRTQ0Cwt8CKjQC aRm245JZ5BdrkwLP3OVDZmQF4VIBb7PTmzG2jVWvB20Xb2wR6ukmfz3YixkWW+Xfgp oZF6zl9tAzOJsvP7Q3zeR5Kwh4euu1kgk+oMn490= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , stable Subject: [PATCH 5.10 47/55] misc: rtsx_usb: fix use of dma mapped buffer for usb bulk transfer Date: Mon, 11 Jul 2022 11:07:35 +0200 Message-Id: <20220711090543.143177596@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090541.764895984@linuxfoundation.org> References: <20220711090541.764895984@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;