Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp2088230pxb; Sat, 19 Feb 2022 01:49:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIl32cPUI+4yGFX9pGlTjYkr6NNSqqR1kfLtAfLI9o9VuDirgJUoq8a884mBnyiUjWYTNp X-Received: by 2002:a17:902:7205:b0:14c:9586:f9d5 with SMTP id ba5-20020a170902720500b0014c9586f9d5mr11041984plb.77.1645264174999; Sat, 19 Feb 2022 01:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645264174; cv=none; d=google.com; s=arc-20160816; b=e5jV6H51XHSrjlA8iwB50tgQRoPvGXFIngIoe08Vdn/BqOSdmhtoDHtpJ7VAQwaVsc xPf5ZDZQymbNO57CWcIvKX6drUMh8OmXlO453FOOpwF4Ub7CyMwha+GkEw1Bcd1MDma0 NfJnj7VmZeroruBSa/lm3TvYYnMtnAtmWa7WgjPMw3bjCqMBksIEFt2hG7RsdkD6fN3f 5GEX50xUKZm1NeRDrXBO+poFy8jJucKefmpiHbSGxTnrmHtEmhJbWlSfJRA8Vjp0+40z Noome/N4l0Y5OosnY2EAW7pzuywgXb5le2q4w49ae+zBSdsdvqJt7P6t5u+ec/FwwNzt mqhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Gw/NJK8fpoJAAgLoy5A/sOEoEXpxXVtHErMcNbgZLPI=; b=KfsmCNq520gZuyzw+pbQ/69rpmO3b4ZWsqgSGWIqy5Re5Ay1wVmihWu7hBxn2kXiaR uBc1i8WueYYlW1bK62ogDLKufcuRulOjNBT9667WTFSpS3KqN9skA80u3yNN3pCV7+IX mvE2NFn2Xo+cyKm6WwVtKX2SX5S2u7DOULMbceWjj7VlMMCdVm73F2keC0gbRrex2OZc XyplZx2OCzRcfYTKy6Xe9/76Z845CJb+d1q+qZbcq8gyr8+KHa/cs82zjIzRTeI6LIdW LKmEJFACRWsWW4rDpf4KP8k4FTr8dLW1jPuSwI0ID9ZKFnoHIJIt3B47thCpDnz1P1ZE U4qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UAuzkxcJ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 12-20020a17090a0ccc00b001b8814b9e0csi1595377pjt.74.2022.02.19.01.49.20; Sat, 19 Feb 2022 01:49:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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=@redhat.com header.s=mimecast20190719 header.b=UAuzkxcJ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238465AbiBSA6h (ORCPT + 99 others); Fri, 18 Feb 2022 19:58:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241024AbiBSA5v (ORCPT ); Fri, 18 Feb 2022 19:57:51 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E07827AA36 for ; Fri, 18 Feb 2022 16:57:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645232230; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=Gw/NJK8fpoJAAgLoy5A/sOEoEXpxXVtHErMcNbgZLPI=; b=UAuzkxcJoeLT69J+P2p5K5wXDb086xACuLhSX10UIQ05Pln8g1eBB7OL7e90z+yU1GRYr+ w/yhpg2ZI3AQK72bDCFCILbKWl2ikbuuzdjFuIcygfadyGOeVw7gOx46nhwcdslQ5isvB0 E7jVr85oc5CyysUgs6VHf06AOuhEjwo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-195-xetRNHCfO521Ql8W4vgBdQ-1; Fri, 18 Feb 2022 19:57:07 -0500 X-MC-Unique: xetRNHCfO521Ql8W4vgBdQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 096CD1091DA0; Sat, 19 Feb 2022 00:57:04 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA67A62D4E; Sat, 19 Feb 2022 00:56:52 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, hch@lst.de, cl@linux.com, 42.hyeyoo@gmail.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz, David.Laight@ACULAB.COM, david@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, steffen.klassert@secunet.com, netdev@vger.kernel.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, linux-s390@vger.kernel.org, michael@walle.cc, linux-i2c@vger.kernel.org, wsa@kernel.org Subject: [PATCH 20/22] HID: intel-ish-hid: Use dma_alloc_noncoherent() for dma buffer Date: Sat, 19 Feb 2022 08:52:19 +0800 Message-Id: <20220219005221.634-21-bhe@redhat.com> In-Reply-To: <20220219005221.634-1-bhe@redhat.com> References: <20220219005221.634-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-crypto@vger.kernel.org GFP_DMA32 is an illegal flag to pass when calling kmalloc(), please see GFP_SLAB_BUG_MASK definition. Allocating dma buffer using kmalloc() is not recommended. Use dma_alloc_noncoherent() instead. DMA API will assume the device has 32 bit addressing limitation when allocating buffer. [ 42.hyeyoo@gmail.com: Use dma_alloc_noncoherent() instead of __get_free_pages ] Signed-off-by: Baoquan He Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Srinivas Pandruvada Cc: Jiri Kosina Cc: Benjamin Tissoires Cc: Sumit Semwal Cc: christian.koenig@amd.com Cc: linux-input@vger.kernel.org --- drivers/hid/intel-ish-hid/ishtp-fw-loader.c | 23 +++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c index e24988586710..3be1e3329962 100644 --- a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c +++ b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c @@ -661,21 +661,15 @@ static int ish_fw_xfer_direct_dma(struct ishtp_cl_data *client_data, */ payload_max_size &= ~(L1_CACHE_BYTES - 1); - dma_buf = kmalloc(payload_max_size, GFP_KERNEL | GFP_DMA32); + dma_buf = dma_alloc_noncoherent(devc, get_order(payload_max_size), + &dma_buf_phy, DMA_TO_DEVICE, + GFP_KERNEL); if (!dma_buf) { + dev_err(cl_data_to_dev(client_data), "DMA alloc failed\n"); client_data->flag_retry = true; return -ENOMEM; } - dma_buf_phy = dma_map_single(devc, dma_buf, payload_max_size, - DMA_TO_DEVICE); - if (dma_mapping_error(devc, dma_buf_phy)) { - dev_err(cl_data_to_dev(client_data), "DMA map failed\n"); - client_data->flag_retry = true; - rv = -ENOMEM; - goto end_err_dma_buf_release; - } - ldr_xfer_dma_frag.fragment.hdr.command = LOADER_CMD_XFER_FRAGMENT; ldr_xfer_dma_frag.fragment.xfer_mode = LOADER_XFER_MODE_DIRECT_DMA; ldr_xfer_dma_frag.ddr_phys_addr = (u64)dma_buf_phy; @@ -725,15 +719,14 @@ static int ish_fw_xfer_direct_dma(struct ishtp_cl_data *client_data, fragment_offset += fragment_size; } - dma_unmap_single(devc, dma_buf_phy, payload_max_size, DMA_TO_DEVICE); - kfree(dma_buf); + dma_free_noncoherent(devc, get_order(payload_max_size), dma_buf, + dma_buf_phy, DMA_TO_DEVICE); return 0; end_err_resp_buf_release: /* Free ISH buffer if not done already, in error case */ - dma_unmap_single(devc, dma_buf_phy, payload_max_size, DMA_TO_DEVICE); -end_err_dma_buf_release: - kfree(dma_buf); + dma_free_noncoherent(devc, get_order(payload_max_size), dma_buf, + dma_buf_phy, DMA_TO_DEVICE); return rv; } -- 2.17.2