Skip to content

Commit 6761a0a

Browse files
committed
Merge tag 'char-misc-5.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are some small misc driver fixes for 5.15-rc4. They are in two "groups": - ipack driver fixes for issues found by Johan Hovold - interconnect driver fixes for reported problems All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-5.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: ipack: ipoctal: fix module reference leak ipack: ipoctal: fix missing allocation-failure check ipack: ipoctal: fix tty-registration error handling ipack: ipoctal: fix tty registration race ipack: ipoctal: fix stack information leak interconnect: qcom: sdm660: Add missing a2noc qos clocks dt-bindings: interconnect: sdm660: Add missing a2noc qos clocks interconnect: qcom: sdm660: Correct NOC_QOS_PRIORITY shift and mask interconnect: qcom: sdm660: Fix id of slv_cnoc_mnoc_cfg
2 parents 84928ce + bb8a4fc commit 6761a0a

File tree

3 files changed

+108
-26
lines changed

3 files changed

+108
-26
lines changed

Documentation/devicetree/bindings/interconnect/qcom,sdm660.yaml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ properties:
3131

3232
clocks:
3333
minItems: 1
34-
maxItems: 3
34+
maxItems: 7
3535

3636
clock-names:
3737
minItems: 1
38-
maxItems: 3
38+
maxItems: 7
3939

4040
required:
4141
- compatible
@@ -72,6 +72,32 @@ allOf:
7272
contains:
7373
enum:
7474
- qcom,sdm660-a2noc
75+
then:
76+
properties:
77+
clocks:
78+
items:
79+
- description: Bus Clock.
80+
- description: Bus A Clock.
81+
- description: IPA Clock.
82+
- description: UFS AXI Clock.
83+
- description: Aggregate2 UFS AXI Clock.
84+
- description: Aggregate2 USB3 AXI Clock.
85+
- description: Config NoC USB2 AXI Clock.
86+
clock-names:
87+
items:
88+
- const: bus
89+
- const: bus_a
90+
- const: ipa
91+
- const: ufs_axi
92+
- const: aggre2_ufs_axi
93+
- const: aggre2_usb3_axi
94+
- const: cfg_noc_usb2_axi
95+
96+
- if:
97+
properties:
98+
compatible:
99+
contains:
100+
enum:
75101
- qcom,sdm660-bimc
76102
- qcom,sdm660-cnoc
77103
- qcom,sdm660-gnoc
@@ -91,6 +117,7 @@ examples:
91117
- |
92118
#include <dt-bindings/clock/qcom,rpmcc.h>
93119
#include <dt-bindings/clock/qcom,mmcc-sdm660.h>
120+
#include <dt-bindings/clock/qcom,gcc-sdm660.h>
94121
95122
bimc: interconnect@1008000 {
96123
compatible = "qcom,sdm660-bimc";
@@ -123,9 +150,20 @@ examples:
123150
compatible = "qcom,sdm660-a2noc";
124151
reg = <0x01704000 0xc100>;
125152
#interconnect-cells = <1>;
126-
clock-names = "bus", "bus_a";
153+
clock-names = "bus",
154+
"bus_a",
155+
"ipa",
156+
"ufs_axi",
157+
"aggre2_ufs_axi",
158+
"aggre2_usb3_axi",
159+
"cfg_noc_usb2_axi";
127160
clocks = <&rpmcc RPM_SMD_AGGR2_NOC_CLK>,
128-
<&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>;
161+
<&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>,
162+
<&rpmcc RPM_SMD_IPA_CLK>,
163+
<&gcc GCC_UFS_AXI_CLK>,
164+
<&gcc GCC_AGGRE2_UFS_AXI_CLK>,
165+
<&gcc GCC_AGGRE2_USB3_AXI_CLK>,
166+
<&gcc GCC_CFG_NOC_USB2_AXI_CLK>;
129167
};
130168
131169
mnoc: interconnect@1745000 {

drivers/interconnect/qcom/sdm660.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
#define NOC_PERM_MODE_BYPASS (1 << NOC_QOS_MODE_BYPASS)
4545

4646
#define NOC_QOS_PRIORITYn_ADDR(n) (0x8 + (n * 0x1000))
47-
#define NOC_QOS_PRIORITY_MASK 0xf
47+
#define NOC_QOS_PRIORITY_P1_MASK 0xc
48+
#define NOC_QOS_PRIORITY_P0_MASK 0x3
4849
#define NOC_QOS_PRIORITY_P1_SHIFT 0x2
49-
#define NOC_QOS_PRIORITY_P0_SHIFT 0x3
5050

5151
#define NOC_QOS_MODEn_ADDR(n) (0xc + (n * 0x1000))
5252
#define NOC_QOS_MODEn_MASK 0x3
@@ -173,6 +173,16 @@ static const struct clk_bulk_data bus_mm_clocks[] = {
173173
{ .id = "iface" },
174174
};
175175

176+
static const struct clk_bulk_data bus_a2noc_clocks[] = {
177+
{ .id = "bus" },
178+
{ .id = "bus_a" },
179+
{ .id = "ipa" },
180+
{ .id = "ufs_axi" },
181+
{ .id = "aggre2_ufs_axi" },
182+
{ .id = "aggre2_usb3_axi" },
183+
{ .id = "cfg_noc_usb2_axi" },
184+
};
185+
176186
/**
177187
* struct qcom_icc_provider - Qualcomm specific interconnect provider
178188
* @provider: generic interconnect provider
@@ -307,7 +317,7 @@ DEFINE_QNODE(slv_bimc_cfg, SDM660_SLAVE_BIMC_CFG, 4, -1, 56, true, -1, 0, -1, 0)
307317
DEFINE_QNODE(slv_prng, SDM660_SLAVE_PRNG, 4, -1, 44, true, -1, 0, -1, 0);
308318
DEFINE_QNODE(slv_spdm, SDM660_SLAVE_SPDM, 4, -1, 60, true, -1, 0, -1, 0);
309319
DEFINE_QNODE(slv_qdss_cfg, SDM660_SLAVE_QDSS_CFG, 4, -1, 63, true, -1, 0, -1, 0);
310-
DEFINE_QNODE(slv_cnoc_mnoc_cfg, SDM660_SLAVE_BLSP_1, 4, -1, 66, true, -1, 0, -1, SDM660_MASTER_CNOC_MNOC_CFG);
320+
DEFINE_QNODE(slv_cnoc_mnoc_cfg, SDM660_SLAVE_CNOC_MNOC_CFG, 4, -1, 66, true, -1, 0, -1, SDM660_MASTER_CNOC_MNOC_CFG);
311321
DEFINE_QNODE(slv_snoc_cfg, SDM660_SLAVE_SNOC_CFG, 4, -1, 70, true, -1, 0, -1, 0);
312322
DEFINE_QNODE(slv_qm_cfg, SDM660_SLAVE_QM_CFG, 4, -1, 212, true, -1, 0, -1, 0);
313323
DEFINE_QNODE(slv_clk_ctl, SDM660_SLAVE_CLK_CTL, 4, -1, 47, true, -1, 0, -1, 0);
@@ -624,13 +634,12 @@ static int qcom_icc_noc_set_qos_priority(struct regmap *rmap,
624634
/* Must be updated one at a time, P1 first, P0 last */
625635
val = qos->areq_prio << NOC_QOS_PRIORITY_P1_SHIFT;
626636
rc = regmap_update_bits(rmap, NOC_QOS_PRIORITYn_ADDR(qos->qos_port),
627-
NOC_QOS_PRIORITY_MASK, val);
637+
NOC_QOS_PRIORITY_P1_MASK, val);
628638
if (rc)
629639
return rc;
630640

631-
val = qos->prio_level << NOC_QOS_PRIORITY_P0_SHIFT;
632641
return regmap_update_bits(rmap, NOC_QOS_PRIORITYn_ADDR(qos->qos_port),
633-
NOC_QOS_PRIORITY_MASK, val);
642+
NOC_QOS_PRIORITY_P0_MASK, qos->prio_level);
634643
}
635644

636645
static int qcom_icc_set_noc_qos(struct icc_node *src, u64 max_bw)
@@ -810,6 +819,10 @@ static int qnoc_probe(struct platform_device *pdev)
810819
qp->bus_clks = devm_kmemdup(dev, bus_mm_clocks,
811820
sizeof(bus_mm_clocks), GFP_KERNEL);
812821
qp->num_clks = ARRAY_SIZE(bus_mm_clocks);
822+
} else if (of_device_is_compatible(dev->of_node, "qcom,sdm660-a2noc")) {
823+
qp->bus_clks = devm_kmemdup(dev, bus_a2noc_clocks,
824+
sizeof(bus_a2noc_clocks), GFP_KERNEL);
825+
qp->num_clks = ARRAY_SIZE(bus_a2noc_clocks);
813826
} else {
814827
if (of_device_is_compatible(dev->of_node, "qcom,sdm660-bimc"))
815828
qp->is_bimc_node = true;

drivers/ipack/devices/ipoctal.c

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct ipoctal_channel {
3333
unsigned int pointer_read;
3434
unsigned int pointer_write;
3535
struct tty_port tty_port;
36+
bool tty_registered;
3637
union scc2698_channel __iomem *regs;
3738
union scc2698_block __iomem *block_regs;
3839
unsigned int board_id;
@@ -81,22 +82,34 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
8182
return 0;
8283
}
8384

84-
static int ipoctal_open(struct tty_struct *tty, struct file *file)
85+
static int ipoctal_install(struct tty_driver *driver, struct tty_struct *tty)
8586
{
8687
struct ipoctal_channel *channel = dev_get_drvdata(tty->dev);
8788
struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
88-
int err;
89-
90-
tty->driver_data = channel;
89+
int res;
9190

9291
if (!ipack_get_carrier(ipoctal->dev))
9392
return -EBUSY;
9493

95-
err = tty_port_open(&channel->tty_port, tty, file);
96-
if (err)
97-
ipack_put_carrier(ipoctal->dev);
94+
res = tty_standard_install(driver, tty);
95+
if (res)
96+
goto err_put_carrier;
97+
98+
tty->driver_data = channel;
99+
100+
return 0;
101+
102+
err_put_carrier:
103+
ipack_put_carrier(ipoctal->dev);
104+
105+
return res;
106+
}
107+
108+
static int ipoctal_open(struct tty_struct *tty, struct file *file)
109+
{
110+
struct ipoctal_channel *channel = tty->driver_data;
98111

99-
return err;
112+
return tty_port_open(&channel->tty_port, tty, file);
100113
}
101114

102115
static void ipoctal_reset_stats(struct ipoctal_stats *stats)
@@ -264,7 +277,6 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
264277
int res;
265278
int i;
266279
struct tty_driver *tty;
267-
char name[20];
268280
struct ipoctal_channel *channel;
269281
struct ipack_region *region;
270282
void __iomem *addr;
@@ -355,8 +367,11 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
355367
/* Fill struct tty_driver with ipoctal data */
356368
tty->owner = THIS_MODULE;
357369
tty->driver_name = KBUILD_MODNAME;
358-
sprintf(name, KBUILD_MODNAME ".%d.%d.", bus_nr, slot);
359-
tty->name = name;
370+
tty->name = kasprintf(GFP_KERNEL, KBUILD_MODNAME ".%d.%d.", bus_nr, slot);
371+
if (!tty->name) {
372+
res = -ENOMEM;
373+
goto err_put_driver;
374+
}
360375
tty->major = 0;
361376

362377
tty->minor_start = 0;
@@ -371,8 +386,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
371386
res = tty_register_driver(tty);
372387
if (res) {
373388
dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n");
374-
tty_driver_kref_put(tty);
375-
return res;
389+
goto err_free_name;
376390
}
377391

378392
/* Save struct tty_driver for use it when uninstalling the device */
@@ -383,21 +397,25 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
383397

384398
channel = &ipoctal->channel[i];
385399
tty_port_init(&channel->tty_port);
386-
tty_port_alloc_xmit_buf(&channel->tty_port);
400+
res = tty_port_alloc_xmit_buf(&channel->tty_port);
401+
if (res)
402+
continue;
387403
channel->tty_port.ops = &ipoctal_tty_port_ops;
388404

389405
ipoctal_reset_stats(&channel->stats);
390406
channel->nb_bytes = 0;
391407
spin_lock_init(&channel->lock);
392408
channel->pointer_read = 0;
393409
channel->pointer_write = 0;
394-
tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL);
410+
tty_dev = tty_port_register_device_attr(&channel->tty_port, tty,
411+
i, NULL, channel, NULL);
395412
if (IS_ERR(tty_dev)) {
396413
dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
414+
tty_port_free_xmit_buf(&channel->tty_port);
397415
tty_port_destroy(&channel->tty_port);
398416
continue;
399417
}
400-
dev_set_drvdata(tty_dev, channel);
418+
channel->tty_registered = true;
401419
}
402420

403421
/*
@@ -409,6 +427,13 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
409427
ipoctal_irq_handler, ipoctal);
410428

411429
return 0;
430+
431+
err_free_name:
432+
kfree(tty->name);
433+
err_put_driver:
434+
tty_driver_kref_put(tty);
435+
436+
return res;
412437
}
413438

414439
static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
@@ -648,6 +673,7 @@ static void ipoctal_cleanup(struct tty_struct *tty)
648673

649674
static const struct tty_operations ipoctal_fops = {
650675
.ioctl = NULL,
676+
.install = ipoctal_install,
651677
.open = ipoctal_open,
652678
.close = ipoctal_close,
653679
.write = ipoctal_write_tty,
@@ -690,12 +716,17 @@ static void __ipoctal_remove(struct ipoctal *ipoctal)
690716

691717
for (i = 0; i < NR_CHANNELS; i++) {
692718
struct ipoctal_channel *channel = &ipoctal->channel[i];
719+
720+
if (!channel->tty_registered)
721+
continue;
722+
693723
tty_unregister_device(ipoctal->tty_drv, i);
694724
tty_port_free_xmit_buf(&channel->tty_port);
695725
tty_port_destroy(&channel->tty_port);
696726
}
697727

698728
tty_unregister_driver(ipoctal->tty_drv);
729+
kfree(ipoctal->tty_drv->name);
699730
tty_driver_kref_put(ipoctal->tty_drv);
700731
kfree(ipoctal);
701732
}

0 commit comments

Comments
 (0)