Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ipa: introduce ipa_cmd_init()

Currently, ipa_cmd_data_valid() is called by ipa_mem_config().
Nothing it does requires access to hardware though, so it can be
done during the init phase of IPA driver startup.

Create a new function ipa_cmd_init(), whose purpose is to do early
initialization related to IPA immediate commands. It will call the
build-time validation function, then will make the two calls made
previously by ipa_cmd_data_valid(). This make ipa_cmd_data_valid()
unnecessary, so get rid of it.

Rename ipa_cmd_header_valid() to be ipa_cmd_header_init_local_valid(),
so its name is clearer about which IPA immediate command it is
associated with.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Alex Elder and committed by
Paolo Abeni
7fd10a2a 5444b0ea

+25 -20
+15 -16
drivers/net/ipa/ipa_cmd.c
··· 202 202 } 203 203 204 204 /* Validate the memory region that holds headers */ 205 - static bool ipa_cmd_header_valid(struct ipa *ipa) 205 + static bool ipa_cmd_header_init_local_valid(struct ipa *ipa) 206 206 { 207 207 struct device *dev = &ipa->pdev->dev; 208 208 const struct ipa_mem *mem; ··· 318 318 return true; 319 319 } 320 320 321 - bool ipa_cmd_data_valid(struct ipa *ipa) 322 - { 323 - if (!ipa_cmd_header_valid(ipa)) 324 - return false; 325 - 326 - if (!ipa_cmd_register_write_valid(ipa)) 327 - return false; 328 - 329 - return true; 330 - } 331 - 332 - 333 321 int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_max) 334 322 { 335 323 struct gsi_trans_info *trans_info = &channel->trans_info; 336 324 struct device *dev = channel->gsi->dev; 337 - 338 - /* This is as good a place as any to validate build constants */ 339 - ipa_cmd_validate_build(); 340 325 341 326 /* Command payloads are allocated one at a time, but a single 342 327 * transaction can require up to the maximum supported by the ··· 621 636 622 637 return gsi_channel_trans_alloc(&ipa->gsi, endpoint->channel_id, 623 638 tre_count, DMA_NONE); 639 + } 640 + 641 + /* Init function for immediate commands; there is no ipa_cmd_exit() */ 642 + int ipa_cmd_init(struct ipa *ipa) 643 + { 644 + ipa_cmd_validate_build(); 645 + 646 + if (!ipa_cmd_header_init_local_valid(ipa)) 647 + return -EINVAL; 648 + 649 + if (!ipa_cmd_register_write_valid(ipa)) 650 + return -EINVAL; 651 + 652 + return 0; 624 653 }
+10
drivers/net/ipa/ipa_cmd.h
··· 162 162 */ 163 163 struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count); 164 164 165 + /** 166 + * ipa_cmd_init() - Initialize IPA immediate commands 167 + * @ipa: - IPA pointer 168 + * 169 + * Return: 0 if successful, or a negative error code 170 + * 171 + * There is no need for a matching ipa_cmd_exit() function. 172 + */ 173 + int ipa_cmd_init(struct ipa *ipa); 174 + 165 175 #endif /* _IPA_CMD_H_ */
-4
drivers/net/ipa/ipa_mem.c
··· 370 370 if (!ipa_table_valid(ipa)) 371 371 goto err_dma_free; 372 372 373 - /* Validate memory-related properties relevant to immediate commands */ 374 - if (!ipa_cmd_data_valid(ipa)) 375 - goto err_dma_free; 376 - 377 373 /* Verify the microcontroller ring alignment (if defined) */ 378 374 mem = ipa_mem_find(ipa, IPA_MEM_UC_EVENT_RING); 379 375 if (mem && mem->offset % 1024) {