From patchwork Tue Oct 20 16:11:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 55313 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id E4E7F23024 for ; Tue, 20 Oct 2015 16:11:40 +0000 (UTC) Received: by wiyb4 with SMTP id b4sf11358717wiy.2 for ; Tue, 20 Oct 2015 09:11:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=JYgoShvNGFLVYyb8cR/zU+yk9Uee8/9gEOVMzuVH0V8=; b=Qu23st1d8d5x9O9pMB8QYFyfO7AlQ75oHPNBtHNFdcSMcsPanrR2WJbBp/aeQPOXVL 8wgMPRsvOYMXUTEFKvYFDdl2MpR7rGsBjK9e/f8JJx+nU6EV65v74T4nJahYgCl41O9/ f7ESorDJXUt9Yi+kBZc6GLLA8eiFe8Oem1DJERbAplywlklrk4wRXxD1/xRhFLSroyxR RG0JQ3GU9BCOE+BHl6AgKMvj8cuViowxVAh8f71lOXuC/zzI3Rj8z27i20Jr+oYYAapV /H5JQLz92Dq8zULsSlAMtm9unXNYwK5tRtC3Cc9ID9lQvn1J1LdMjEdA8+EP5p0HIZAW Rfbw== X-Gm-Message-State: ALoCoQneTSuxRjJkQ04FO6guxqCdhnHzPQjL9eMl0tLwPPtVZwGn5+FacGJrOX7Vc98yupTJfdQV X-Received: by 10.180.35.132 with SMTP id h4mr5534467wij.5.1445357500257; Tue, 20 Oct 2015 09:11:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.28.195 with SMTP id c186ls99040lfc.71.gmail; Tue, 20 Oct 2015 09:11:40 -0700 (PDT) X-Received: by 10.112.134.197 with SMTP id pm5mr2342672lbb.3.1445357500057; Tue, 20 Oct 2015 09:11:40 -0700 (PDT) Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id wt5si2836880lbb.57.2015.10.20.09.11.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 09:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lfaz124 with SMTP id z124so8331067lfa.1 for ; Tue, 20 Oct 2015 09:11:40 -0700 (PDT) X-Received: by 10.25.38.9 with SMTP id m9mr1531368lfm.112.1445357499899; Tue, 20 Oct 2015 09:11:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2174375lbq; Tue, 20 Oct 2015 09:11:39 -0700 (PDT) X-Received: by 10.66.240.37 with SMTP id vx5mr4889709pac.76.1445357498894; Tue, 20 Oct 2015 09:11:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ls17si6216510pab.10.2015.10.20.09.11.37; Tue, 20 Oct 2015 09:11:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752377AbbJTQLf (ORCPT + 28 others); Tue, 20 Oct 2015 12:11:35 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:34813 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751609AbbJTQLc (ORCPT ); Tue, 20 Oct 2015 12:11:32 -0400 Received: by wikq8 with SMTP id q8so53833915wik.1 for ; Tue, 20 Oct 2015 09:11:31 -0700 (PDT) X-Received: by 10.194.10.162 with SMTP id j2mr5231676wjb.43.1445357490939; Tue, 20 Oct 2015 09:11:30 -0700 (PDT) Received: from localhost.localdomain (cpc14-aztw22-2-0-cust189.18-1.cable.virginm.net. [82.45.1.190]) by smtp.gmail.com with ESMTPSA id lg1sm19931008wic.17.2015.10.20.09.11.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Oct 2015 09:11:30 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, maxime.coquelin@st.com, jassisinghbrar@gmail.com, peter.griffin@linaro.org, Lee Jones Subject: [PATCH] mailbox: mailbox-test: Correctly repair Sparse warnings Date: Tue, 20 Oct 2015 17:11:27 +0100 Message-Id: <1445357487-13961-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Kbuild test robot reported some Sparse warnings to the tune of: sparse: incorrect type in argument 6 (different address spaces) expected void const *buf got void [noderef] *mmio This was due to passing variables tagged with the Sparse cookie '__iomem' through into memcpy() and print_hex_dump() without adequate protection or casting. These issues were fixed in a previous patch suppressing the warnings, but the issue is indeed still present. This patch fixes the warnings in the correct way, i.e. by using the purposely authored memcpy_{from,to}io() derivatives in the memcpy() case and casting the memory address to (void *) and forcing Sparse to ignore to ignore it in the print_hex_dump() case [NB: This is also what the memcpy() derivatives do]. Reported-by: Peter Griffin Signed-off-by: Lee Jones --- drivers/mailbox/mailbox-test.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index 22f2e40..a4f10cc 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -30,7 +31,7 @@ static struct dentry *root_debugfs_dir; struct mbox_test_device { struct device *dev; - void *mmio; + void __iomem *mmio; struct mbox_chan *tx_channel; struct mbox_chan *rx_channel; char *rx_buffer; @@ -222,8 +223,8 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message) if (tdev->mmio) { print_hex_dump(KERN_INFO, "Client: Received [MMIO]: ", DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1, - tdev->mmio, MBOX_MAX_MSG_LEN, true); - memcpy(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN); + __io_virt(tdev->mmio), MBOX_MAX_MSG_LEN, true); + memcpy_fromio(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN); } else if (message) { print_hex_dump(KERN_INFO, "Client: Received [API]: ", @@ -240,9 +241,9 @@ static void mbox_test_prepare_message(struct mbox_client *client, void *message) if (tdev->mmio) { if (tdev->signal) - memcpy(tdev->mmio, tdev->message, MBOX_MAX_MSG_LEN); + memcpy_toio(tdev->mmio, tdev->message, MBOX_MAX_MSG_LEN); else - memcpy(tdev->mmio, message, MBOX_MAX_MSG_LEN); + memcpy_toio(tdev->mmio, message, MBOX_MAX_MSG_LEN); } }