Skip to content

Commit b8fa3e9

Browse files
halil-pasicAlexander Gordeev
authored andcommitted
s390/cio: make sch->lock spinlock pointer a member
The lock member of struct subchannel used to be a spinlock, but became a pointer to a spinlock with commit 2ec2298 ("[S390] subchannel lock conversion."). This might have been justified back then, but with the current state of affairs, there is no reason to manage a separate spinlock object. Let's simplify things and pull the spinlock back into struct subchannel. Signed-off-by: Halil Pasic <pasic@linux.ibm.com> Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com> Link: https://lore.kernel.org/r/20231101115751.2308307-1-pasic@linux.ibm.com Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 7fe228e commit b8fa3e9

10 files changed

Lines changed: 99 additions & 115 deletions

File tree

drivers/s390/cio/chsc.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,16 @@ EXPORT_SYMBOL_GPL(chsc_sadc);
219219

220220
static int s390_subchannel_remove_chpid(struct subchannel *sch, void *data)
221221
{
222-
spin_lock_irq(sch->lock);
222+
spin_lock_irq(&sch->lock);
223223
if (sch->driver && sch->driver->chp_event)
224224
if (sch->driver->chp_event(sch, data, CHP_OFFLINE) != 0)
225225
goto out_unreg;
226-
spin_unlock_irq(sch->lock);
226+
spin_unlock_irq(&sch->lock);
227227
return 0;
228228

229229
out_unreg:
230230
sch->lpm = 0;
231-
spin_unlock_irq(sch->lock);
231+
spin_unlock_irq(&sch->lock);
232232
css_schedule_eval(sch->schid);
233233
return 0;
234234
}
@@ -258,10 +258,10 @@ void chsc_chp_offline(struct chp_id chpid)
258258

259259
static int __s390_process_res_acc(struct subchannel *sch, void *data)
260260
{
261-
spin_lock_irq(sch->lock);
261+
spin_lock_irq(&sch->lock);
262262
if (sch->driver && sch->driver->chp_event)
263263
sch->driver->chp_event(sch, data, CHP_ONLINE);
264-
spin_unlock_irq(sch->lock);
264+
spin_unlock_irq(&sch->lock);
265265

266266
return 0;
267267
}
@@ -292,10 +292,10 @@ static void s390_process_res_acc(struct chp_link *link)
292292

293293
static int process_fces_event(struct subchannel *sch, void *data)
294294
{
295-
spin_lock_irq(sch->lock);
295+
spin_lock_irq(&sch->lock);
296296
if (sch->driver && sch->driver->chp_event)
297297
sch->driver->chp_event(sch, data, CHP_FCES_EVENT);
298-
spin_unlock_irq(sch->lock);
298+
spin_unlock_irq(&sch->lock);
299299
return 0;
300300
}
301301

@@ -769,11 +769,11 @@ static void __s390_subchannel_vary_chpid(struct subchannel *sch,
769769

770770
memset(&link, 0, sizeof(struct chp_link));
771771
link.chpid = chpid;
772-
spin_lock_irqsave(sch->lock, flags);
772+
spin_lock_irqsave(&sch->lock, flags);
773773
if (sch->driver && sch->driver->chp_event)
774774
sch->driver->chp_event(sch, &link,
775775
on ? CHP_VARY_ON : CHP_VARY_OFF);
776-
spin_unlock_irqrestore(sch->lock, flags);
776+
spin_unlock_irqrestore(&sch->lock, flags);
777777
}
778778

779779
static int s390_subchannel_vary_chpid_off(struct subchannel *sch, void *data)

drivers/s390/cio/chsc_sch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ static int chsc_async(struct chsc_async_area *chsc_area,
211211

212212
chsc_area->header.key = PAGE_DEFAULT_KEY >> 4;
213213
while ((sch = chsc_get_next_subchannel(sch))) {
214-
spin_lock(sch->lock);
214+
spin_lock(&sch->lock);
215215
private = dev_get_drvdata(&sch->dev);
216216
if (private->request) {
217-
spin_unlock(sch->lock);
217+
spin_unlock(&sch->lock);
218218
ret = -EBUSY;
219219
continue;
220220
}
@@ -239,7 +239,7 @@ static int chsc_async(struct chsc_async_area *chsc_area,
239239
default:
240240
ret = -ENODEV;
241241
}
242-
spin_unlock(sch->lock);
242+
spin_unlock(&sch->lock);
243243
CHSC_MSG(2, "chsc on 0.%x.%04x returned cc=%d\n",
244244
sch->schid.ssid, sch->schid.sch_no, cc);
245245
if (ret == -EINPROGRESS)

drivers/s390/cio/cio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static irqreturn_t do_cio_interrupt(int irq, void *dummy)
546546
return IRQ_HANDLED;
547547
}
548548
sch = phys_to_virt(tpi_info->intparm);
549-
spin_lock(sch->lock);
549+
spin_lock(&sch->lock);
550550
/* Store interrupt response block to lowcore. */
551551
if (tsch(tpi_info->schid, irb) == 0) {
552552
/* Keep subchannel information word up to date. */
@@ -558,7 +558,7 @@ static irqreturn_t do_cio_interrupt(int irq, void *dummy)
558558
inc_irq_stat(IRQIO_CIO);
559559
} else
560560
inc_irq_stat(IRQIO_CIO);
561-
spin_unlock(sch->lock);
561+
spin_unlock(&sch->lock);
562562

563563
return IRQ_HANDLED;
564564
}
@@ -663,7 +663,7 @@ struct subchannel *cio_probe_console(void)
663663
if (IS_ERR(sch))
664664
return sch;
665665

666-
lockdep_set_class(sch->lock, &console_sch_key);
666+
lockdep_set_class(&sch->lock, &console_sch_key);
667667
isc_register(CONSOLE_ISC);
668668
sch->config.isc = CONSOLE_ISC;
669669
sch->config.intparm = (u32)virt_to_phys(sch);

drivers/s390/cio/cio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ enum sch_todo {
8383
/* subchannel data structure used by I/O subroutines */
8484
struct subchannel {
8585
struct subchannel_id schid;
86-
spinlock_t *lock; /* subchannel lock */
86+
spinlock_t lock; /* subchannel lock */
8787
struct mutex reg_mutex;
8888
enum {
8989
SUBCHANNEL_TYPE_IO = 0,

drivers/s390/cio/css.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,10 @@ int for_each_subchannel_staged(int (*fn_known)(struct subchannel *, void *),
148148

149149
static void css_sch_todo(struct work_struct *work);
150150

151-
static int css_sch_create_locks(struct subchannel *sch)
151+
static void css_sch_create_locks(struct subchannel *sch)
152152
{
153-
sch->lock = kmalloc(sizeof(*sch->lock), GFP_KERNEL);
154-
if (!sch->lock)
155-
return -ENOMEM;
156-
157-
spin_lock_init(sch->lock);
153+
spin_lock_init(&sch->lock);
158154
mutex_init(&sch->reg_mutex);
159-
160-
return 0;
161155
}
162156

163157
static void css_subchannel_release(struct device *dev)
@@ -167,7 +161,6 @@ static void css_subchannel_release(struct device *dev)
167161
sch->config.intparm = 0;
168162
cio_commit_config(sch);
169163
kfree(sch->driver_override);
170-
kfree(sch->lock);
171164
kfree(sch);
172165
}
173166

@@ -219,9 +212,7 @@ struct subchannel *css_alloc_subchannel(struct subchannel_id schid,
219212
sch->schib = *schib;
220213
sch->st = schib->pmcw.st;
221214

222-
ret = css_sch_create_locks(sch);
223-
if (ret)
224-
goto err;
215+
css_sch_create_locks(sch);
225216

226217
INIT_WORK(&sch->todo_work, css_sch_todo);
227218
sch->dev.release = &css_subchannel_release;
@@ -233,19 +224,17 @@ struct subchannel *css_alloc_subchannel(struct subchannel_id schid,
233224
*/
234225
ret = dma_set_coherent_mask(&sch->dev, DMA_BIT_MASK(31));
235226
if (ret)
236-
goto err_lock;
227+
goto err;
237228
/*
238229
* But we don't have such restrictions imposed on the stuff that
239230
* is handled by the streaming API.
240231
*/
241232
ret = dma_set_mask(&sch->dev, DMA_BIT_MASK(64));
242233
if (ret)
243-
goto err_lock;
234+
goto err;
244235

245236
return sch;
246237

247-
err_lock:
248-
kfree(sch->lock);
249238
err:
250239
kfree(sch);
251240
return ERR_PTR(ret);
@@ -604,22 +593,22 @@ static void css_sch_todo(struct work_struct *work)
604593

605594
sch = container_of(work, struct subchannel, todo_work);
606595
/* Find out todo. */
607-
spin_lock_irq(sch->lock);
596+
spin_lock_irq(&sch->lock);
608597
todo = sch->todo;
609598
CIO_MSG_EVENT(4, "sch_todo: sch=0.%x.%04x, todo=%d\n", sch->schid.ssid,
610599
sch->schid.sch_no, todo);
611600
sch->todo = SCH_TODO_NOTHING;
612-
spin_unlock_irq(sch->lock);
601+
spin_unlock_irq(&sch->lock);
613602
/* Perform todo. */
614603
switch (todo) {
615604
case SCH_TODO_NOTHING:
616605
break;
617606
case SCH_TODO_EVAL:
618607
ret = css_evaluate_known_subchannel(sch, 1);
619608
if (ret == -EAGAIN) {
620-
spin_lock_irq(sch->lock);
609+
spin_lock_irq(&sch->lock);
621610
css_sched_sch_todo(sch, todo);
622-
spin_unlock_irq(sch->lock);
611+
spin_unlock_irq(&sch->lock);
623612
}
624613
break;
625614
case SCH_TODO_UNREG:
@@ -1028,12 +1017,7 @@ static int __init setup_css(int nr)
10281017
css->pseudo_subchannel->dev.parent = &css->device;
10291018
css->pseudo_subchannel->dev.release = css_subchannel_release;
10301019
mutex_init(&css->pseudo_subchannel->reg_mutex);
1031-
ret = css_sch_create_locks(css->pseudo_subchannel);
1032-
if (ret) {
1033-
kfree(css->pseudo_subchannel);
1034-
device_unregister(&css->device);
1035-
goto out_err;
1036-
}
1020+
css_sch_create_locks(css->pseudo_subchannel);
10371021

10381022
dev_set_name(&css->pseudo_subchannel->dev, "defunct");
10391023
ret = device_register(&css->pseudo_subchannel->dev);

0 commit comments

Comments
 (0)