* [PATCH 0/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry
@ 2023-03-15 19:21 Desnes Nunes
2023-03-15 19:21 ` [PATCH 1/3] dma-debug: small dma_debug_entry's comment and variable name updates Desnes Nunes
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Desnes Nunes @ 2023-03-15 19:21 UTC (permalink / raw)
To: iommu, linux-scsi, storagedev, linux-kernel
Cc: hch, martin.petersen, don.brace, m.szyprowski, robin.murphy,
jejb, jsnitsel, Desnes Nunes
In summary, this series fixes an overlapping mappings asymmetry on the
smartpqi driver due to a missing pqi_pci_unmap() call, while also adding
the cacheline on debug messages of dma-debug debugging functions.
Other minor non-functional updates are also provided.
Desnes Nunes (3):
dma-debug: small dma_debug_entry's comment and variable name updates
dma-debug: add cacheline to user/kernel space dump messages
scsi: smartpqi: fix overlapping mappings asymmetry on DMA
drivers/scsi/smartpqi/smartpqi_init.c | 2 +
kernel/dma/debug.c | 133 ++++++++++++++------------
2 files changed, 72 insertions(+), 63 deletions(-)
--
2.39.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] dma-debug: small dma_debug_entry's comment and variable name updates
2023-03-15 19:21 [PATCH 0/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry Desnes Nunes
@ 2023-03-15 19:21 ` Desnes Nunes
2023-03-16 10:24 ` Robin Murphy
2023-03-15 19:21 ` [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages Desnes Nunes
2023-03-15 19:21 ` [PATCH 3/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry Desnes Nunes
2 siblings, 1 reply; 8+ messages in thread
From: Desnes Nunes @ 2023-03-15 19:21 UTC (permalink / raw)
To: iommu, linux-scsi, storagedev, linux-kernel
Cc: hch, martin.petersen, don.brace, m.szyprowski, robin.murphy,
jejb, jsnitsel, Desnes Nunes
Small update on dma_debug_entry's struct commentary and also standardize
the usage of 'dma_addr' variable name from debug_dma_map_page() on
debug_dma_unmap_page(), and similarly on debug_dma_free_coherent()
Signed-off-by: Desnes Nunes <desnesn@redhat.com>
---
kernel/dma/debug.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index 18c93c2276ca..e0ad8db1ec25 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -52,7 +52,8 @@ enum map_err_types {
/**
* struct dma_debug_entry - track a dma_map* or dma_alloc_coherent mapping
* @list: node on pre-allocated free_entries list
- * @dev: 'dev' argument to dma_map_{page|single|sg} or dma_alloc_coherent
+ * @dev: pointer to the device driver
+ * @dev_addr: 'dev' argument to dma_map_{page|single|sg} or dma_alloc_coherent
* @size: length of the mapping
* @type: single, page, sg, coherent
* @direction: enum dma_data_direction
@@ -1262,13 +1263,13 @@ void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
}
EXPORT_SYMBOL(debug_dma_mapping_error);
-void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
+void debug_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
size_t size, int direction)
{
struct dma_debug_entry ref = {
.type = dma_debug_single,
.dev = dev,
- .dev_addr = addr,
+ .dev_addr = dma_addr,
.size = size,
.direction = direction,
};
@@ -1403,13 +1404,13 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
}
void debug_dma_free_coherent(struct device *dev, size_t size,
- void *virt, dma_addr_t addr)
+ void *virt, dma_addr_t dma_addr)
{
struct dma_debug_entry ref = {
.type = dma_debug_coherent,
.dev = dev,
.offset = offset_in_page(virt),
- .dev_addr = addr,
+ .dev_addr = dma_addr,
.size = size,
.direction = DMA_BIDIRECTIONAL,
};
--
2.39.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages
2023-03-15 19:21 [PATCH 0/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry Desnes Nunes
2023-03-15 19:21 ` [PATCH 1/3] dma-debug: small dma_debug_entry's comment and variable name updates Desnes Nunes
@ 2023-03-15 19:21 ` Desnes Nunes
2023-03-15 21:46 ` kernel test robot
2023-03-16 1:32 ` kernel test robot
2023-03-15 19:21 ` [PATCH 3/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry Desnes Nunes
2 siblings, 2 replies; 8+ messages in thread
From: Desnes Nunes @ 2023-03-15 19:21 UTC (permalink / raw)
To: iommu, linux-scsi, storagedev, linux-kernel
Cc: hch, martin.petersen, don.brace, m.szyprowski, robin.murphy,
jejb, jsnitsel, Desnes Nunes
Having the cacheline also printed on the debug_dma_dump_mappings() and
dump_show() is useful for debugging. Furthermore, this also standardizes
the messages shown on both dump functions.
Signed-off-by: Desnes Nunes <desnesn@redhat.com>
---
kernel/dma/debug.c | 122 ++++++++++++++++++++++++---------------------
1 file changed, 64 insertions(+), 58 deletions(-)
diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index e0ad8db1ec25..19cc59829ffd 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -396,37 +396,6 @@ static unsigned long long phys_addr(struct dma_debug_entry *entry)
return page_to_phys(pfn_to_page(entry->pfn)) + entry->offset;
}
-/*
- * Dump mapping entries for debugging purposes
- */
-void debug_dma_dump_mappings(struct device *dev)
-{
- int idx;
-
- for (idx = 0; idx < HASH_SIZE; idx++) {
- struct hash_bucket *bucket = &dma_entry_hash[idx];
- struct dma_debug_entry *entry;
- unsigned long flags;
-
- spin_lock_irqsave(&bucket->lock, flags);
-
- list_for_each_entry(entry, &bucket->list, list) {
- if (!dev || dev == entry->dev) {
- dev_info(entry->dev,
- "%s idx %d P=%Lx N=%lx D=%Lx L=%Lx %s %s\n",
- type2name[entry->type], idx,
- phys_addr(entry), entry->pfn,
- entry->dev_addr, entry->size,
- dir2name[entry->direction],
- maperr2str[entry->map_err_type]);
- }
- }
-
- spin_unlock_irqrestore(&bucket->lock, flags);
- cond_resched();
- }
-}
-
/*
* For each mapping (initial cacheline in the case of
* dma_alloc_coherent/dma_map_page, initial cacheline in each page of a
@@ -547,6 +516,70 @@ static void active_cacheline_remove(struct dma_debug_entry *entry)
spin_unlock_irqrestore(&radix_lock, flags);
}
+/*
+ * Dump mappings entries on kernel space for debugging purposes
+ */
+void debug_dma_dump_mappings(struct device *dev)
+{
+ int idx;
+ phys_addr_t cln;
+
+ for (idx = 0; idx < HASH_SIZE; idx++) {
+ struct hash_bucket *bucket = &dma_entry_hash[idx];
+ struct dma_debug_entry *entry;
+ unsigned long flags;
+
+ spin_lock_irqsave(&bucket->lock, flags);
+ list_for_each_entry(entry, &bucket->list, list) {
+ if (!dev || dev == entry->dev) {
+ cln = to_cacheline_number(entry);
+ dev_info(entry->dev,
+ "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
+ type2name[entry->type], idx,
+ phys_addr(entry), entry->pfn,
+ entry->dev_addr, entry->size,
+ cln, dir2name[entry->direction],
+ maperr2str[entry->map_err_type]);
+ }
+ }
+ spin_unlock_irqrestore(&bucket->lock, flags);
+
+ cond_resched();
+ }
+}
+
+/*
+ * Dump mappings entries on user space via debugfs
+ */
+static int dump_show(struct seq_file *seq, void *v)
+{
+ int idx;
+ phys_addr_t cln;
+
+ for (idx = 0; idx < HASH_SIZE; idx++) {
+ struct hash_bucket *bucket = &dma_entry_hash[idx];
+ struct dma_debug_entry *entry;
+ unsigned long flags;
+
+ spin_lock_irqsave(&bucket->lock, flags);
+ list_for_each_entry(entry, &bucket->list, list) {
+ cln = to_cacheline_number(entry);
+ seq_printf(seq,
+ "%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
+ dev_driver_string(entry->dev),
+ dev_name(entry->dev),
+ type2name[entry->type], idx,
+ phys_addr(entry), entry->pfn,
+ entry->dev_addr, entry->size,
+ cln, dir2name[entry->direction],
+ maperr2str[entry->map_err_type]);
+ }
+ spin_unlock_irqrestore(&bucket->lock, flags);
+ }
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(dump);
+
/*
* Wrapper function for adding an entry to the hash.
* This function takes care of locking itself.
@@ -765,33 +798,6 @@ static const struct file_operations filter_fops = {
.llseek = default_llseek,
};
-static int dump_show(struct seq_file *seq, void *v)
-{
- int idx;
-
- for (idx = 0; idx < HASH_SIZE; idx++) {
- struct hash_bucket *bucket = &dma_entry_hash[idx];
- struct dma_debug_entry *entry;
- unsigned long flags;
-
- spin_lock_irqsave(&bucket->lock, flags);
- list_for_each_entry(entry, &bucket->list, list) {
- seq_printf(seq,
- "%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx %s %s\n",
- dev_name(entry->dev),
- dev_driver_string(entry->dev),
- type2name[entry->type], idx,
- phys_addr(entry), entry->pfn,
- entry->dev_addr, entry->size,
- dir2name[entry->direction],
- maperr2str[entry->map_err_type]);
- }
- spin_unlock_irqrestore(&bucket->lock, flags);
- }
- return 0;
-}
-DEFINE_SHOW_ATTRIBUTE(dump);
-
static int __init dma_debug_fs_init(void)
{
struct dentry *dentry = debugfs_create_dir("dma-api", NULL);
--
2.39.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry
2023-03-15 19:21 [PATCH 0/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry Desnes Nunes
2023-03-15 19:21 ` [PATCH 1/3] dma-debug: small dma_debug_entry's comment and variable name updates Desnes Nunes
2023-03-15 19:21 ` [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages Desnes Nunes
@ 2023-03-15 19:21 ` Desnes Nunes
2 siblings, 0 replies; 8+ messages in thread
From: Desnes Nunes @ 2023-03-15 19:21 UTC (permalink / raw)
To: iommu, linux-scsi, storagedev, linux-kernel
Cc: hch, martin.petersen, don.brace, m.szyprowski, robin.murphy,
jejb, jsnitsel, Desnes Nunes
Currently, pqi_keep_device_offline() calls pqi_build_raid_path_request()
(i.e., a wrapper to pqi_map_single()), but there isn't a pqi_pci_unmap()
call in pqi_keep_device_offline(). Hence, this is flaged as an API viola-
tion due to the overlapping mapping of the physical address.
This patch fixes following warning:
DMA-API: smartpqi 0000:43:00.0: cacheline tracking EEXIST, overlapping
mappings aren't supported
WARNING: CPU: 0 PID: 15 at kernel/dma/debug.c:570
add_dma_entry+0x1f6/0x2f0
CPU: 0 PID: 15 Comm: kworker/0:1 Not tainted 6.3.0-rc1-linux #1
Call Trace:
<TASK>
dma_map_page_attrs+0x6f/0xa0
pqi_map_single+0xaa/0x160 [smartpqi]
pqi_keep_device_offline+0xaf/0x160 [smartpqi]
? dma_unmap_page_attrs+0x1a1/0x1e0
? pqi_identify_physical_device.constprop.0+0xd3/0xe0 [smartpqi]
pqi_update_scsi_devices+0x284/0x7e0 [smartpqi]
pqi_scan_scsi_devices+0x87/0xe0 [smartpqi]
pqi_ctrl_init+0x725/0xa60 [smartpqi]
pqi_pci_probe+0xa7/0x130 [smartpqi]
local_pci_probe+0x46/0xa0
work_for_cpu_fn+0x16/0x20
process_one_work+0x2bf/0x670
? __pfx_worker_thread+0x10/0x10
worker_thread+0x1d1/0x3b0
? __pfx_worker_thread+0x10/0x10
kthread+0xf3/0x120
? __pfx_kthread+0x10/0x10
ret_from_fork+0x2c/0x50
</TASK>
Fixes: be76f90668d8 ("scsi: smartpqi: Add TEST UNIT READY check for SANITIZE operation")
Signed-off-by: Desnes Nunes <desnesn@redhat.com>
---
drivers/scsi/smartpqi/smartpqi_init.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 49a8f91810b6..6fca497ca605 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -1726,6 +1726,8 @@ static bool pqi_keep_device_offline(struct pqi_ctrl_info *ctrl_info,
rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, 0, &error_info);
+ pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, dir);
+
if (rc)
goto out; /* Assume not offline */
--
2.39.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages
2023-03-15 19:21 ` [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages Desnes Nunes
@ 2023-03-15 21:46 ` kernel test robot
2023-03-16 1:32 ` kernel test robot
1 sibling, 0 replies; 8+ messages in thread
From: kernel test robot @ 2023-03-15 21:46 UTC (permalink / raw)
To: Desnes Nunes, iommu, linux-scsi, storagedev, linux-kernel
Cc: oe-kbuild-all, hch, martin.petersen, don.brace, m.szyprowski,
robin.murphy, jejb, jsnitsel, Desnes Nunes
Hi Desnes,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on jejb-scsi/for-next]
[also build test WARNING on mkp-scsi/for-next linus/master hch-configfs/for-next v6.3-rc2 next-20230315]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Desnes-Nunes/dma-debug-small-dma_debug_entry-s-comment-and-variable-name-updates/20230316-032542
base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link: https://lore.kernel.org/r/20230315192130.970021-3-desnesn%40redhat.com
patch subject: [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230316/202303160548.ReyuTsGD-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ae3f8fdd17c54b837d476952733456723c472ed8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Desnes-Nunes/dma-debug-small-dma_debug_entry-s-comment-and-variable-name-updates/20230316-032542
git checkout ae3f8fdd17c54b837d476952733456723c472ed8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash kernel/dma/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303160548.ReyuTsGD-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/dma-mapping.h:7,
from include/linux/dma-map-ops.h:9,
from kernel/dma/debug.c:12:
kernel/dma/debug.c: In function 'debug_dma_dump_mappings':
>> kernel/dma/debug.c:537:42: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 9 has type 'phys_addr_t' {aka 'unsigned int'} [-Wformat=]
537 | "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:150:58: note: in expansion of macro 'dev_fmt'
150 | dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
kernel/dma/debug.c:536:33: note: in expansion of macro 'dev_info'
536 | dev_info(entry->dev,
| ^~~~~~~~
kernel/dma/debug.c:537:87: note: format string is defined here
537 | "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
| ~~~^
| |
| long long unsigned int
| %x
kernel/dma/debug.c: In function 'dump_show':
kernel/dma/debug.c:568:87: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 11 has type 'phys_addr_t' {aka 'unsigned int'} [-Wformat=]
568 | "%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
| ~~~^
| |
| long long unsigned int
| %x
......
574 | cln, dir2name[entry->direction],
| ~~~
| |
| phys_addr_t {aka unsigned int}
vim +537 kernel/dma/debug.c
518
519 /*
520 * Dump mappings entries on kernel space for debugging purposes
521 */
522 void debug_dma_dump_mappings(struct device *dev)
523 {
524 int idx;
525 phys_addr_t cln;
526
527 for (idx = 0; idx < HASH_SIZE; idx++) {
528 struct hash_bucket *bucket = &dma_entry_hash[idx];
529 struct dma_debug_entry *entry;
530 unsigned long flags;
531
532 spin_lock_irqsave(&bucket->lock, flags);
533 list_for_each_entry(entry, &bucket->list, list) {
534 if (!dev || dev == entry->dev) {
535 cln = to_cacheline_number(entry);
536 dev_info(entry->dev,
> 537 "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
538 type2name[entry->type], idx,
539 phys_addr(entry), entry->pfn,
540 entry->dev_addr, entry->size,
541 cln, dir2name[entry->direction],
542 maperr2str[entry->map_err_type]);
543 }
544 }
545 spin_unlock_irqrestore(&bucket->lock, flags);
546
547 cond_resched();
548 }
549 }
550
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages
2023-03-15 19:21 ` [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages Desnes Nunes
2023-03-15 21:46 ` kernel test robot
@ 2023-03-16 1:32 ` kernel test robot
1 sibling, 0 replies; 8+ messages in thread
From: kernel test robot @ 2023-03-16 1:32 UTC (permalink / raw)
To: Desnes Nunes, iommu, linux-scsi, storagedev, linux-kernel
Cc: llvm, oe-kbuild-all, hch, martin.petersen, don.brace,
m.szyprowski, robin.murphy, jejb, jsnitsel, Desnes Nunes
Hi Desnes,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on jejb-scsi/for-next]
[also build test WARNING on mkp-scsi/for-next linus/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Desnes-Nunes/dma-debug-small-dma_debug_entry-s-comment-and-variable-name-updates/20230316-032542
base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link: https://lore.kernel.org/r/20230315192130.970021-3-desnesn%40redhat.com
patch subject: [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages
config: arm-randconfig-r046-20230312 (https://download.01.org/0day-ci/archive/20230316/202303160927.dwt0jHFb-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/ae3f8fdd17c54b837d476952733456723c472ed8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Desnes-Nunes/dma-debug-small-dma_debug_entry-s-comment-and-variable-name-updates/20230316-032542
git checkout ae3f8fdd17c54b837d476952733456723c472ed8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash kernel/dma/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303160927.dwt0jHFb-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> kernel/dma/debug.c:541:7: warning: format specifies type 'unsigned long long' but the argument has type 'phys_addr_t' (aka 'unsigned int') [-Wformat]
cln, dir2name[entry->direction],
^~~
include/linux/dev_printk.h:150:67: note: expanded from macro 'dev_info'
dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
_p_func(dev, fmt, ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
kernel/dma/debug.c:574:8: warning: format specifies type 'unsigned long long' but the argument has type 'phys_addr_t' (aka 'unsigned int') [-Wformat]
cln, dir2name[entry->direction],
^~~
2 warnings generated.
vim +541 kernel/dma/debug.c
518
519 /*
520 * Dump mappings entries on kernel space for debugging purposes
521 */
522 void debug_dma_dump_mappings(struct device *dev)
523 {
524 int idx;
525 phys_addr_t cln;
526
527 for (idx = 0; idx < HASH_SIZE; idx++) {
528 struct hash_bucket *bucket = &dma_entry_hash[idx];
529 struct dma_debug_entry *entry;
530 unsigned long flags;
531
532 spin_lock_irqsave(&bucket->lock, flags);
533 list_for_each_entry(entry, &bucket->list, list) {
534 if (!dev || dev == entry->dev) {
535 cln = to_cacheline_number(entry);
536 dev_info(entry->dev,
537 "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
538 type2name[entry->type], idx,
539 phys_addr(entry), entry->pfn,
540 entry->dev_addr, entry->size,
> 541 cln, dir2name[entry->direction],
542 maperr2str[entry->map_err_type]);
543 }
544 }
545 spin_unlock_irqrestore(&bucket->lock, flags);
546
547 cond_resched();
548 }
549 }
550
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] dma-debug: small dma_debug_entry's comment and variable name updates
2023-03-15 19:21 ` [PATCH 1/3] dma-debug: small dma_debug_entry's comment and variable name updates Desnes Nunes
@ 2023-03-16 10:24 ` Robin Murphy
2023-03-16 14:06 ` Desnes Nunes
0 siblings, 1 reply; 8+ messages in thread
From: Robin Murphy @ 2023-03-16 10:24 UTC (permalink / raw)
To: Desnes Nunes, iommu, linux-scsi, storagedev, linux-kernel
Cc: hch, martin.petersen, don.brace, m.szyprowski, jejb, jsnitsel
On 2023-03-15 19:21, Desnes Nunes wrote:
> Small update on dma_debug_entry's struct commentary and also standardize
> the usage of 'dma_addr' variable name from debug_dma_map_page() on
> debug_dma_unmap_page(), and similarly on debug_dma_free_coherent()
>
> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
> ---
> kernel/dma/debug.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
> index 18c93c2276ca..e0ad8db1ec25 100644
> --- a/kernel/dma/debug.c
> +++ b/kernel/dma/debug.c
> @@ -52,7 +52,8 @@ enum map_err_types {
> /**
> * struct dma_debug_entry - track a dma_map* or dma_alloc_coherent mapping
> * @list: node on pre-allocated free_entries list
> - * @dev: 'dev' argument to dma_map_{page|single|sg} or dma_alloc_coherent
> + * @dev: pointer to the device driver
The original comment was correct...
> + * @dev_addr: 'dev' argument to dma_map_{page|single|sg} or dma_alloc_coherent
...and the address is clearly not the argument representing the device,
since it is an address :/
Thanks,
Robin.
> * @size: length of the mapping
> * @type: single, page, sg, coherent
> * @direction: enum dma_data_direction
> @@ -1262,13 +1263,13 @@ void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
> }
> EXPORT_SYMBOL(debug_dma_mapping_error);
>
> -void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
> +void debug_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
> size_t size, int direction)
> {
> struct dma_debug_entry ref = {
> .type = dma_debug_single,
> .dev = dev,
> - .dev_addr = addr,
> + .dev_addr = dma_addr,
> .size = size,
> .direction = direction,
> };
> @@ -1403,13 +1404,13 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
> }
>
> void debug_dma_free_coherent(struct device *dev, size_t size,
> - void *virt, dma_addr_t addr)
> + void *virt, dma_addr_t dma_addr)
> {
> struct dma_debug_entry ref = {
> .type = dma_debug_coherent,
> .dev = dev,
> .offset = offset_in_page(virt),
> - .dev_addr = addr,
> + .dev_addr = dma_addr,
> .size = size,
> .direction = DMA_BIDIRECTIONAL,
> };
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] dma-debug: small dma_debug_entry's comment and variable name updates
2023-03-16 10:24 ` Robin Murphy
@ 2023-03-16 14:06 ` Desnes Nunes
0 siblings, 0 replies; 8+ messages in thread
From: Desnes Nunes @ 2023-03-16 14:06 UTC (permalink / raw)
To: Robin Murphy
Cc: iommu, linux-scsi, storagedev, linux-kernel, hch,
martin.petersen, don.brace, m.szyprowski, jejb, jsnitsel
Good day Robin,
Thank you very much for the review and clarification - will send a v2
with the proper comment update.
Best Regards,
On Thu, Mar 16, 2023 at 7:24 AM Robin Murphy <robin.murphy@arm.com> wrote:
>
> On 2023-03-15 19:21, Desnes Nunes wrote:
> > Small update on dma_debug_entry's struct commentary and also standardize
> > the usage of 'dma_addr' variable name from debug_dma_map_page() on
> > debug_dma_unmap_page(), and similarly on debug_dma_free_coherent()
> >
> > Signed-off-by: Desnes Nunes <desnesn@redhat.com>
> > ---
> > kernel/dma/debug.c | 11 ++++++-----
> > 1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
> > index 18c93c2276ca..e0ad8db1ec25 100644
> > --- a/kernel/dma/debug.c
> > +++ b/kernel/dma/debug.c
> > @@ -52,7 +52,8 @@ enum map_err_types {
> > /**
> > * struct dma_debug_entry - track a dma_map* or dma_alloc_coherent mapping
> > * @list: node on pre-allocated free_entries list
> > - * @dev: 'dev' argument to dma_map_{page|single|sg} or dma_alloc_coherent
> > + * @dev: pointer to the device driver
>
> The original comment was correct...
>
> > + * @dev_addr: 'dev' argument to dma_map_{page|single|sg} or dma_alloc_coherent
>
> ...and the address is clearly not the argument representing the device,
> since it is an address :/
>
> Thanks,
> Robin.
>
> > * @size: length of the mapping
> > * @type: single, page, sg, coherent
> > * @direction: enum dma_data_direction
> > @@ -1262,13 +1263,13 @@ void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
> > }
> > EXPORT_SYMBOL(debug_dma_mapping_error);
> >
> > -void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
> > +void debug_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
> > size_t size, int direction)
> > {
> > struct dma_debug_entry ref = {
> > .type = dma_debug_single,
> > .dev = dev,
> > - .dev_addr = addr,
> > + .dev_addr = dma_addr,
> > .size = size,
> > .direction = direction,
> > };
> > @@ -1403,13 +1404,13 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
> > }
> >
> > void debug_dma_free_coherent(struct device *dev, size_t size,
> > - void *virt, dma_addr_t addr)
> > + void *virt, dma_addr_t dma_addr)
> > {
> > struct dma_debug_entry ref = {
> > .type = dma_debug_coherent,
> > .dev = dev,
> > .offset = offset_in_page(virt),
> > - .dev_addr = addr,
> > + .dev_addr = dma_addr,
> > .size = size,
> > .direction = DMA_BIDIRECTIONAL,
> > };
>
--
Desnes Nunes
Principal Software Engineer
Red Hat Brasil
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-16 14:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15 19:21 [PATCH 0/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry Desnes Nunes
2023-03-15 19:21 ` [PATCH 1/3] dma-debug: small dma_debug_entry's comment and variable name updates Desnes Nunes
2023-03-16 10:24 ` Robin Murphy
2023-03-16 14:06 ` Desnes Nunes
2023-03-15 19:21 ` [PATCH 2/3] dma-debug: add cacheline to user/kernel space dump messages Desnes Nunes
2023-03-15 21:46 ` kernel test robot
2023-03-16 1:32 ` kernel test robot
2023-03-15 19:21 ` [PATCH 3/3] scsi: smartpqi: fix DMA overlapping mappings asymmetry Desnes Nunes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).