From patchwork Wed May 8 11:54:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasanthakumar Thiagarajan X-Patchwork-Id: 10935537 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2FF192A for ; Wed, 8 May 2019 11:55:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEAA628409 for ; Wed, 8 May 2019 11:55:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2C9A28935; Wed, 8 May 2019 11:55:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C64028409 for ; Wed, 8 May 2019 11:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=08Bbt+xq9UKvoUk0pWOqXS8mfgyYBqfJEHkQkWTwvwY=; b=Gph9AzcZVIR/tV PDo4wgjp9R7/gSvj2+nqa60nOp0o3iXPy+Oov9QNDV4T8Xt46egeRJ6wr3EAHHwMg49W1w8KFIi6W atFEE1beqTrujp21BnJ6Xo/skAMBRU8OnCDl/6BwjUCIeF4pgVe+zMrtGl+GNEY2pavVdwwduvU67 kOAMDJtp0aAaVX7pGThKHfRQy85FwN3IjO7ZbtiqzweV45ZEI5FFlQyEOA44Gmekxz7JSt+BwHzWZ yTlBEk4RtTx1squCcv5/IMZyW9MTb6GDhpDtHgjBW3zbLtNadlS600TzAt5fDjJ9ntMpdxPNqOJqQ 7m5RG2giFZvsisIw8lCA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hOLAh-0002GK-9C; Wed, 08 May 2019 11:55:39 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hOLAe-0002Ft-MG for ath11k@lists.infradead.org; Wed, 08 May 2019 11:55:38 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B51FA60E3E; Wed, 8 May 2019 11:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1557316535; bh=L+OQ8iDPnt4x3tOFv+S5dtjdT7gAuoz4KFMz+ZB7XXc=; h=From:To:Subject:Date:From; b=XhBpC/NE45z+uO+1DlJ3LtQB9FfGXQqCeiR30Rz1oiKMSKV44Vqb7TJzmyPdzvsRh UnR2VVIKSbGjXfvSgdOuhr4vmDZDBDFmhkDzB5JUuxIgE62zbvG5BH1gU1np0M+qOI TdZYSwBeg6oPS+ivioGfWnS/dWb039oRr+9OFLCQ= Received: from vasanth-lnx.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vthiagar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4D6CD60452 for ; Wed, 8 May 2019 11:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1557316535; bh=L+OQ8iDPnt4x3tOFv+S5dtjdT7gAuoz4KFMz+ZB7XXc=; h=From:To:Subject:Date:From; b=XhBpC/NE45z+uO+1DlJ3LtQB9FfGXQqCeiR30Rz1oiKMSKV44Vqb7TJzmyPdzvsRh UnR2VVIKSbGjXfvSgdOuhr4vmDZDBDFmhkDzB5JUuxIgE62zbvG5BH1gU1np0M+qOI TdZYSwBeg6oPS+ivioGfWnS/dWb039oRr+9OFLCQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4D6CD60452 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vthiagar@codeaurora.org From: Vasanthakumar Thiagarajan To: ath11k@lists.infradead.org Subject: [PATCH] ath11k/qmi: Use memcpy_toio() function on I/O memory Date: Wed, 8 May 2019 17:24:43 +0530 Message-Id: <1557316483-18397-1-git-send-email-vthiagar@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190508_045536_768674_9B5EE65D X-CRM114-Status: UNSURE ( 9.97 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The usage of memcpy() function on I/O memory is not recommended when doing a bulk data copy. Instead use memcpy_toio() function while copying bulk data to I/O memory. Using the right function takes care of platform specific alignment requirement as well in arm64. This fixes the below kernel crash due to unaligned memory access in 64-bit arm during memory copy of board data to I/O memory. [ 15.672513] ath11k c000000.wifi1: Downloading BDF: IPQ8074/board-2.bin, size: 917972 [ 15.672635] Unhandled fault: alignment fault (0x96000061) at 0xffffff8007200004 [ 15.680449] Internal error: : 96000061 [#1] PREEMPT SMP [ 15.946227] CPU: 0 PID: 890 Comm: kworker/u8:5 Tainted: P [ 15.968272] task: ffffffc03cae9f80 ti: ffffffc03cae9f80 task.ti: ffffffc03cae9f80 [ 15.968552] PC is at __efistub_memcpy+0x48/0x180 [ 15.976011] LR is at ath11k_ce_get_attr_flags+0xc14/0x1594 [ath11k] Signed-off-by: Vasanthakumar Thiagarajan Tested-by: Sven Eckelmann --- drivers/net/wireless/ath/ath11k/qmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index b862fa9..0bec067 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -1795,7 +1795,7 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) static int ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type, struct qmi_wlanfw_bdf_download_req_msg_v01 *req, - void *bdf_addr) + void __iomem *bdf_addr) { struct device *dev = ab->dev; char filename[ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE]; @@ -1813,7 +1813,7 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) } fw_size = min_t(u32, ab->hw_params.fw.board_size, bd.len); - memcpy(bdf_addr, bd.data, fw_size); + memcpy_toio(bdf_addr, bd.data, fw_size); ath11k_core_free_bdf(ab, &bd); break; case ATH11K_QMI_FILE_TYPE_CALDATA: @@ -1828,7 +1828,8 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) fw_size = min_t(u32, ab->hw_params.fw.board_size, fw_entry->size); - memcpy(bdf_addr + ATH11K_QMI_CALDATA_OFFSET, fw_entry->data, fw_size); + memcpy_toio(bdf_addr + ATH11K_QMI_CALDATA_OFFSET, + fw_entry->data, fw_size); ath11k_info(ab, "qmi downloading BDF: %s, size: %zu\n", filename, fw_entry->size);