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

Configure Feed

Select the types of activity you want to include in your feed.

media: pisp_be: Remove config validation from schedule()

The config parameters buffer is already validated in
pisp_be_validate_config() at .buf_prepare() time.

However some of the same validations are also performed at
pispbe_schedule() time. In particular the function checks that:

1) config.num_tiles is valid
2) At least one of the BAYER or RGB input is enabled

The input config validation is already performed in
pisp_be_validate_config() and while job.hw_enables is modified by
pispbe_xlate_addrs(), the function only resets the input masks if

- there is no input buffer available, but pispbe_prepare_job() fails
before calling pispbe_xlate_addrs() in this case
- bayer_enable is 0, but in this case rgb_enable is valid as guaranteed
by pisp_be_validate_config()
- only outputs are reset in rgb_enable

For this reasons there is no need to repeat the check at
pispbe_schedule() time.

The num_tiles validation can be moved to pisp_be_validate_config() as
well. As num_tiles is a u32 it can'be be < 0, so change the sanity
check accordingly.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Jacopo Mondi and committed by
Hans Verkuil
a773b614 3ae89661

+7 -18
+7 -18
drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
··· 588 588 pispbe->hw_busy = true; 589 589 spin_unlock_irqrestore(&pispbe->hw_lock, flags); 590 590 591 - if (job.config->num_tiles <= 0 || 592 - job.config->num_tiles > PISP_BACK_END_NUM_TILES || 593 - !((job.hw_enables.bayer_enables | job.hw_enables.rgb_enables) & 594 - PISP_BE_BAYER_ENABLE_INPUT)) { 595 - /* 596 - * Bad job. We can't let it proceed as it could lock up 597 - * the hardware, or worse! 598 - * 599 - * For now, just force num_tiles to 0, which causes the 600 - * H/W to do something bizarre but survivable. It 601 - * increments (started,done) counters by more than 1, 602 - * but we seem to survive... 603 - */ 604 - dev_dbg(pispbe->dev, "Bad job: invalid number of tiles: %u\n", 605 - job.config->num_tiles); 606 - job.config->num_tiles = 0; 607 - } 608 - 609 591 pispbe_queue_job(pispbe, &job); 610 592 611 593 return; ··· 683 701 !(rgb_enables & PISP_BE_RGB_ENABLE_INPUT)) { 684 702 dev_dbg(dev, "%s: Not one input enabled\n", __func__); 685 703 return -EIO; 704 + } 705 + 706 + if (config->num_tiles == 0 || 707 + config->num_tiles > PISP_BACK_END_NUM_TILES) { 708 + dev_dbg(dev, "%s: Invalid number of tiles: %d\n", __func__, 709 + config->num_tiles); 710 + return -EINVAL; 686 711 } 687 712 688 713 /* Ensure output config strides and buffer sizes match the V4L2 formats. */