drivers/crypto/qat/qat_4xxx/adf_drv.c:134:34: warning: taking address of packed member 'status' of class or structure 'adf_accel_dev' may result in an unaligned pointer value

From: kernel test robot
Date: Tue Aug 31 2021 - 14:39:41 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b91db6a0b52e019b6bdabea3f1dbe36d85c7e52c
commit: 8c8268166e83425243789c5781c92e7fa33b703b crypto: qat - add qat_4xxx driver
date: 10 months ago
config: i386-randconfig-r012-20210831 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b1fde8a2b681dad2ce0c082a5d6422caa06b0bc)
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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8c8268166e83425243789c5781c92e7fa33b703b
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 8c8268166e83425243789c5781c92e7fa33b703b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

clang-14: warning: optimization flag '-falign-jumps=0' is not supported [-Wignored-optimization-argument]
In file included from drivers/crypto/qat/qat_4xxx/adf_drv.c:3:
In file included from include/linux/device.h:15:
In file included from include/linux/dev_printk.h:16:
In file included from include/linux/ratelimit.h:6:
In file included from include/linux/sched.h:14:
In file included from include/linux/pid.h:5:
In file included from include/linux/rculist.h:11:
In file included from include/linux/rcupdate.h:27:
In file included from include/linux/preempt.h:78:
In file included from arch/x86/include/asm/preempt.h:7:
In file included from include/linux/thread_info.h:38:
arch/x86/include/asm/thread_info.h:183:13: warning: calling '__builtin_frame_address' with a nonzero argument is unsafe [-Wframe-address]
oldframe = __builtin_frame_address(1);
^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/include/asm/thread_info.h:185:11: warning: calling '__builtin_frame_address' with a nonzero argument is unsafe [-Wframe-address]
frame = __builtin_frame_address(2);
^~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/crypto/qat/qat_4xxx/adf_drv.c:134:34: warning: taking address of packed member 'status' of class or structure 'adf_accel_dev' may result in an unaligned pointer value [-Waddress-of-packed-member]
set_bit(ADF_STATUS_CONFIGURED, &accel_dev->status);
^~~~~~~~~~~~~~~~~
>> drivers/crypto/qat/qat_4xxx/adf_drv.c:166:18: warning: taking address of packed member 'crypto_list' of class or structure 'adf_accel_dev' may result in an unaligned pointer value [-Waddress-of-packed-member]
INIT_LIST_HEAD(&accel_dev->crypto_list);
^~~~~~~~~~~~~~~~~~~~~~
>> drivers/crypto/qat/qat_4xxx/adf_drv.c:191:57: warning: taking address of packed member 'fuses' of class or structure 'adf_hw_device_data' may result in an unaligned pointer value [-Waddress-of-packed-member]
pci_read_config_dword(pdev, ADF_4XXX_FUSECTL4_OFFSET, &hw_data->fuses);
^~~~~~~~~~~~~~
5 warnings generated.
--
clang-14: warning: optimization flag '-falign-jumps=0' is not supported [-Wignored-optimization-argument]
In file included from drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c:3:
In file included from drivers/crypto/qat/qat_4xxx/../qat_common/adf_accel_devices.h:5:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:5:
In file included from include/linux/context_tracking_state.h:5:
In file included from include/linux/percpu.h:6:
In file included from include/linux/preempt.h:78:
In file included from arch/x86/include/asm/preempt.h:7:
In file included from include/linux/thread_info.h:38:
arch/x86/include/asm/thread_info.h:183:13: warning: calling '__builtin_frame_address' with a nonzero argument is unsafe [-Wframe-address]
oldframe = __builtin_frame_address(1);
^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/include/asm/thread_info.h:185:11: warning: calling '__builtin_frame_address' with a nonzero argument is unsafe [-Wframe-address]
frame = __builtin_frame_address(2);
^~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c:212:28: warning: taking address of packed member 'csr_ops' of class or structure 'adf_hw_device_data' may result in an unaligned pointer value [-Waddress-of-packed-member]
adf_gen4_init_hw_csr_ops(&hw_data->csr_ops);
^~~~~~~~~~~~~~~~
3 warnings generated.


vim +134 drivers/crypto/qat/qat_4xxx/adf_drv.c

31
32 static int adf_crypto_dev_config(struct adf_accel_dev *accel_dev)
33 {
34 char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
35 int banks = GET_MAX_BANKS(accel_dev);
36 int cpus = num_online_cpus();
37 unsigned long bank, val;
38 int instances;
39 int ret;
40 int i;
41
42 if (adf_hw_dev_has_crypto(accel_dev))
43 instances = min(cpus, banks / 2);
44 else
45 instances = 0;
46
47 ret = adf_cfg_section_add(accel_dev, ADF_KERNEL_SEC);
48 if (ret)
49 goto err;
50
51 ret = adf_cfg_section_add(accel_dev, "Accelerator0");
52 if (ret)
53 goto err;
54
55 for (i = 0; i < instances; i++) {
56 val = i;
57 bank = i * 2;
58 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_BANK_NUM, i);
59 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
60 key, &bank, ADF_DEC);
61 if (ret)
62 goto err;
63
64 bank += 1;
65 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_BANK_NUM, i);
66 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
67 key, &bank, ADF_DEC);
68 if (ret)
69 goto err;
70
71 snprintf(key, sizeof(key), ADF_CY "%d" ADF_ETRMGR_CORE_AFFINITY,
72 i);
73 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
74 key, &val, ADF_DEC);
75 if (ret)
76 goto err;
77
78 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_SIZE, i);
79 val = 128;
80 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
81 key, &val, ADF_DEC);
82 if (ret)
83 goto err;
84
85 val = 512;
86 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_SIZE, i);
87 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
88 key, &val, ADF_DEC);
89 if (ret)
90 goto err;
91
92 val = 0;
93 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_TX, i);
94 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
95 key, &val, ADF_DEC);
96 if (ret)
97 goto err;
98
99 val = 0;
100 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_TX, i);
101 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
102 key, &val, ADF_DEC);
103 if (ret)
104 goto err;
105
106 val = 1;
107 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_RX, i);
108 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
109 key, &val, ADF_DEC);
110 if (ret)
111 goto err;
112
113 val = 1;
114 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_RX, i);
115 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
116 key, &val, ADF_DEC);
117 if (ret)
118 goto err;
119
120 val = ADF_COALESCING_DEF_TIME;
121 snprintf(key, sizeof(key), ADF_ETRMGR_COALESCE_TIMER_FORMAT, i);
122 ret = adf_cfg_add_key_value_param(accel_dev, "Accelerator0",
123 key, &val, ADF_DEC);
124 if (ret)
125 goto err;
126 }
127
128 val = i;
129 ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC, ADF_NUM_CY,
130 &val, ADF_DEC);
131 if (ret)
132 goto err;
133
> 134 set_bit(ADF_STATUS_CONFIGURED, &accel_dev->status);
135 return 0;
136 err:
137 dev_err(&GET_DEV(accel_dev), "Failed to start QAT accel dev\n");
138 return ret;
139 }
140
141 static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
142 {
143 struct adf_accel_dev *accel_dev;
144 struct adf_accel_pci *accel_pci_dev;
145 struct adf_hw_device_data *hw_data;
146 char name[ADF_DEVICE_NAME_LENGTH];
147 unsigned int i, bar_nr;
148 unsigned long bar_mask;
149 struct adf_bar *bar;
150 int ret;
151
152 if (num_possible_nodes() > 1 && dev_to_node(&pdev->dev) < 0) {
153 /*
154 * If the accelerator is connected to a node with no memory
155 * there is no point in using the accelerator since the remote
156 * memory transaction will be very slow.
157 */
158 dev_err(&pdev->dev, "Invalid NUMA configuration.\n");
159 return -EINVAL;
160 }
161
162 accel_dev = devm_kzalloc(&pdev->dev, sizeof(*accel_dev), GFP_KERNEL);
163 if (!accel_dev)
164 return -ENOMEM;
165
> 166 INIT_LIST_HEAD(&accel_dev->crypto_list);
167 accel_pci_dev = &accel_dev->accel_pci_dev;
168 accel_pci_dev->pci_dev = pdev;
169
170 /*
171 * Add accel device to accel table
172 * This should be called before adf_cleanup_accel is called
173 */
174 if (adf_devmgr_add_dev(accel_dev, NULL)) {
175 dev_err(&pdev->dev, "Failed to add new accelerator device.\n");
176 return -EFAULT;
177 }
178
179 accel_dev->owner = THIS_MODULE;
180 /* Allocate and initialise device hardware meta-data structure */
181 hw_data = devm_kzalloc(&pdev->dev, sizeof(*hw_data), GFP_KERNEL);
182 if (!hw_data) {
183 ret = -ENOMEM;
184 goto out_err;
185 }
186
187 accel_dev->hw_device = hw_data;
188 adf_init_hw_data_4xxx(accel_dev->hw_device);
189
190 pci_read_config_byte(pdev, PCI_REVISION_ID, &accel_pci_dev->revid);
> 191 pci_read_config_dword(pdev, ADF_4XXX_FUSECTL4_OFFSET, &hw_data->fuses);
192
193 /* Get Accelerators and Accelerators Engines masks */
194 hw_data->accel_mask = hw_data->get_accel_mask(hw_data);
195 hw_data->ae_mask = hw_data->get_ae_mask(hw_data);
196 accel_pci_dev->sku = hw_data->get_sku(hw_data);
197 /* If the device has no acceleration engines then ignore it */
198 if (!hw_data->accel_mask || !hw_data->ae_mask ||
199 (~hw_data->ae_mask & 0x01)) {
200 dev_err(&pdev->dev, "No acceleration units found.\n");
201 ret = -EFAULT;
202 goto out_err;
203 }
204
205 /* Create dev top level debugfs entry */
206 snprintf(name, sizeof(name), "%s%s_%s", ADF_DEVICE_NAME_PREFIX,
207 hw_data->dev_class->name, pci_name(pdev));
208
209 accel_dev->debugfs_dir = debugfs_create_dir(name, NULL);
210
211 /* Create device configuration table */
212 ret = adf_cfg_dev_add(accel_dev);
213 if (ret)
214 goto out_err;
215
216 /* Enable PCI device */
217 ret = pcim_enable_device(pdev);
218 if (ret) {
219 dev_err(&pdev->dev, "Can't enable PCI device.\n");
220 goto out_err;
221 }
222
223 /* Set DMA identifier */
224 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
225 if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) {
226 dev_err(&pdev->dev, "No usable DMA configuration.\n");
227 ret = -EFAULT;
228 goto out_err;
229 } else {
230 pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
231 }
232 } else {
233 pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
234 }
235
236 /* Find and map all the device's BARS */
237 bar_mask = pci_select_bars(pdev, IORESOURCE_MEM) & ADF_4XXX_BAR_MASK;
238
239 ret = pcim_iomap_regions_request_all(pdev, bar_mask, pci_name(pdev));
240 if (ret) {
241 dev_err(&pdev->dev, "Failed to map pci regions.\n");
242 goto out_err;
243 }
244
245 i = 0;
246 for_each_set_bit(bar_nr, &bar_mask, PCI_STD_NUM_BARS) {
247 bar = &accel_pci_dev->pci_bars[i++];
248 bar->virt_addr = pcim_iomap_table(pdev)[bar_nr];
249 }
250
251 pci_set_master(pdev);
252
253 if (adf_enable_aer(accel_dev)) {
254 dev_err(&pdev->dev, "Failed to enable aer.\n");
255 ret = -EFAULT;
256 goto out_err;
257 }
258
259 if (pci_save_state(pdev)) {
260 dev_err(&pdev->dev, "Failed to save pci state.\n");
261 ret = -ENOMEM;
262 goto out_err_disable_aer;
263 }
264
265 ret = adf_crypto_dev_config(accel_dev);
266 if (ret)
267 goto out_err_disable_aer;
268
269 ret = adf_dev_init(accel_dev);
270 if (ret)
271 goto out_err_dev_shutdown;
272
273 ret = adf_dev_start(accel_dev);
274 if (ret)
275 goto out_err_dev_stop;
276
277 return ret;
278
279 out_err_dev_stop:
280 adf_dev_stop(accel_dev);
281 out_err_dev_shutdown:
282 adf_dev_shutdown(accel_dev);
283 out_err_disable_aer:
284 adf_disable_aer(accel_dev);
285 out_err:
286 adf_cleanup_accel(accel_dev);
287 return ret;
288 }
289

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip