Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1647450imm; Thu, 14 Jun 2018 01:16:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJzOokpi68KbkceyXc2uc0qvBz0Rm6KKVS/tDPxVn7RnjZ4YeKcoJe+pGGYoAcTx6k3d5iG X-Received: by 2002:a63:83c3:: with SMTP id h186-v6mr1399178pge.298.1528964197365; Thu, 14 Jun 2018 01:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528964197; cv=none; d=google.com; s=arc-20160816; b=HQ3WnKhzqLeRtZm39WpvdnG/7TwnMB7XWbv4uM3kFeN1z8qp0YapONzf9AQjyX7A2E pDZh8l6HVBGZdo42RhScy0zXEbH2Ap835XJB+kaFgULUDzRh9LONdwL5/SmKQEH8/6QZ iugkMKGRfr0/HemLpnFz4maJ6xRIU4q9zFs9G9UjldunKSarIEmi32BzuiOUZih6eSOm XYKKWj9sdb7kcrg96qu8We1aGedWsi7ryv3IVMSDM/MdK6/bUPhBZzYpqfyqx3oPKQkT D8FhXOFolgsyVCBY1qwiJ9CmbDMsjl9EdCSEwtbT20b0HtoHiFYyKvFkJV6807xDLnt+ MLaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sF9vliHeDvILTPAF0ceT+gp6wnY41nA9CjOUi4i+CWc=; b=q0fDqwnMzvLf5gTpMro+9r3Gms9xhNvUB2gRfyfJew3Cw4DBOJWnlqLU3AEDrhwWFW K6E4msUoeymc8QXp7Gnfd7vz01It5lDLRSt0kxLaci2RWVqUtuRJ3B2glSS/VstH26oi 2X4zX53wCp4hK/gG/dgDK453IHRIU33rwPQOYqeEiQ4F09WtNd8UcXuO9lA/7HAH7YaK xtuk8ELdtQ+9OfaYaix00Qio8VibNjvSA0J1MHljionRNusDtRIXKqk9h6dJagRv3a0x OQ8wSS8JSxdVVWuJLeGgKUYca3iZLHaf8v21UP4FXC1zUg8Vs5bf7ZLGfbiNswa/2Nkl 18Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o5-v6si4085503pgs.303.2018.06.14.01.16.23; Thu, 14 Jun 2018 01:16:37 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754740AbeFNIPL (ORCPT + 99 others); Thu, 14 Jun 2018 04:15:11 -0400 Received: from mga06.intel.com ([134.134.136.31]:24708 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754631AbeFNIPH (ORCPT ); Thu, 14 Jun 2018 04:15:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jun 2018 01:15:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,222,1526367600"; d="scan'208";a="49814386" Received: from twinkler-lnx.jer.intel.com ([10.12.91.43]) by orsmga006.jf.intel.com with ESMTP; 14 Jun 2018 01:15:03 -0700 From: Tomas Winkler To: "James E . J . Bottomley" , "Martin K . Petersen" , Vinayak Holikatti , Adrian Hunter Cc: Christoph Hellwig , Vivek Gautam , Subhash Jadavani , Alex Lemberg , Avri Altman , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Tomas Winkler Subject: [PATCH resend] scsi: ufs: ufshcd_dump_regs to use memcpy_fromio Date: Thu, 14 Jun 2018 11:14:09 +0300 Message-Id: <20180614081409.29780-1-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ufshcd_dump_regs should use memcpy_fromio to read host registers instead of directly accessing using memcpy. The same function is utilized in ufs-qcom. Elminite compilation warning drivers/scsi/ufs/ufshcd.c:356:9: warning: incorrect type in argument 6 (different address spaces) drivers/scsi/ufs/ufshcd.c:356:9: expected void const *buf drivers/scsi/ufs/ufshcd.c:356:9: got void [noderef] *mmio_base Signed-off-by: Tomas Winkler --- drivers/scsi/ufs/ufs-qcom.c | 21 ++++++--------------- drivers/scsi/ufs/ufshcd.c | 35 ++++++++++++++++++++++++----------- drivers/scsi/ufs/ufshcd.h | 3 +++ 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 2b38db2eeafa..77ac98ea80d4 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -50,19 +50,10 @@ static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host); static int ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div(struct ufs_hba *hba, u32 clk_cycles); -static void ufs_qcom_dump_regs(struct ufs_hba *hba, int offset, int len, - char *prefix) -{ - print_hex_dump(KERN_ERR, prefix, - len > 4 ? DUMP_PREFIX_OFFSET : DUMP_PREFIX_NONE, - 16, 4, (void __force *)hba->mmio_base + offset, - len * 4, false); -} - static void ufs_qcom_dump_regs_wrapper(struct ufs_hba *hba, int offset, int len, - char *prefix, void *priv) + const char *prefix, void *priv) { - ufs_qcom_dump_regs(hba, offset, len, prefix); + ufshcd_dump_regs(hba, offset, len * 4, prefix); } static int ufs_qcom_get_connected_tx_lanes(struct ufs_hba *hba, u32 *tx_lanes) @@ -1431,7 +1422,7 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, static void ufs_qcom_print_hw_debug_reg_all(struct ufs_hba *hba, void *priv, void (*print_fn)(struct ufs_hba *hba, - int offset, int num_regs, char *str, void *priv)) + int offset, int num_regs, const char *str, void *priv)) { u32 reg; struct ufs_qcom_host *host; @@ -1613,7 +1604,7 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host) static void ufs_qcom_testbus_read(struct ufs_hba *hba) { - ufs_qcom_dump_regs(hba, UFS_TEST_BUS, 1, "UFS_TEST_BUS "); + ufshcd_dump_regs(hba, UFS_TEST_BUS, 4, "UFS_TEST_BUS "); } static void ufs_qcom_print_unipro_testbus(struct ufs_hba *hba) @@ -1639,8 +1630,8 @@ static void ufs_qcom_print_unipro_testbus(struct ufs_hba *hba) static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba) { - ufs_qcom_dump_regs(hba, REG_UFS_SYS1CLK_1US, 16, - "HCI Vendor Specific Registers "); + ufshcd_dump_regs(hba, REG_UFS_SYS1CLK_1US, 16 * 4, + "HCI Vendor Specific Registers "); /* sleep a bit intermittently as we are dumping too much data */ ufs_qcom_print_hw_debug_reg_all(hba, NULL, ufs_qcom_dump_regs_wrapper); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index d0a1674915a1..972fa85e2b24 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -99,8 +99,29 @@ _ret; \ }) -#define ufshcd_hex_dump(prefix_str, buf, len) \ -print_hex_dump(KERN_ERR, prefix_str, DUMP_PREFIX_OFFSET, 16, 4, buf, len, false) +#define ufshcd_hex_dump(prefix_str, buf, len) do { \ + size_t __len = (len); \ + print_hex_dump(KERN_ERR, prefix_str, \ + __len > 4 ? DUMP_PREFIX_OFFSET : DUMP_PREFIX_NONE,\ + 16, 4, buf, __len, false); \ +} while (0) + +int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, + const char *prefix) +{ + u8 *regs; + + regs = kzalloc(len, GFP_KERNEL); + if (!regs) + return -ENOMEM; + + memcpy_fromio(regs, hba->mmio_base + offset, len); + ufshcd_hex_dump(prefix, regs, len); + kfree(regs); + + return 0; +} +EXPORT_SYMBOL_GPL(ufshcd_dump_regs); enum { UFSHCD_MAX_CHANNEL = 0, @@ -376,15 +397,7 @@ static void ufshcd_print_uic_err_hist(struct ufs_hba *hba, static void ufshcd_print_host_regs(struct ufs_hba *hba) { - /* - * hex_dump reads its data without the readl macro. This might - * cause inconsistency issues on some platform, as the printed - * values may be from cache and not the most recent value. - * To know whether you are looking at an un-cached version verify - * that IORESOURCE_MEM flag is on when xxx_get_resource() is invoked - * during platform/pci probe function. - */ - ufshcd_hex_dump("host regs: ", hba->mmio_base, UFSHCI_REG_SPACE_SIZE); + ufshcd_dump_regs(hba, 0, UFSHCI_REG_SPACE_SIZE, "host_regs: "); dev_err(hba->dev, "hba->ufs_version = 0x%x, hba->capabilities = 0x%x\n", hba->ufs_version, hba->capabilities); dev_err(hba->dev, diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 8110dcd04d22..aad959ba3d9b 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1022,4 +1022,7 @@ static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun) return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID; } +int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, + const char *prefix); + #endif /* End of Header */ -- 2.14.4