Skip to content

Commit 080eba7

Browse files
committed
Merge tag 'char-misc-5.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are a small number of char/misc driver fixes for 5.17-rc4 for reported issues. They contain: - phy driver fixes - iio driver fix - eeprom driver fix - speakup regression fix - fastrpc fix All of these have been in linux-next with no reported issues" * tag 'char-misc-5.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: iio: buffer: Fix file related error handling in IIO_BUFFER_GET_FD_IOCTL speakup-dectlk: Restore pitch setting bus: mhi: pci_generic: Add mru_default for Cinterion MV31-W bus: mhi: pci_generic: Add mru_default for Foxconn SDX55 eeprom: ee1004: limit i2c reads to I2C_SMBUS_BLOCK_MAX misc: fastrpc: avoid double fput() on failed usercopy phy: dphy: Correct clk_pre parameter phy: phy-mtk-tphy: Fix duplicated argument in phy-mtk-tphy phy: stm32: fix a refcount leak in stm32_usbphyc_pll_enable() phy: xilinx: zynqmp: Fix bus width setting for SGMII phy: cadence: Sierra: fix error handling bugs in probe() phy: ti: Fix missing sentinel for clk_div_table phy: broadcom: Kconfig: Fix PHY_BRCM_USB config option phy: usb: Leave some clocks running during suspend
2 parents dcd72f5 + c72ea20 commit 080eba7

File tree

16 files changed

+105
-38
lines changed

16 files changed

+105
-38
lines changed

drivers/accessibility/speakup/speakup_dectlk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static struct var_t vars[] = {
4444
{ CAPS_START, .u.s = {"[:dv ap 160] " } },
4545
{ CAPS_STOP, .u.s = {"[:dv ap 100 ] " } },
4646
{ RATE, .u.n = {"[:ra %d] ", 180, 75, 650, 0, 0, NULL } },
47+
{ PITCH, .u.n = {"[:dv ap %d] ", 122, 50, 350, 0, 0, NULL } },
4748
{ INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } },
4849
{ VOL, .u.n = {"[:dv g5 %d] ", 86, 60, 86, 0, 0, NULL } },
4950
{ PUNCT, .u.n = {"[:pu %c] ", 0, 0, 2, 0, 0, "nsa" } },

drivers/bus/mhi/pci_generic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ static const struct mhi_pci_dev_info mhi_foxconn_sdx55_info = {
366366
.config = &modem_foxconn_sdx55_config,
367367
.bar_num = MHI_PCI_DEFAULT_BAR_NUM,
368368
.dma_data_width = 32,
369+
.mru_default = 32768,
369370
.sideband_wake = false,
370371
};
371372

@@ -401,6 +402,7 @@ static const struct mhi_pci_dev_info mhi_mv31_info = {
401402
.config = &modem_mv31_config,
402403
.bar_num = MHI_PCI_DEFAULT_BAR_NUM,
403404
.dma_data_width = 32,
405+
.mru_default = 32768,
404406
};
405407

406408
static const struct mhi_channel_config mhi_sierra_em919x_channels[] = {

drivers/gpu/drm/bridge/nwl-dsi.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <linux/bitfield.h>
10+
#include <linux/bits.h>
1011
#include <linux/clk.h>
1112
#include <linux/irq.h>
1213
#include <linux/math64.h>
@@ -196,12 +197,9 @@ static u32 ps2bc(struct nwl_dsi *dsi, unsigned long long ps)
196197
/*
197198
* ui2bc - UI time periods to byte clock cycles
198199
*/
199-
static u32 ui2bc(struct nwl_dsi *dsi, unsigned long long ui)
200+
static u32 ui2bc(unsigned int ui)
200201
{
201-
u32 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
202-
203-
return DIV64_U64_ROUND_UP(ui * dsi->lanes,
204-
dsi->mode.clock * 1000 * bpp);
202+
return DIV_ROUND_UP(ui, BITS_PER_BYTE);
205203
}
206204

207205
/*
@@ -232,12 +230,12 @@ static int nwl_dsi_config_host(struct nwl_dsi *dsi)
232230
}
233231

234232
/* values in byte clock cycles */
235-
cycles = ui2bc(dsi, cfg->clk_pre);
233+
cycles = ui2bc(cfg->clk_pre);
236234
DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_t_pre: 0x%x\n", cycles);
237235
nwl_dsi_write(dsi, NWL_DSI_CFG_T_PRE, cycles);
238236
cycles = ps2bc(dsi, cfg->lpx + cfg->clk_prepare + cfg->clk_zero);
239237
DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_tx_gap (pre): 0x%x\n", cycles);
240-
cycles += ui2bc(dsi, cfg->clk_pre);
238+
cycles += ui2bc(cfg->clk_pre);
241239
DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_t_post: 0x%x\n", cycles);
242240
nwl_dsi_write(dsi, NWL_DSI_CFG_T_POST, cycles);
243241
cycles = ps2bc(dsi, cfg->hs_exit);

drivers/iio/industrialio-buffer.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,9 +1569,17 @@ static long iio_device_buffer_getfd(struct iio_dev *indio_dev, unsigned long arg
15691569
}
15701570

15711571
if (copy_to_user(ival, &fd, sizeof(fd))) {
1572-
put_unused_fd(fd);
1573-
ret = -EFAULT;
1574-
goto error_free_ib;
1572+
/*
1573+
* "Leak" the fd, as there's not much we can do about this
1574+
* anyway. 'fd' might have been closed already, as
1575+
* anon_inode_getfd() called fd_install() on it, which made
1576+
* it reachable by userland.
1577+
*
1578+
* Instead of allowing a malicious user to play tricks with
1579+
* us, rely on the process exit path to do any necessary
1580+
* cleanup, as in releasing the file, if still needed.
1581+
*/
1582+
return -EFAULT;
15751583
}
15761584

15771585
return 0;

drivers/misc/eeprom/ee1004.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ static ssize_t ee1004_eeprom_read(struct i2c_client *client, char *buf,
114114
if (offset + count > EE1004_PAGE_SIZE)
115115
count = EE1004_PAGE_SIZE - offset;
116116

117+
if (count > I2C_SMBUS_BLOCK_MAX)
118+
count = I2C_SMBUS_BLOCK_MAX;
119+
117120
return i2c_smbus_read_i2c_block_data_or_emulated(client, offset, count, buf);
118121
}
119122

drivers/misc/fastrpc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,14 @@ static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp)
12881288
}
12891289

12901290
if (copy_to_user(argp, &bp, sizeof(bp))) {
1291-
dma_buf_put(buf->dmabuf);
1291+
/*
1292+
* The usercopy failed, but we can't do much about it, as
1293+
* dma_buf_fd() already called fd_install() and made the
1294+
* file descriptor accessible for the current process. It
1295+
* might already be closed and dmabuf no longer valid when
1296+
* we reach this point. Therefore "leak" the fd and rely on
1297+
* the process exit path to do any required cleanup.
1298+
*/
12921299
return -EFAULT;
12931300
}
12941301

drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/bitfield.h>
1111
#include <linux/bitops.h>
12+
#include <linux/bits.h>
1213
#include <linux/clk.h>
1314
#include <linux/delay.h>
1415
#include <linux/io.h>
@@ -250,7 +251,7 @@ static int phy_meson_axg_mipi_dphy_power_on(struct phy *phy)
250251
(DIV_ROUND_UP(priv->config.clk_zero, temp) << 16) |
251252
(DIV_ROUND_UP(priv->config.clk_prepare, temp) << 24));
252253
regmap_write(priv->regmap, MIPI_DSI_CLK_TIM1,
253-
DIV_ROUND_UP(priv->config.clk_pre, temp));
254+
DIV_ROUND_UP(priv->config.clk_pre, BITS_PER_BYTE));
254255

255256
regmap_write(priv->regmap, MIPI_DSI_HS_TIM,
256257
DIV_ROUND_UP(priv->config.hs_exit, temp) |

drivers/phy/broadcom/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ config PHY_BRCM_USB
9797
depends on OF
9898
select GENERIC_PHY
9999
select SOC_BRCMSTB if ARCH_BRCMSTB
100-
default ARCH_BCM4908
101-
default ARCH_BRCMSTB
100+
default ARCH_BCM4908 || ARCH_BRCMSTB
102101
help
103102
Enable this to support the Broadcom STB USB PHY.
104103
This driver is required by the USB XHCI, EHCI and OHCI

drivers/phy/broadcom/phy-brcm-usb.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/soc/brcmstb/brcmstb.h>
1919
#include <dt-bindings/phy/phy.h>
2020
#include <linux/mfd/syscon.h>
21+
#include <linux/suspend.h>
2122

2223
#include "phy-brcm-usb-init.h"
2324

@@ -70,12 +71,35 @@ struct brcm_usb_phy_data {
7071
int init_count;
7172
int wake_irq;
7273
struct brcm_usb_phy phys[BRCM_USB_PHY_ID_MAX];
74+
struct notifier_block pm_notifier;
75+
bool pm_active;
7376
};
7477

7578
static s8 *node_reg_names[BRCM_REGS_MAX] = {
7679
"crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio", "bdc_ec"
7780
};
7881

82+
static int brcm_pm_notifier(struct notifier_block *notifier,
83+
unsigned long pm_event,
84+
void *unused)
85+
{
86+
struct brcm_usb_phy_data *priv =
87+
container_of(notifier, struct brcm_usb_phy_data, pm_notifier);
88+
89+
switch (pm_event) {
90+
case PM_HIBERNATION_PREPARE:
91+
case PM_SUSPEND_PREPARE:
92+
priv->pm_active = true;
93+
break;
94+
case PM_POST_RESTORE:
95+
case PM_POST_HIBERNATION:
96+
case PM_POST_SUSPEND:
97+
priv->pm_active = false;
98+
break;
99+
}
100+
return NOTIFY_DONE;
101+
}
102+
79103
static irqreturn_t brcm_usb_phy_wake_isr(int irq, void *dev_id)
80104
{
81105
struct phy *gphy = dev_id;
@@ -91,6 +115,9 @@ static int brcm_usb_phy_init(struct phy *gphy)
91115
struct brcm_usb_phy_data *priv =
92116
container_of(phy, struct brcm_usb_phy_data, phys[phy->id]);
93117

118+
if (priv->pm_active)
119+
return 0;
120+
94121
/*
95122
* Use a lock to make sure a second caller waits until
96123
* the base phy is inited before using it.
@@ -120,6 +147,9 @@ static int brcm_usb_phy_exit(struct phy *gphy)
120147
struct brcm_usb_phy_data *priv =
121148
container_of(phy, struct brcm_usb_phy_data, phys[phy->id]);
122149

150+
if (priv->pm_active)
151+
return 0;
152+
123153
dev_dbg(&gphy->dev, "EXIT\n");
124154
if (phy->id == BRCM_USB_PHY_2_0)
125155
brcm_usb_uninit_eohci(&priv->ini);
@@ -488,6 +518,9 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
488518
if (err)
489519
return err;
490520

521+
priv->pm_notifier.notifier_call = brcm_pm_notifier;
522+
register_pm_notifier(&priv->pm_notifier);
523+
491524
mutex_init(&priv->mutex);
492525

493526
/* make sure invert settings are correct */
@@ -528,7 +561,10 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
528561

529562
static int brcm_usb_phy_remove(struct platform_device *pdev)
530563
{
564+
struct brcm_usb_phy_data *priv = dev_get_drvdata(&pdev->dev);
565+
531566
sysfs_remove_group(&pdev->dev.kobj, &brcm_usb_phy_group);
567+
unregister_pm_notifier(&priv->pm_notifier);
532568

533569
return 0;
534570
}
@@ -539,6 +575,7 @@ static int brcm_usb_phy_suspend(struct device *dev)
539575
struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
540576

541577
if (priv->init_count) {
578+
dev_dbg(dev, "SUSPEND\n");
542579
priv->ini.wake_enabled = device_may_wakeup(dev);
543580
if (priv->phys[BRCM_USB_PHY_3_0].inited)
544581
brcm_usb_uninit_xhci(&priv->ini);
@@ -578,6 +615,7 @@ static int brcm_usb_phy_resume(struct device *dev)
578615
* Uninitialize anything that wasn't previously initialized.
579616
*/
580617
if (priv->init_count) {
618+
dev_dbg(dev, "RESUME\n");
581619
if (priv->wake_irq >= 0)
582620
disable_irq_wake(priv->wake_irq);
583621
brcm_usb_init_common(&priv->ini);

drivers/phy/cadence/phy-cadence-sierra.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
13381338
struct device *dev = &pdev->dev;
13391339
const struct cdns_sierra_data *data;
13401340
unsigned int id_value;
1341-
int i, ret, node = 0;
1341+
int ret, node = 0;
13421342
void __iomem *base;
13431343
struct device_node *dn = dev->of_node, *child;
13441344

@@ -1416,15 +1416,18 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
14161416
dev_err(dev, "failed to get reset %s\n",
14171417
child->full_name);
14181418
ret = PTR_ERR(sp->phys[node].lnk_rst);
1419-
goto put_child2;
1419+
of_node_put(child);
1420+
goto put_control;
14201421
}
14211422

14221423
if (!sp->autoconf) {
14231424
ret = cdns_sierra_get_optional(&sp->phys[node], child);
14241425
if (ret) {
14251426
dev_err(dev, "missing property in node %s\n",
14261427
child->name);
1427-
goto put_child;
1428+
of_node_put(child);
1429+
reset_control_put(sp->phys[node].lnk_rst);
1430+
goto put_control;
14281431
}
14291432
}
14301433

@@ -1434,7 +1437,9 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
14341437

14351438
if (IS_ERR(gphy)) {
14361439
ret = PTR_ERR(gphy);
1437-
goto put_child;
1440+
of_node_put(child);
1441+
reset_control_put(sp->phys[node].lnk_rst);
1442+
goto put_control;
14381443
}
14391444
sp->phys[node].phy = gphy;
14401445
phy_set_drvdata(gphy, &sp->phys[node]);
@@ -1446,26 +1451,28 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
14461451
if (sp->num_lanes > SIERRA_MAX_LANES) {
14471452
ret = -EINVAL;
14481453
dev_err(dev, "Invalid lane configuration\n");
1449-
goto put_child2;
1454+
goto put_control;
14501455
}
14511456

14521457
/* If more than one subnode, configure the PHY as multilink */
14531458
if (!sp->autoconf && sp->nsubnodes > 1) {
14541459
ret = cdns_sierra_phy_configure_multilink(sp);
14551460
if (ret)
1456-
goto put_child2;
1461+
goto put_control;
14571462
}
14581463

14591464
pm_runtime_enable(dev);
14601465
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
1461-
return PTR_ERR_OR_ZERO(phy_provider);
1462-
1463-
put_child:
1464-
node++;
1465-
put_child2:
1466-
for (i = 0; i < node; i++)
1467-
reset_control_put(sp->phys[i].lnk_rst);
1468-
of_node_put(child);
1466+
if (IS_ERR(phy_provider)) {
1467+
ret = PTR_ERR(phy_provider);
1468+
goto put_control;
1469+
}
1470+
1471+
return 0;
1472+
1473+
put_control:
1474+
while (--node >= 0)
1475+
reset_control_put(sp->phys[node].lnk_rst);
14691476
clk_disable:
14701477
cdns_sierra_phy_disable_clocks(sp);
14711478
reset_control_assert(sp->apb_rst);

0 commit comments

Comments
 (0)