Skip to content

Commit d57ce84

Browse files
committed
Merge tag 's390-5.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fixes from Vasily Gorbik: - a couple of fixes for storage key handling relevant for debugging - add cond_resched into potentially slow subchannels scanning loop - fixes for PF/VF linking and to ignore stale PCI configuration request events * tag 's390-5.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/pci: fix PF/VF linking on hot plug s390/pci: re-introduce zpci_remove_device() s390/pci: fix zpci_bus_link_virtfn() s390/ptrace: fix storage key handling s390/runtime_instrumentation: fix storage key handling s390/pci: ignore stale configuration request event s390/cio: add cond_resched() in the slow_eval_known_fn() loop
2 parents b2d9e99 + b97bf44 commit d57ce84

File tree

8 files changed

+79
-41
lines changed

8 files changed

+79
-41
lines changed

arch/s390/kernel/ptrace.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,6 @@ static bool is_ri_cb_valid(struct runtime_instr_cb *cb)
12681268
cb->pc == 1 &&
12691269
cb->qc == 0 &&
12701270
cb->reserved2 == 0 &&
1271-
cb->key == PAGE_DEFAULT_KEY &&
12721271
cb->reserved3 == 0 &&
12731272
cb->reserved4 == 0 &&
12741273
cb->reserved5 == 0 &&
@@ -1330,7 +1329,11 @@ static int s390_runtime_instr_set(struct task_struct *target,
13301329
kfree(data);
13311330
return -EINVAL;
13321331
}
1333-
1332+
/*
1333+
* Override access key in any case, since user space should
1334+
* not be able to set it, nor should it care about it.
1335+
*/
1336+
ri_cb.key = PAGE_DEFAULT_KEY >> 4;
13341337
preempt_disable();
13351338
if (!target->thread.ri_cb)
13361339
target->thread.ri_cb = data;

arch/s390/kernel/runtime_instr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void init_runtime_instr_cb(struct runtime_instr_cb *cb)
5757
cb->k = 1;
5858
cb->ps = 1;
5959
cb->pc = 1;
60-
cb->key = PAGE_DEFAULT_KEY;
60+
cb->key = PAGE_DEFAULT_KEY >> 4;
6161
cb->v = 1;
6262
}
6363

arch/s390/pci/pci.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,19 @@ int zpci_disable_device(struct zpci_dev *zdev)
672672
}
673673
EXPORT_SYMBOL_GPL(zpci_disable_device);
674674

675+
void zpci_remove_device(struct zpci_dev *zdev)
676+
{
677+
struct zpci_bus *zbus = zdev->zbus;
678+
struct pci_dev *pdev;
679+
680+
pdev = pci_get_slot(zbus->bus, zdev->devfn);
681+
if (pdev) {
682+
if (pdev->is_virtfn)
683+
return zpci_remove_virtfn(pdev, zdev->vfn);
684+
pci_stop_and_remove_bus_device_locked(pdev);
685+
}
686+
}
687+
675688
int zpci_create_device(struct zpci_dev *zdev)
676689
{
677690
int rc;
@@ -716,13 +729,8 @@ void zpci_release_device(struct kref *kref)
716729
{
717730
struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref);
718731

719-
if (zdev->zbus->bus) {
720-
struct pci_dev *pdev;
721-
722-
pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
723-
if (pdev)
724-
pci_stop_and_remove_bus_device_locked(pdev);
725-
}
732+
if (zdev->zbus->bus)
733+
zpci_remove_device(zdev);
726734

727735
switch (zdev->state) {
728736
case ZPCI_FN_STATE_ONLINE:

arch/s390/pci/pci_bus.c

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,14 @@ static int zpci_bus_link_virtfn(struct pci_dev *pdev,
132132
{
133133
int rc;
134134

135-
virtfn->physfn = pci_dev_get(pdev);
136135
rc = pci_iov_sysfs_link(pdev, virtfn, vfid);
137-
if (rc) {
138-
pci_dev_put(pdev);
139-
virtfn->physfn = NULL;
136+
if (rc)
140137
return rc;
141-
}
138+
139+
virtfn->is_virtfn = 1;
140+
virtfn->multifunction = 0;
141+
virtfn->physfn = pci_dev_get(pdev);
142+
142143
return 0;
143144
}
144145

@@ -151,9 +152,9 @@ static int zpci_bus_setup_virtfn(struct zpci_bus *zbus,
151152
int vfid = vfn - 1; /* Linux' vfid's start at 0 vfn at 1*/
152153
int rc = 0;
153154

154-
virtfn->is_virtfn = 1;
155-
virtfn->multifunction = 0;
156-
WARN_ON(vfid < 0);
155+
if (!zbus->multifunction)
156+
return 0;
157+
157158
/* If the parent PF for the given VF is also configured in the
158159
* instance, it must be on the same zbus.
159160
* We can then identify the parent PF by checking what
@@ -165,11 +166,17 @@ static int zpci_bus_setup_virtfn(struct zpci_bus *zbus,
165166
zdev = zbus->function[i];
166167
if (zdev && zdev->is_physfn) {
167168
pdev = pci_get_slot(zbus->bus, zdev->devfn);
169+
if (!pdev)
170+
continue;
168171
cand_devfn = pci_iov_virtfn_devfn(pdev, vfid);
169172
if (cand_devfn == virtfn->devfn) {
170173
rc = zpci_bus_link_virtfn(pdev, virtfn, vfid);
174+
/* balance pci_get_slot() */
175+
pci_dev_put(pdev);
171176
break;
172177
}
178+
/* balance pci_get_slot() */
179+
pci_dev_put(pdev);
173180
}
174181
}
175182
return rc;
@@ -178,12 +185,23 @@ static int zpci_bus_setup_virtfn(struct zpci_bus *zbus,
178185
static inline int zpci_bus_setup_virtfn(struct zpci_bus *zbus,
179186
struct pci_dev *virtfn, int vfn)
180187
{
181-
virtfn->is_virtfn = 1;
182-
virtfn->multifunction = 0;
183188
return 0;
184189
}
185190
#endif
186191

192+
void pcibios_bus_add_device(struct pci_dev *pdev)
193+
{
194+
struct zpci_dev *zdev = to_zpci(pdev);
195+
196+
/*
197+
* With pdev->no_vf_scan the common PCI probing code does not
198+
* perform PF/VF linking.
199+
*/
200+
if (zdev->vfn)
201+
zpci_bus_setup_virtfn(zdev->zbus, pdev, zdev->vfn);
202+
203+
}
204+
187205
static int zpci_bus_add_device(struct zpci_bus *zbus, struct zpci_dev *zdev)
188206
{
189207
struct pci_bus *bus;
@@ -214,20 +232,10 @@ static int zpci_bus_add_device(struct zpci_bus *zbus, struct zpci_dev *zdev)
214232
}
215233

216234
pdev = pci_scan_single_device(bus, zdev->devfn);
217-
if (pdev) {
218-
if (!zdev->is_physfn) {
219-
rc = zpci_bus_setup_virtfn(zbus, pdev, zdev->vfn);
220-
if (rc)
221-
goto failed_with_pdev;
222-
}
235+
if (pdev)
223236
pci_bus_add_device(pdev);
224-
}
225-
return 0;
226237

227-
failed_with_pdev:
228-
pci_stop_and_remove_bus_device(pdev);
229-
pci_dev_put(pdev);
230-
return rc;
238+
return 0;
231239
}
232240

233241
static void zpci_bus_add_devices(struct zpci_bus *zbus)

arch/s390/pci/pci_bus.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,16 @@ static inline struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus,
2929

3030
return (devfn >= ZPCI_FUNCTIONS_PER_BUS) ? NULL : zbus->function[devfn];
3131
}
32+
33+
#ifdef CONFIG_PCI_IOV
34+
static inline void zpci_remove_virtfn(struct pci_dev *pdev, int vfn)
35+
{
36+
37+
pci_lock_rescan_remove();
38+
/* Linux' vfid's start at 0 vfn at 1 */
39+
pci_iov_remove_virtfn(pdev->physfn, vfn - 1);
40+
pci_unlock_rescan_remove();
41+
}
42+
#else /* CONFIG_PCI_IOV */
43+
static inline void zpci_remove_virtfn(struct pci_dev *pdev, int vfn) {}
44+
#endif /* CONFIG_PCI_IOV */

arch/s390/pci/pci_event.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
9292
ret = clp_add_pci_device(ccdf->fid, ccdf->fh, 1);
9393
break;
9494
}
95+
/* the configuration request may be stale */
96+
if (zdev->state != ZPCI_FN_STATE_STANDBY)
97+
break;
9598
zdev->fh = ccdf->fh;
9699
zdev->state = ZPCI_FN_STATE_CONFIGURED;
97100
ret = zpci_enable_device(zdev);
@@ -118,7 +121,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
118121
if (!zdev)
119122
break;
120123
if (pdev)
121-
pci_stop_and_remove_bus_device_locked(pdev);
124+
zpci_remove_device(zdev);
122125

123126
ret = zpci_disable_device(zdev);
124127
if (ret)
@@ -137,7 +140,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
137140
/* Give the driver a hint that the function is
138141
* already unusable. */
139142
pdev->error_state = pci_channel_io_perm_failure;
140-
pci_stop_and_remove_bus_device_locked(pdev);
143+
zpci_remove_device(zdev);
141144
}
142145

143146
zdev->state = ZPCI_FN_STATE_STANDBY;

drivers/pci/hotplug/s390_pci_hpc.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,19 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
8383
struct zpci_dev *zdev = container_of(hotplug_slot, struct zpci_dev,
8484
hotplug_slot);
8585
struct pci_dev *pdev;
86-
struct zpci_bus *zbus = zdev->zbus;
8786
int rc;
8887

8988
if (!zpci_fn_configured(zdev->state))
9089
return -EIO;
9190

92-
pdev = pci_get_slot(zbus->bus, zdev->devfn);
93-
if (pdev) {
94-
if (pci_num_vf(pdev))
95-
return -EBUSY;
96-
97-
pci_stop_and_remove_bus_device_locked(pdev);
91+
pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
92+
if (pdev && pci_num_vf(pdev)) {
9893
pci_dev_put(pdev);
94+
return -EBUSY;
9995
}
10096

97+
zpci_remove_device(zdev);
98+
10199
rc = zpci_disable_device(zdev);
102100
if (rc)
103101
return rc;

drivers/s390/cio/css.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,11 @@ static int slow_eval_known_fn(struct subchannel *sch, void *data)
677677
rc = css_evaluate_known_subchannel(sch, 1);
678678
if (rc == -EAGAIN)
679679
css_schedule_eval(sch->schid);
680+
/*
681+
* The loop might take long time for platforms with lots of
682+
* known devices. Allow scheduling here.
683+
*/
684+
cond_resched();
680685
}
681686
return 0;
682687
}

0 commit comments

Comments
 (0)