Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp593415pxb; Tue, 5 Apr 2022 15:16:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVwabuYK2z4enuTqzi5yQ0iKUB3M+kCtui01P2M42J3IipPNNfkkBNnZKgqDP1q9M7fqTU X-Received: by 2002:a17:902:a981:b0:156:229d:6834 with SMTP id bh1-20020a170902a98100b00156229d6834mr5362206plb.128.1649196991324; Tue, 05 Apr 2022 15:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649196991; cv=none; d=google.com; s=arc-20160816; b=K1fiYzlAAeXburHSIvx6PUa5VYDP0dacPqLHZbIgrK5JJvAb8KvHisuTzpazO9In8h /UgdpZQ58ZxblcoSbJJ5CFW8tbCZm09g8W//wKSxRHadgGQ9GVSiLb9wxEe64x6Mwy27 712/2r8jW7xwDmdyVt2gq7l8zTopQWPOjOVBjDJAKjs5sa4mycI7SXsQqZKYNGujVYmC adKB6T9bgvDfGG0JmV/frQRmCl54YNKml1SYAJhjbnnksvXbo++neFAoxfNPbvgRQK8g ImNM14pnuLVw7gV76MlTvWTCxVu0gE/Kx9rSqwNJ7S11rjf+chpnnO6GgObUS/+NXu7Z m/rg== 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=pmZUEqcxdpfewm82aJPEU3UzLnLAWDtaXGiF1N5bBxM=; b=KVQATDNAjyPZAXBZl875IVe3dpI+Hix9TDsgqbPorxi/PiKA68+nNSSbgN0N/AzwBV Qrq2/gD7/qNLKVCNMKWYKQXbxiTdO0FM2lHwL2VWUkeRKSmsmvecpRfDlVZFNHVekyIB Rg0x0yYIWcnljcdHbO0AZkcQwDC8Kxk1/8K03qmn3vJEEIgmO5Jdwi2RFTG9xoJVWZG3 X7fSuF4DnbPKxy9j9xhl5m+qyCEf37P0eLUxMk7owYEZKRpdgx/prDKIT/bCkC3Qs8tw rEI3txM5l+CkxBpz9Tw5/hX0YK3+fZctj6lmU4YGjKKJnSsxJJO8BDyeGXR1SbUZB/Vx nrtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wXPgXdnV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n7-20020a635c47000000b003816043ef09si11503559pgm.254.2022.04.05.15.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 15:16:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wXPgXdnV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C594C1AEC9E; Tue, 5 Apr 2022 14:59:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234003AbiDEO03 (ORCPT + 99 others); Tue, 5 Apr 2022 10:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238970AbiDEJdN (ORCPT ); Tue, 5 Apr 2022 05:33:13 -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 C1A9F6370; Tue, 5 Apr 2022 02:20:59 -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 73B3BB81B75; Tue, 5 Apr 2022 09:20:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B99D1C385A3; Tue, 5 Apr 2022 09:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150457; bh=2mbQAsg1ojvN2fz5ehSmAEL4IcrsYT0ZF5XIupg9S1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wXPgXdnV6ewqp/iTpaBEN39/lEiGkUP/RSIlnABon3Hm7H22dfwNVpg7GTWPXxIjw oIQk1aAEbbqNrWu/EpMc16K/u0S68nThUlMYcn6G3jsafpPivyAAlkI6/KtESKGlHb Xf6ZdvOERciO+gm9k77axFuzDX9DDSUc6HA+NPYQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gwendal Grignou , Srinivas Pandruvada , Jiri Kosina Subject: [PATCH 5.15 062/913] HID: intel-ish-hid: Use dma_alloc_coherent for firmware update Date: Tue, 5 Apr 2022 09:18:44 +0200 Message-Id: <20220405070341.682757585@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Gwendal Grignou commit f97ec5d75e9261a5da78dc28a8955b7cc0c4468b upstream. Allocating memory with kmalloc and GPF_DMA32 is not allowed, the allocator will ignore the attribute. Instead, use dma_alloc_coherent() API as we allocate a small amount of memory to transfer firmware fragment to the ISH. On Arcada chromebook, after the patch the warning: "Unexpected gfp: 0x4 (GFP_DMA32). Fixing up to gfp: 0xcc0 (GFP_KERNEL). Fix your code!" is gone. The ISH firmware is loaded properly and we can interact with the ISH: > ectool --name cros_ish version ... Build info: arcada_ish_v2.0.3661+3c1a1c1ae0 2022-02-08 05:37:47 @localhost Tool version: v2.0.12300-900b03ec7f 2022-02-08 10:01:48 @localhost Fixes: commit 91b228107da3 ("HID: intel-ish-hid: ISH firmware loader client driver") Signed-off-by: Gwendal Grignou Acked-by: Srinivas Pandruvada Cc: stable@vger.kernel.org Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/intel-ish-hid/ishtp-fw-loader.c | 29 ++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) --- a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c +++ b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c @@ -657,21 +657,12 @@ static int ish_fw_xfer_direct_dma(struct */ payload_max_size &= ~(L1_CACHE_BYTES - 1); - dma_buf = kmalloc(payload_max_size, GFP_KERNEL | GFP_DMA32); + dma_buf = dma_alloc_coherent(devc, payload_max_size, &dma_buf_phy, GFP_KERNEL); if (!dma_buf) { 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; @@ -691,14 +682,7 @@ static int ish_fw_xfer_direct_dma(struct ldr_xfer_dma_frag.fragment.size = fragment_size; memcpy(dma_buf, &fw->data[fragment_offset], fragment_size); - dma_sync_single_for_device(devc, dma_buf_phy, - payload_max_size, - DMA_TO_DEVICE); - - /* - * Flush cache here because the dma_sync_single_for_device() - * does not do for x86. - */ + /* Flush cache to be sure the data is in main memory. */ clflush_cache_range(dma_buf, payload_max_size); dev_dbg(cl_data_to_dev(client_data), @@ -721,15 +705,8 @@ static int ish_fw_xfer_direct_dma(struct fragment_offset += fragment_size; } - dma_unmap_single(devc, dma_buf_phy, payload_max_size, DMA_TO_DEVICE); - kfree(dma_buf); - 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_coherent(devc, payload_max_size, dma_buf, dma_buf_phy); return rv; }