Compare

a0ff06b3a7bd3aa0cd99d0294e60b3ed28c9bfac..c03c1a14507dfaf8b856c2608f9ac216021fc222

Linux 7.3

Linus Torvalds <torvalds@linux-foundation.org> · 2026-10-18 23:14 UTC

Browse files
27 files changed, +183 −96
modified Makefile
@@ -2,7 +2,7 @@
2 2 VERSION = 7
3 3 PATCHLEVEL = 3
4 4 SUBLEVEL = 0
5 - EXTRAVERSION = -rc7
5 + EXTRAVERSION =
6 6 NAME = Baby Opossum Posse
7 7
8 8 # *DOCUMENTATION*
modified block/bsg-lib.c
@@ -23,11 +23,14 @@ struct bsg_set {
23 23 struct bsg_device *bd;
24 24 bsg_job_fn *job_fn;
25 25 bsg_timeout_fn *timeout_fn;
26 + unsigned int reply_len;
26 27 };
27 28
28 29 static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
29 30 bool open_for_write, unsigned int timeout)
30 31 {
32 + struct bsg_set *bset =
33 + container_of(q->tag_set, struct bsg_set, tag_set);
31 34 struct bsg_job *job;
32 35 struct request *rq;
33 36 struct bio *bio;
@@ -50,7 +53,7 @@ static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
50 53 reply = job->reply;
51 54 memset(job, 0, sizeof(*job));
52 55 job->reply = reply;
53 - job->reply_len = SCSI_SENSE_BUFFERSIZE;
56 + job->reply_len = bset->reply_len;
54 57 job->dd_data = job + 1;
55 58
56 59 job->request_len = hdr->request_len;
@@ -301,9 +304,10 @@ out:
301 304 static int bsg_init_rq(struct blk_mq_tag_set *set, struct request *req,
302 305 unsigned int hctx_idx, int numa_node)
303 306 {
307 + struct bsg_set *bset = container_of(set, struct bsg_set, tag_set);
304 308 struct bsg_job *job = blk_mq_rq_to_pdu(req);
305 309
306 - job->reply = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
310 + job->reply = kzalloc(bset->reply_len, GFP_KERNEL);
307 311 if (!job->reply)
308 312 return -ENOMEM;
309 313 return 0;
@@ -358,10 +362,12 @@ static const struct blk_mq_ops bsg_mq_ops = {
358 362 * @job_fn: bsg job handler
359 363 * @timeout: timeout handler function pointer
360 364 * @dd_job_size: size of LLD data needed for each job
365 + * @reply_len: size of the reply buffer needed for each job
361 366 */
362 367 struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
363 368 struct queue_limits *lim, bsg_job_fn *job_fn,
364 - bsg_timeout_fn *timeout, int dd_job_size)
369 + bsg_timeout_fn *timeout, int dd_job_size,
370 + unsigned int reply_len)
365 371 {
366 372 struct bsg_set *bset;
367 373 struct blk_mq_tag_set *set;
@@ -374,6 +380,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
374 380
375 381 bset->job_fn = job_fn;
376 382 bset->timeout_fn = timeout;
383 + bset->reply_len = reply_len;
377 384
378 385 set = &bset->tag_set;
379 386 set->ops = &bsg_mq_ops;
modified drivers/base/regmap/regcache-maple.c
@@ -312,16 +312,21 @@ static void regcache_maple_exit(struct regmap *map)
312 312 struct maple_tree *mt = map->cache;
313 313 MA_STATE(mas, mt, 0, UINT_MAX);
314 314 unsigned int *entry;
315 + unsigned long flags;
315 316
316 317 /* if we've already been called then just return */
317 318 if (!mt)
318 319 return;
319 320
320 - mas_lock(&mas);
321 + /*
322 + * Register access may take the Maple lock from hard IRQ context, so
323 + * preserve its IRQ-safe lockdep state during teardown.
324 + */
325 + mas_lock_irqsave(&mas, flags);
321 326 mas_for_each(&mas, entry, UINT_MAX)
322 327 kfree(entry);
323 328 __mt_destroy(mt);
324 - mas_unlock(&mas);
329 + mas_unlock_irqrestore(&mas, flags);
325 330
326 331 kfree(mt);
327 332 map->cache = NULL;
modified drivers/base/regmap/regcache.c
@@ -225,9 +225,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
225 225 if (map->cache_ops->init) {
226 226 dev_dbg(map->dev, "Initializing %s cache\n",
227 227 map->cache_ops->name);
228 - map->lock(map->lock_arg);
229 228 ret = map->cache_ops->init(map);
230 - map->unlock(map->lock_arg);
231 229 if (ret)
232 230 goto err_free_reg_defaults;
233 231 }
@@ -259,9 +257,7 @@ err_free:
259 257 err_exit:
260 258 if (map->cache_ops->exit) {
261 259 dev_dbg(map->dev, "Destroying %s cache\n", map->cache_ops->name);
262 - map->lock(map->lock_arg);
263 260 map->cache_ops->exit(map);
264 - map->unlock(map->lock_arg);
265 261 }
266 262 err_free_reg_defaults:
267 263 kfree(map->reg_defaults);
@@ -281,9 +277,7 @@ void regcache_exit(struct regmap *map)
281 277 if (map->cache_ops->exit) {
282 278 dev_dbg(map->dev, "Destroying %s cache\n",
283 279 map->cache_ops->name);
284 - map->lock(map->lock_arg);
285 280 map->cache_ops->exit(map);
286 - map->unlock(map->lock_arg);
287 281 }
288 282
289 283 kfree(map->reg_defaults);
modified drivers/base/regmap/regmap-debugfs.c
@@ -664,6 +664,7 @@ void regmap_debugfs_exit(struct regmap *map)
664 664 {
665 665 if (map->debugfs) {
666 666 debugfs_remove_recursive(map->debugfs);
667 + map->debugfs = NULL;
667 668 mutex_lock(&map->cache_lock);
668 669 regmap_debugfs_free_dump_cache(map);
669 670 mutex_unlock(&map->cache_lock);
modified drivers/base/regmap/regmap-irq.c
@@ -963,7 +963,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
963 963 return 0;
964 964
965 965 err_domain:
966 - /* Should really dispose of the domain but... */
966 + irq_domain_remove(d->domain);
967 967 err_mutex:
968 968 mutex_destroy(&d->lock);
969 969 lockdep_unregister_key(&d->lock_key);
modified drivers/base/regmap/regmap.c
@@ -1422,8 +1422,8 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
1422 1422 {
1423 1423 int ret;
1424 1424
1425 - regcache_exit(map);
1426 1425 regmap_debugfs_exit(map);
1426 + regcache_exit(map);
1427 1427
1428 1428 map->max_register = config->max_register;
1429 1429 map->max_register_is_set = map->max_register ?: config->max_register_is_0;
@@ -1440,12 +1440,16 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
1440 1440 if (ret)
1441 1441 return ret;
1442 1442
1443 - regmap_debugfs_init(map);
1444 -
1445 1443 map->cache_bypass = false;
1446 1444 map->cache_only = false;
1447 1445
1448 - return regcache_init(map, config);
1446 + ret = regcache_init(map, config);
1447 + if (ret)
1448 + return ret;
1449 +
1450 + regmap_debugfs_init(map);
1451 +
1452 + return 0;
1449 1453 }
1450 1454 EXPORT_SYMBOL_GPL(regmap_reinit_cache);
1451 1455
@@ -1459,9 +1463,8 @@ void regmap_exit(struct regmap *map)
1459 1463 struct regmap_async *async;
1460 1464
1461 1465 regmap_detach_dev(map->dev, map);
1462 - regcache_exit(map);
1463 -
1464 1466 regmap_debugfs_exit(map);
1467 + regcache_exit(map);
1465 1468 regmap_range_exit(map);
1466 1469 if (map->bus && map->bus->free_context)
1467 1470 map->bus->free_context(map->bus_context);
modified drivers/i2c/busses/i2c-qcom-cci.c
@@ -164,12 +164,12 @@ static irqreturn_t cci_isr(int irq, void *dev)
164 164 }
165 165
166 166 if (unlikely(val & CCI_IRQ_STATUS_0_I2C_M0_Q0Q1_HALT_ACK)) {
167 - reset = CCI_RESET_CMD_M0_MASK;
167 + reset |= CCI_RESET_CMD_M0_MASK;
168 168 ret = IRQ_HANDLED;
169 169 }
170 170
171 171 if (unlikely(val & CCI_IRQ_STATUS_0_I2C_M1_Q0Q1_HALT_ACK)) {
172 - reset = CCI_RESET_CMD_M1_MASK;
172 + reset |= CCI_RESET_CMD_M1_MASK;
173 173 ret = IRQ_HANDLED;
174 174 }
175 175
modified drivers/i2c/busses/i2c-qcom-geni.c
@@ -201,28 +201,31 @@ static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
201 201 static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
202 202 {
203 203 const struct geni_i2c_clk_fld *itr;
204 - unsigned long res_freq;
204 + unsigned long req_freq, res_freq;
205 + int ret;
205 206
206 207 /*
207 - * Frequency counter tables are calibrated for a specific source
208 - * clock frequency and are not valid for any multiple of it
209 - * (e.g. 64 MHz, 128 MHz).
210 - * Use exact=true and verify res_freq matches req_freq literally
211 - * to reject harmonics: a 64 MHz clock that divides evenly to
212 - * 32 MHz would pass exact matching but produce double the intended
213 - * I2C frequency with these counter values.
208 + * Use 32 MHz only if already selected, otherwise use 19.2 MHz.
209 + * Preferring 32 MHz merely because DFS supports it breaks I2C
210 + * transfers on X1E80100 CRD.
214 211 */
215 - if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_32MHZ,
216 - &gi2c->clk_idx, &res_freq, true) &&
217 - res_freq == GENI_SE_CLK_32MHZ) {
212 + if (clk_get_rate(gi2c->se.clk) == GENI_SE_CLK_32MHZ) {
213 + req_freq = GENI_SE_CLK_32MHZ;
218 214 itr = geni_i2c_clk_map_32mhz;
219 - } else if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_19P2MHZ,
220 - &gi2c->clk_idx, &res_freq, true) &&
221 - res_freq == GENI_SE_CLK_19P2MHZ) {
222 - itr = geni_i2c_clk_map_19p2mhz;
223 215 } else {
224 - dev_err(gi2c->se.dev,
225 - "Unsupported SE source clock: must be exactly 32 MHz or 19.2 MHz\n");
216 + req_freq = GENI_SE_CLK_19P2MHZ;
217 + itr = geni_i2c_clk_map_19p2mhz;
218 + }
219 +
220 + ret = geni_se_clk_freq_match(&gi2c->se, req_freq, &gi2c->clk_idx,
221 + &res_freq, true);
222 + if (ret)
223 + return dev_err_probe(gi2c->se.dev, ret,
224 + "Failed to find SE source clock %lu Hz\n",
225 + req_freq);
226 + if (res_freq != req_freq) {
227 + dev_err(gi2c->se.dev, "Unsupported SE source clock %lu Hz\n",
228 + res_freq);
226 229 return -EINVAL;
227 230 }
228 231
modified drivers/i2c/busses/i2c-viai2c-wmt.c
@@ -116,7 +116,7 @@ static int wmt_i2c_probe(struct platform_device *pdev)
116 116 if (err)
117 117 return err;
118 118
119 - i2c->clk = of_clk_get(np, 0);
119 + i2c->clk = devm_clk_get(&pdev->dev, NULL);
120 120 if (IS_ERR(i2c->clk))
121 121 return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
122 122 "unable to request clock\n");
modified drivers/i2c/busses/i2c-xiic.c
@@ -67,6 +67,7 @@ enum i2c_scl_freq {
67 67 * @rx_pos: Position within current RX message
68 68 * @endianness: big/little-endian byte order
69 69 * @clk: Pointer to AXI4-lite input clock
70 + * @irq: Interrupt number
70 71 * @state: See STATE_
71 72 * @singlemaster: Indicates bus is single master
72 73 * @dynamic: Mode of controller
@@ -95,6 +96,7 @@ struct xiic_i2c {
95 96 int rx_pos;
96 97 enum xiic_endian endianness;
97 98 struct clk *clk;
99 + int irq;
98 100 enum xilinx_i2c_state state;
99 101 bool singlemaster;
100 102 bool dynamic;
@@ -1506,9 +1508,17 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1506 1508
1507 1509 pm_runtime_set_autosuspend_delay(dev, XIIC_PM_TIMEOUT);
1508 1510 pm_runtime_use_autosuspend(dev);
1509 - ret = devm_pm_runtime_set_active_enabled(dev);
1510 - if (ret)
1511 + /*
1512 + * Enable runtime PM by hand: devm_pm_runtime_set_active_enabled()
1513 + * tears down in an order that races the devm-enabled clock release and
1514 + * makes clk_core_disable() WARN (see xiic_i2c_remove()).
1515 + */
1516 + ret = pm_runtime_set_active(dev);
1517 + if (ret) {
1518 + pm_runtime_dont_use_autosuspend(dev);
1511 1519 return ret;
1520 + }
1521 + pm_runtime_enable(dev);
1512 1522
1513 1523 /* SCL frequency configuration */
1514 1524 i2c->input_clk = clk_get_rate(i2c->clk);
@@ -1517,10 +1527,15 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1517 1527 if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ)
1518 1528 i2c->i2c_clk = 0;
1519 1529
1520 - ret = devm_request_threaded_irq(dev, irq, NULL, xiic_process,
1521 - IRQF_ONESHOT, pdev->name, i2c);
1530 + /*
1531 + * Request the IRQ non-managed: later probe steps unwind manually via
1532 + * goto, so a devm handler could still be live after that teardown runs.
1533 + */
1534 + i2c->irq = irq;
1535 + ret = request_threaded_irq(irq, NULL, xiic_process, IRQF_ONESHOT,
1536 + pdev->name, i2c);
1522 1537 if (ret)
1523 - return ret;
1538 + goto err_pm_disable;
1524 1539
1525 1540 i2c->singlemaster = device_property_read_bool(dev, "single-master");
1526 1541
@@ -1537,14 +1552,16 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1537 1552 i2c->endianness = BIG;
1538 1553
1539 1554 ret = xiic_reinit(i2c);
1540 - if (ret)
1541 - return dev_err_probe(dev, ret, "Cannot xiic_reinit\n");
1555 + if (ret) {
1556 + dev_err_probe(dev, ret, "Cannot xiic_reinit\n");
1557 + goto err_free_irq;
1558 + }
1542 1559
1543 1560 /* add i2c adapter to i2c tree */
1544 1561 ret = i2c_add_numbered_adapter(&i2c->adap);
1545 1562 if (ret) {
1546 1563 xiic_deinit(i2c);
1547 - return ret;
1564 + goto err_free_irq;
1548 1565 }
1549 1566
1550 1567 if (pdata) {
@@ -1557,6 +1574,15 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1557 1574 res, irq, i2c->i2c_clk);
1558 1575
1559 1576 return 0;
1577 +
1578 + err_free_irq:
1579 + free_irq(irq, i2c);
1580 + err_pm_disable:
1581 + pm_runtime_disable(dev);
1582 + pm_runtime_set_suspended(dev);
1583 + pm_runtime_dont_use_autosuspend(dev);
1584 +
1585 + return ret;
1560 1586 }
1561 1587
1562 1588 static void xiic_i2c_remove(struct platform_device *pdev)
@@ -1568,6 +1594,8 @@ static void xiic_i2c_remove(struct platform_device *pdev)
1568 1594 /* remove adapter & data */
1569 1595 i2c_del_adapter(&i2c->adap);
1570 1596
1597 + free_irq(i2c->irq, i2c);
1598 +
1571 1599 ret = pm_runtime_get_sync(dev);
1572 1600 if (ret < 0)
1573 1601 dev_warn(dev, "Failed to activate device for removal (%pe)\n",
@@ -1575,7 +1603,10 @@ static void xiic_i2c_remove(struct platform_device *pdev)
1575 1603 else
1576 1604 xiic_deinit(i2c);
1577 1605
1578 - pm_runtime_put_sync(dev);
1606 + pm_runtime_disable(dev);
1607 + pm_runtime_put_noidle(dev);
1608 + pm_runtime_set_suspended(dev);
1609 + pm_runtime_dont_use_autosuspend(dev);
1579 1610 }
1580 1611
1581 1612 static const struct dev_pm_ops xiic_dev_pm_ops = {
modified drivers/scsi/libiscsi.c
@@ -1142,13 +1142,15 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1142 1142 spin_unlock(&conn->session->frwd_lock);
1143 1143 spin_lock(&conn->session->back_lock);
1144 1144 } else {
1145 - struct iscsi_task *task;
1145 + struct iscsi_task *task = NULL;
1146 1146 /*
1147 1147 * Our nop as ping got dropped. We know the target
1148 1148 * and transport are ok so just clean up
1149 1149 */
1150 - task = iscsi_itt_to_task(conn, rejected_pdu.itt);
1151 - if (!task) {
1150 + if (!iscsi_verify_itt(conn, rejected_pdu.itt))
1151 + task = iscsi_itt_to_task(conn, rejected_pdu.itt);
1152 + if (!task || task->state == ISCSI_TASK_FREE ||
1153 + task->sc) {
1152 1154 iscsi_conn_printk(KERN_ERR, conn,
1153 1155 "Invalid pdu reject. Could "
1154 1156 "not lookup rejected task.\n");
@@ -1191,7 +1193,7 @@ struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
1191 1193 session->tt->parse_pdu_itt(conn, itt, &i, NULL);
1192 1194 else
1193 1195 i = get_itt(itt);
1194 - if (i >= session->cmds_max)
1196 + if (i < 0 || i >= session->cmds_max)
1195 1197 return NULL;
1196 1198
1197 1199 return session->cmds[i];
@@ -1284,7 +1286,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1284 1286 case ISCSI_OP_SCSI_TMFUNC_RSP:
1285 1287 case ISCSI_OP_NOOP_IN:
1286 1288 task = iscsi_itt_to_task(conn, hdr->itt);
1287 - if (!task)
1289 + if (!task || task->state == ISCSI_TASK_FREE || task->sc)
1288 1290 return ISCSI_ERR_BAD_ITT;
1289 1291 break;
1290 1292 default:
@@ -1384,7 +1386,7 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)
1384 1386 return ISCSI_ERR_BAD_ITT;
1385 1387 }
1386 1388
1387 - if (i >= session->cmds_max) {
1389 + if (i < 0 || i >= session->cmds_max) {
1388 1390 iscsi_conn_printk(KERN_ERR, conn,
1389 1391 "received invalid itt index %u (max cmds "
1390 1392 "%u.\n", i, session->cmds_max);
modified drivers/scsi/libsas/sas_expander.c
@@ -62,7 +62,11 @@ static int smp_execute_task_sg(struct domain_device *dev,
62 62 to_sas_internal(dev->port->ha->shost->transportt);
63 63 struct sas_ha_struct *ha = dev->port->ha;
64 64
65 - pm_runtime_get_sync(ha->dev);
65 + /*
66 + * Non-blocking: a sync resume here would deadlock against
67 + * sas_drain_work() during HA resume.
68 + */
69 + pm_runtime_get_noresume(ha->dev);
66 70 mutex_lock(&dev->ex_dev.cmd_mutex);
67 71 for (retry = 0; retry < 3; retry++) {
68 72 if (test_bit(SAS_DEV_GONE, &dev->state)) {
@@ -135,7 +139,7 @@ static int smp_execute_task_sg(struct domain_device *dev,
135 139 }
136 140 }
137 141 mutex_unlock(&dev->ex_dev.cmd_mutex);
138 - pm_runtime_put_sync(ha->dev);
142 + pm_runtime_put(ha->dev);
139 143
140 144 BUG_ON(retry == 3 && task != NULL);
141 145 sas_free_task(task);
@@ -2222,6 +2226,11 @@ void sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost,
2222 2226 goto out;
2223 2227 }
2224 2228
2229 + /* The host may have autosuspended, resume it here. */
2230 + ret = pm_runtime_resume_and_get(dev->port->ha->dev);
2231 + if (ret)
2232 + goto out;
2233 +
2225 2234 ret = smp_execute_task_sg(dev, job->request_payload.sg_list,
2226 2235 job->reply_payload.sg_list);
2227 2236 if (ret >= 0) {
@@ -2229,6 +2238,7 @@ void sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost,
2229 2238 rcvlen = job->reply_payload.payload_len - ret;
2230 2239 ret = 0;
2231 2240 }
2241 + pm_runtime_put(dev->port->ha->dev);
2232 2242
2233 2243 out:
2234 2244 bsg_job_done(job, ret, rcvlen);
modified drivers/scsi/mpi3mr/mpi3mr_app.c
@@ -3053,7 +3053,7 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
3053 3053 }
3054 3054
3055 3055 q = bsg_setup_queue(bsg_dev, dev_name(bsg_dev), &lim,
3056 - mpi3mr_bsg_request, NULL, 0);
3056 + mpi3mr_bsg_request, NULL, 0, SCSI_SENSE_BUFFERSIZE);
3057 3057 if (IS_ERR(q)) {
3058 3058 ioc_err(mrioc, "%s: bsg registration failed\n",
3059 3059 dev_name(bsg_dev));
modified drivers/scsi/scsi_transport_fc.c
@@ -4345,7 +4345,8 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host)
4345 4345 scsi_init_limits(shost, &lim);
4346 4346 lim.max_segments = min_not_zero(lim.max_segments, i->f->max_bsg_segments);
4347 4347 q = bsg_setup_queue(dev, bsg_name, &lim, fc_bsg_dispatch,
4348 - fc_bsg_job_timeout, i->f->dd_bsg_size);
4348 + fc_bsg_job_timeout, i->f->dd_bsg_size,
4349 + SCSI_SENSE_BUFFERSIZE);
4349 4350 if (IS_ERR(q)) {
4350 4351 dev_err(dev,
4351 4352 "fc_host%d: bsg interface failed to initialize - setup queue\n",
@@ -4378,7 +4379,8 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
4378 4379 scsi_init_limits(shost, &lim);
4379 4380 lim.max_segments = min_not_zero(lim.max_segments, i->f->max_bsg_segments);
4380 4381 q = bsg_setup_queue(dev, dev_name(dev), &lim, fc_bsg_dispatch_prep,
4381 - fc_bsg_job_timeout, i->f->dd_bsg_size);
4382 + fc_bsg_job_timeout, i->f->dd_bsg_size,
4383 + SCSI_SENSE_BUFFERSIZE);
4382 4384 if (IS_ERR(q)) {
4383 4385 dev_err(dev, "failed to setup bsg queue\n");
4384 4386 return PTR_ERR(q);
modified drivers/scsi/scsi_transport_iscsi.c
@@ -1545,7 +1545,7 @@ iscsi_bsg_host_add(struct Scsi_Host *shost, struct iscsi_cls_host *ihost)
1545 1545 snprintf(bsg_name, sizeof(bsg_name), "iscsi_host%d", shost->host_no);
1546 1546 scsi_init_limits(shost, &lim);
1547 1547 q = bsg_setup_queue(dev, bsg_name, &lim, iscsi_bsg_host_dispatch, NULL,
1548 - 0);
1548 + 0, SCSI_SENSE_BUFFERSIZE);
1549 1549 if (IS_ERR(q)) {
1550 1550 shost_printk(KERN_ERR, shost, "bsg interface failed to "
1551 1551 "initialize - no request queue\n");
modified drivers/scsi/scsi_transport_sas.c
@@ -199,7 +199,8 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)
199 199
200 200 if (rphy) {
201 201 q = bsg_setup_queue(&rphy->dev, dev_name(&rphy->dev), NULL,
202 - sas_smp_dispatch, NULL, 0);
202 + sas_smp_dispatch, NULL, 0,
203 + SCSI_SENSE_BUFFERSIZE);
203 204 if (IS_ERR(q))
204 205 return PTR_ERR(q);
205 206 rphy->q = q;
@@ -208,7 +209,8 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)
208 209
209 210 snprintf(name, sizeof(name), "sas_host%d", shost->host_no);
210 211 q = bsg_setup_queue(&shost->shost_gendev, name, NULL,
211 - sas_smp_dispatch, NULL, 0);
212 + sas_smp_dispatch, NULL, 0,
213 + SCSI_SENSE_BUFFERSIZE);
212 214 if (IS_ERR(q))
213 215 return PTR_ERR(q);
214 216 to_sas_host_attrs(shost)->q = q;
modified drivers/scsi/st.c
@@ -3217,14 +3217,20 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3217 3217 partition >= ST_NBR_PARTITIONS)
3218 3218 return (-EINVAL);
3219 3219 if (partition != STp->partition) {
3220 - if (get_location(STp, &blk, &p, 1))
3220 + /*
3221 + * Save the location for the partition the drive reports,
3222 + * not for STp->partition: after a reset STp->partition may
3223 + * not match the partition the drive is in.
3224 + */
3225 + if (get_location(STp, &blk, &p, 1) ||
3226 + p < 0 || p >= ST_NBR_PARTITIONS)
3221 3227 STps->last_block_valid = 0;
3222 3228 else {
3223 - STps->last_block_valid = 1;
3224 - STps->last_block_visited = blk;
3229 + STp->ps[p].last_block_valid = 1;
3230 + STp->ps[p].last_block_visited = blk;
3225 3231 DEBC_printk(STp, "Visited block %d for "
3226 3232 "partition %d saved.\n",
3227 - blk, STp->partition);
3233 + blk, p);
3228 3234 }
3229 3235 }
3230 3236
@@ -4509,11 +4515,11 @@ static void st_remove(struct scsi_device *SDp)
4509 4515 remove_cdevs(tpnt);
4510 4516
4511 4517 mutex_lock(&st_ref_mutex);
4512 - kref_put(&tpnt->kref, scsi_tape_release);
4513 - mutex_unlock(&st_ref_mutex);
4514 4518 spin_lock(&st_index_lock);
4515 4519 idr_remove(&st_index_idr, index);
4516 4520 spin_unlock(&st_index_lock);
4521 + kref_put(&tpnt->kref, scsi_tape_release);
4522 + mutex_unlock(&st_ref_mutex);
4517 4523 }
4518 4524
4519 4525 /**
modified drivers/scsi/xen-scsifront.c
@@ -367,6 +367,7 @@ static void scsifront_do_response(struct vscsifrnt_info *info,
367 367 struct vscsifrnt_shadow *shadow;
368 368
369 369 if (ring_rsp->rqid >= VSCSIIF_MAX_REQS ||
370 + !info->shadow[ring_rsp->rqid] ||
370 371 !info->shadow[ring_rsp->rqid]->inflight) {
371 372 scsifront_set_error(info, "illegal rqid returned by backend!");
372 373 return;
modified drivers/spi/spi-fsl-lpspi.c
@@ -550,11 +550,8 @@ static int fsl_lpspi_target_abort(struct spi_controller *controller)
550 550 return 0;
551 551 }
552 552
553 - static int fsl_lpspi_wait_for_completion(struct spi_controller *controller)
553 + static int fsl_lpspi_wait_for_completion(struct fsl_lpspi_data *fsl_lpspi)
554 554 {
555 - struct fsl_lpspi_data *fsl_lpspi =
556 - spi_controller_get_devdata(controller);
557 -
558 555 if (fsl_lpspi->is_target) {
559 556 if (wait_for_completion_interruptible(&fsl_lpspi->xfer_done) ||
560 557 fsl_lpspi->target_aborted) {
@@ -758,11 +755,9 @@ err:
758 755 return ret;
759 756 }
760 757
761 - static int fsl_lpspi_pio_transfer(struct spi_controller *controller,
758 + static int fsl_lpspi_pio_transfer(struct fsl_lpspi_data *fsl_lpspi,
762 759 struct spi_transfer *t)
763 760 {
764 - struct fsl_lpspi_data *fsl_lpspi =
765 - spi_controller_get_devdata(controller);
766 761 int ret;
767 762
768 763 fsl_lpspi->tx_buf = t->tx_buf;
@@ -774,7 +769,7 @@ static int fsl_lpspi_pio_transfer(struct spi_controller *controller,
774 769
775 770 fsl_lpspi_write_tx_fifo(fsl_lpspi);
776 771
777 - ret = fsl_lpspi_wait_for_completion(controller);
772 + ret = fsl_lpspi_wait_for_completion(fsl_lpspi);
778 773
779 774 fsl_lpspi_reset(fsl_lpspi);
780 775
@@ -803,11 +798,9 @@ static int fsl_lpspi_transfer_one(struct spi_controller *controller,
803 798 if (fsl_lpspi->usedma)
804 799 ret = fsl_lpspi_dma_transfer(controller, fsl_lpspi, t);
805 800 else
806 - ret = fsl_lpspi_pio_transfer(controller, t);
807 - if (ret < 0)
808 - return ret;
801 + ret = fsl_lpspi_pio_transfer(fsl_lpspi, t);
809 802
810 - return 0;
803 + return ret;
811 804 }
812 805
813 806 static irqreturn_t fsl_lpspi_isr(int irq, void *dev_id)
modified drivers/spi/spi-imx.c
@@ -1578,11 +1578,13 @@ static int spi_imx_dma_tx_data_handle(struct spi_imx_data *spi_imx,
1578 1578 dma_data->dma_len = ALIGN(dma_data->data_len, BYTES_PER_32BITS_WORD);
1579 1579 }
1580 1580
1581 - dma_data->dma_tx_buf = kzalloc(dma_data->dma_len, GFP_KERNEL);
1581 + dma_data->dma_tx_buf = kzalloc(DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1582 + GFP_KERNEL);
1582 1583 if (!dma_data->dma_tx_buf)
1583 1584 return -ENOMEM;
1584 1585
1585 - dma_data->dma_rx_buf = kzalloc(dma_data->dma_len, GFP_KERNEL);
1586 + dma_data->dma_rx_buf = kzalloc(DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1587 + GFP_KERNEL);
1586 1588 if (!dma_data->dma_rx_buf) {
1587 1589 kfree(dma_data->dma_tx_buf);
1588 1590 return -ENOMEM;
@@ -1920,7 +1922,8 @@ static int spi_imx_dma_package_transfer(struct spi_imx_data *spi_imx,
1920 1922
1921 1923 /* Trim the DMA RX buffer and copy the actual data to rx_buf */
1922 1924 dma_sync_single_for_cpu(controller->dma_rx->device->dev, dma_data->dma_rx_addr,
1923 - dma_data->dma_len, DMA_FROM_DEVICE);
1925 + DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1926 + DMA_FROM_DEVICE);
1924 1927 spi_imx_dma_rx_data_handle(spi_imx, dma_data, transfer->rx_buf + spi_imx->rx_offset,
1925 1928 word_delay);
1926 1929 spi_imx->rx_offset += dma_data->data_len;
modified drivers/spi/spi-tegra114.c
@@ -859,6 +859,13 @@ static u32 tegra_spi_setup_transfer_one(struct spi_device *spi,
859 859 command1 |= SPI_BIT_LENGTH(bits_per_word - 1);
860 860 }
861 861
862 + /*
863 + * Re-assert the CS GPIO for every transfer: transfer_end() drops it
864 + * on cs_change, and the assert above only covers is_first_of_msg.
865 + */
866 + if (spi_get_csgpiod(spi, 0))
867 + gpiod_set_value(spi_get_csgpiod(spi, 0), 1);
868 +
862 869 return command1;
863 870 }
864 871
modified drivers/target/iscsi/iscsi_target_configfs.c
@@ -1306,17 +1306,24 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1306 1306 return -EINVAL;
1307 1307 }
1308 1308
1309 + if (iscsit_get_tpg(discovery_tpg) < 0)
1310 + return -EINVAL;
1311 +
1309 1312 param = iscsi_find_param_from_key(AUTHMETHOD,
1310 1313 discovery_tpg->param_list);
1311 - if (!param)
1312 - return -EINVAL;
1314 + if (!param) {
1315 + err = -EINVAL;
1316 + goto out;
1317 + }
1313 1318
1314 1319 if (op) {
1315 1320 /*
1316 1321 * Reset the AuthMethod key to CHAP.
1317 1322 */
1318 - if (iscsi_update_param_value(param, CHAP) < 0)
1319 - return -EINVAL;
1323 + if (iscsi_update_param_value(param, CHAP) < 0) {
1324 + err = -EINVAL;
1325 + goto out;
1326 + }
1320 1327
1321 1328 discovery_tpg->tpg_attrib.authentication = 1;
1322 1329 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
@@ -1327,8 +1334,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1327 1334 /*
1328 1335 * Reset the AuthMethod key to CHAP,None
1329 1336 */
1330 - if (iscsi_update_param_value(param, "CHAP,None") < 0)
1331 - return -EINVAL;
1337 + if (iscsi_update_param_value(param, "CHAP,None") < 0) {
1338 + err = -EINVAL;
1339 + goto out;
1340 + }
1332 1341
1333 1342 discovery_tpg->tpg_attrib.authentication = 0;
1334 1343 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
@@ -1337,7 +1346,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1337 1346 " Discovery TPG\n");
1338 1347 }
1339 1348
1340 - return count;
1349 + err = count;
1350 + out:
1351 + iscsit_put_tpg(discovery_tpg);
1352 + return err;
1341 1353 }
1342 1354
1343 1355 CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
modified drivers/target/target_core_transport.c
@@ -2359,7 +2359,7 @@ void target_do_delayed_work(struct work_struct *work)
2359 2359 struct se_device *dev = container_of(work, struct se_device,
2360 2360 delayed_cmd_work);
2361 2361
2362 - spin_lock(&dev->delayed_cmd_lock);
2362 + spin_lock_irq(&dev->delayed_cmd_lock);
2363 2363 while (!dev->ordered_sync_in_progress) {
2364 2364 struct se_cmd *cmd;
2365 2365
@@ -2380,12 +2380,12 @@ void target_do_delayed_work(struct work_struct *work)
2380 2380 dev->ordered_sync_in_progress = true;
2381 2381
2382 2382 list_del(&cmd->se_delayed_node);
2383 - spin_unlock(&dev->delayed_cmd_lock);
2383 + spin_unlock_irq(&dev->delayed_cmd_lock);
2384 2384
2385 2385 __target_execute_cmd(cmd, true);
2386 - spin_lock(&dev->delayed_cmd_lock);
2386 + spin_lock_irq(&dev->delayed_cmd_lock);
2387 2387 }
2388 - spin_unlock(&dev->delayed_cmd_lock);
2388 + spin_unlock_irq(&dev->delayed_cmd_lock);
2389 2389 }
2390 2390
2391 2391 static void transport_complete_ordered_sync(struct se_cmd *cmd)
modified drivers/ufs/core/ufs_bsg.c
@@ -258,7 +258,7 @@ int ufs_bsg_probe(struct ufs_hba *hba)
258 258 goto out;
259 259
260 260 q = bsg_setup_queue(bsg_dev, dev_name(bsg_dev), NULL, ufs_bsg_request,
261 - NULL, 0);
261 + NULL, 0, sizeof(struct ufs_rpmb_reply));
262 262 if (IS_ERR(q)) {
263 263 ret = PTR_ERR(q);
264 264 device_del(bsg_dev);
modified include/linux/bsg-lib.h
@@ -66,7 +66,8 @@ void bsg_job_done(struct bsg_job *job, int result,
66 66 unsigned int reply_payload_rcv_len);
67 67 struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
68 68 struct queue_limits *lim, bsg_job_fn *job_fn,
69 - bsg_timeout_fn *timeout, int dd_job_size);
69 + bsg_timeout_fn *timeout, int dd_job_size,
70 + unsigned int reply_len);
70 71 void bsg_remove_queue(struct request_queue *q);
71 72 void bsg_job_put(struct bsg_job *job);
72 73 int __must_check bsg_job_get(struct bsg_job *job);
modified include/linux/maple_tree.h
@@ -507,9 +507,13 @@ struct ma_wr_state {
507 507 };
508 508
509 509 #define mas_lock(mas) spin_lock(&((mas)->tree->ma_lock))
510 + #define mas_lock_irqsave(mas, flags) \
511 + spin_lock_irqsave(&((mas)->tree->ma_lock), flags)
510 512 #define mas_lock_nested(mas, subclass) \
511 513 spin_lock_nested(&((mas)->tree->ma_lock), subclass)
512 514 #define mas_unlock(mas) spin_unlock(&((mas)->tree->ma_lock))
515 + #define mas_unlock_irqrestore(mas, flags) \
516 + spin_unlock_irqrestore(&((mas)->tree->ma_lock), flags)
513 517
514 518 /*
515 519 * Special values for ma_state.node.