* [bug report] bus: ti-sysc: Implement display subsystem reset quirk
@ 2023-05-15 8:28 Dan Carpenter
2023-05-17 6:54 ` Tony Lindgren
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-05-15 8:28 UTC (permalink / raw)
To: tony; +Cc: linux-omap
Hello Tony Lindgren,
The patch 7324a7a0d5e2: "bus: ti-sysc: Implement display subsystem
reset quirk" from Feb 24, 2020, leads to the following Smatch static
checker warning:
drivers/bus/ti-sysc.c:1806 sysc_quirk_dispc()
warn: masking a bool
drivers/bus/ti-sysc.c
1756 static u32 sysc_quirk_dispc(struct sysc *ddata, int dispc_offset,
1757 bool disable)
1758 {
1759 bool lcd_en, digit_en, lcd2_en = false, lcd3_en = false;
1760 const int lcd_en_mask = BIT(0), digit_en_mask = BIT(1);
1761 int manager_count;
1762 bool framedonetv_irq = true;
1763 u32 val, irq_mask = 0;
1764
1765 switch (sysc_soc->soc) {
1766 case SOC_2420 ... SOC_3630:
1767 manager_count = 2;
1768 framedonetv_irq = false;
1769 break;
1770 case SOC_4430 ... SOC_4470:
1771 manager_count = 3;
1772 break;
1773 case SOC_5430:
1774 case SOC_DRA7:
1775 manager_count = 4;
1776 break;
1777 case SOC_AM4:
1778 manager_count = 1;
1779 framedonetv_irq = false;
1780 break;
1781 case SOC_UNKNOWN:
1782 default:
1783 return 0;
1784 }
1785
1786 /* Remap the whole module range to be able to reset dispc outputs */
1787 devm_iounmap(ddata->dev, ddata->module_va);
1788 ddata->module_va = devm_ioremap(ddata->dev,
1789 ddata->module_pa,
1790 ddata->module_size);
1791 if (!ddata->module_va)
1792 return -EIO;
1793
1794 /* DISP_CONTROL */
1795 val = sysc_read(ddata, dispc_offset + 0x40);
1796 lcd_en = val & lcd_en_mask;
1797 digit_en = val & digit_en_mask;
1798 if (lcd_en)
1799 irq_mask |= BIT(0); /* FRAMEDONE */
1800 if (digit_en) {
1801 if (framedonetv_irq)
1802 irq_mask |= BIT(24); /* FRAMEDONETV */
1803 else
1804 irq_mask |= BIT(2) | BIT(3); /* EVSYNC bits */
1805 }
--> 1806 if (disable & (lcd_en | digit_en))
digit_en is BIT(1) so this mask doesn't make sense. Probably logical
&& and || were intended or && and |?
1807 sysc_write(ddata, dispc_offset + 0x40,
1808 val & ~(lcd_en_mask | digit_en_mask));
1809
1810 if (manager_count <= 2)
1811 return irq_mask;
1812
1813 /* DISPC_CONTROL2 */
1814 val = sysc_read(ddata, dispc_offset + 0x238);
1815 lcd2_en = val & lcd_en_mask;
1816 if (lcd2_en)
1817 irq_mask |= BIT(22); /* FRAMEDONE2 */
1818 if (disable && lcd2_en)
1819 sysc_write(ddata, dispc_offset + 0x238,
1820 val & ~lcd_en_mask);
1821
1822 if (manager_count <= 3)
1823 return irq_mask;
1824
1825 /* DISPC_CONTROL3 */
1826 val = sysc_read(ddata, dispc_offset + 0x848);
1827 lcd3_en = val & lcd_en_mask;
1828 if (lcd3_en)
1829 irq_mask |= BIT(30); /* FRAMEDONE3 */
1830 if (disable && lcd3_en)
1831 sysc_write(ddata, dispc_offset + 0x848,
1832 val & ~lcd_en_mask);
1833
1834 return irq_mask;
1835 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] bus: ti-sysc: Implement display subsystem reset quirk
2023-05-15 8:28 [bug report] bus: ti-sysc: Implement display subsystem reset quirk Dan Carpenter
@ 2023-05-17 6:54 ` Tony Lindgren
0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2023-05-17 6:54 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-omap
Hi,
* Dan Carpenter <dan.carpenter@linaro.org> [230515 08:28]:
> Hello Tony Lindgren,
>
> The patch 7324a7a0d5e2: "bus: ti-sysc: Implement display subsystem
> reset quirk" from Feb 24, 2020, leads to the following Smatch static
> checker warning:
>
> drivers/bus/ti-sysc.c:1806 sysc_quirk_dispc()
> warn: masking a bool
>
> drivers/bus/ti-sysc.c
> 1756 static u32 sysc_quirk_dispc(struct sysc *ddata, int dispc_offset,
> 1757 bool disable)
> 1758 {
...
> 1794 /* DISP_CONTROL */
> 1795 val = sysc_read(ddata, dispc_offset + 0x40);
> 1796 lcd_en = val & lcd_en_mask;
> 1797 digit_en = val & digit_en_mask;
> 1798 if (lcd_en)
> 1799 irq_mask |= BIT(0); /* FRAMEDONE */
> 1800 if (digit_en) {
> 1801 if (framedonetv_irq)
> 1802 irq_mask |= BIT(24); /* FRAMEDONETV */
> 1803 else
> 1804 irq_mask |= BIT(2) | BIT(3); /* EVSYNC bits */
> 1805 }
> --> 1806 if (disable & (lcd_en | digit_en))
>
> digit_en is BIT(1) so this mask doesn't make sense. Probably logical
> && and || were intended or && and |?
Thanks for the report, the idea is to reset before disable if lcd or
digit was enabled, so yeah should be if (disable && (lcd_en || digit_en))
since they're bool and not masks. I'll check and add a comment too.
Regards,
Tony
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-17 6:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 8:28 [bug report] bus: ti-sysc: Implement display subsystem reset quirk Dan Carpenter
2023-05-17 6:54 ` Tony Lindgren
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).