Skip to content

Commit 2b76da9

Browse files
committed
Merge branch 'nvme-4.14' of git://git.infradead.org/nvme into for-4.14/block-postmerge
Pull NVMe changes from Christoph: "Below is the current set of NVMe updates for Linux 4.14, now against your postmerge branch, and with three more patches. The biggest bit comes from Sagi and refactors the RDMA driver to prepare for more code sharing in the setup and teardown path. But we have various features and bug fixes from a lot of people as well."
2 parents cd996fb + 1d5df6a commit 2b76da9

File tree

15 files changed

+677
-444
lines changed

15 files changed

+677
-444
lines changed

drivers/nvme/host/core.c

Lines changed: 189 additions & 53 deletions
Large diffs are not rendered by default.

drivers/nvme/host/fabrics.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
735735
goto out;
736736
}
737737
if (uuid_parse(p, &hostid)) {
738+
pr_err("Invalid hostid %s\n", p);
738739
ret = -EINVAL;
739740
goto out;
740741
}

drivers/nvme/host/fc.c

Lines changed: 107 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,90 @@ static int __nvme_fc_del_ctrl(struct nvme_fc_ctrl *);
220220
static void __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *,
221221
struct nvme_fc_queue *, unsigned int);
222222

223+
static void
224+
nvme_fc_free_lport(struct kref *ref)
225+
{
226+
struct nvme_fc_lport *lport =
227+
container_of(ref, struct nvme_fc_lport, ref);
228+
unsigned long flags;
229+
230+
WARN_ON(lport->localport.port_state != FC_OBJSTATE_DELETED);
231+
WARN_ON(!list_empty(&lport->endp_list));
232+
233+
/* remove from transport list */
234+
spin_lock_irqsave(&nvme_fc_lock, flags);
235+
list_del(&lport->port_list);
236+
spin_unlock_irqrestore(&nvme_fc_lock, flags);
237+
238+
/* let the LLDD know we've finished tearing it down */
239+
lport->ops->localport_delete(&lport->localport);
240+
241+
ida_simple_remove(&nvme_fc_local_port_cnt, lport->localport.port_num);
242+
ida_destroy(&lport->endp_cnt);
243+
244+
put_device(lport->dev);
245+
246+
kfree(lport);
247+
}
248+
249+
static void
250+
nvme_fc_lport_put(struct nvme_fc_lport *lport)
251+
{
252+
kref_put(&lport->ref, nvme_fc_free_lport);
253+
}
254+
255+
static int
256+
nvme_fc_lport_get(struct nvme_fc_lport *lport)
257+
{
258+
return kref_get_unless_zero(&lport->ref);
259+
}
260+
261+
262+
static struct nvme_fc_lport *
263+
nvme_fc_attach_to_unreg_lport(struct nvme_fc_port_info *pinfo)
264+
{
265+
struct nvme_fc_lport *lport;
266+
unsigned long flags;
267+
268+
spin_lock_irqsave(&nvme_fc_lock, flags);
269+
270+
list_for_each_entry(lport, &nvme_fc_lport_list, port_list) {
271+
if (lport->localport.node_name != pinfo->node_name ||
272+
lport->localport.port_name != pinfo->port_name)
273+
continue;
274+
275+
if (lport->localport.port_state != FC_OBJSTATE_DELETED) {
276+
lport = ERR_PTR(-EEXIST);
277+
goto out_done;
278+
}
279+
280+
if (!nvme_fc_lport_get(lport)) {
281+
/*
282+
* fails if ref cnt already 0. If so,
283+
* act as if lport already deleted
284+
*/
285+
lport = NULL;
286+
goto out_done;
287+
}
288+
289+
/* resume the lport */
290+
291+
lport->localport.port_role = pinfo->port_role;
292+
lport->localport.port_id = pinfo->port_id;
293+
lport->localport.port_state = FC_OBJSTATE_ONLINE;
294+
295+
spin_unlock_irqrestore(&nvme_fc_lock, flags);
296+
297+
return lport;
298+
}
299+
300+
lport = NULL;
301+
302+
out_done:
303+
spin_unlock_irqrestore(&nvme_fc_lock, flags);
304+
305+
return lport;
306+
}
223307

224308
/**
225309
* nvme_fc_register_localport - transport entry point called by an
@@ -257,6 +341,28 @@ nvme_fc_register_localport(struct nvme_fc_port_info *pinfo,
257341
goto out_reghost_failed;
258342
}
259343

344+
/*
345+
* look to see if there is already a localport that had been
346+
* deregistered and in the process of waiting for all the
347+
* references to fully be removed. If the references haven't
348+
* expired, we can simply re-enable the localport. Remoteports
349+
* and controller reconnections should resume naturally.
350+
*/
351+
newrec = nvme_fc_attach_to_unreg_lport(pinfo);
352+
353+
/* found an lport, but something about its state is bad */
354+
if (IS_ERR(newrec)) {
355+
ret = PTR_ERR(newrec);
356+
goto out_reghost_failed;
357+
358+
/* found existing lport, which was resumed */
359+
} else if (newrec) {
360+
*portptr = &newrec->localport;
361+
return 0;
362+
}
363+
364+
/* nothing found - allocate a new localport struct */
365+
260366
newrec = kmalloc((sizeof(*newrec) + template->local_priv_sz),
261367
GFP_KERNEL);
262368
if (!newrec) {
@@ -310,44 +416,6 @@ nvme_fc_register_localport(struct nvme_fc_port_info *pinfo,
310416
}
311417
EXPORT_SYMBOL_GPL(nvme_fc_register_localport);
312418

313-
static void
314-
nvme_fc_free_lport(struct kref *ref)
315-
{
316-
struct nvme_fc_lport *lport =
317-
container_of(ref, struct nvme_fc_lport, ref);
318-
unsigned long flags;
319-
320-
WARN_ON(lport->localport.port_state != FC_OBJSTATE_DELETED);
321-
WARN_ON(!list_empty(&lport->endp_list));
322-
323-
/* remove from transport list */
324-
spin_lock_irqsave(&nvme_fc_lock, flags);
325-
list_del(&lport->port_list);
326-
spin_unlock_irqrestore(&nvme_fc_lock, flags);
327-
328-
/* let the LLDD know we've finished tearing it down */
329-
lport->ops->localport_delete(&lport->localport);
330-
331-
ida_simple_remove(&nvme_fc_local_port_cnt, lport->localport.port_num);
332-
ida_destroy(&lport->endp_cnt);
333-
334-
put_device(lport->dev);
335-
336-
kfree(lport);
337-
}
338-
339-
static void
340-
nvme_fc_lport_put(struct nvme_fc_lport *lport)
341-
{
342-
kref_put(&lport->ref, nvme_fc_free_lport);
343-
}
344-
345-
static int
346-
nvme_fc_lport_get(struct nvme_fc_lport *lport)
347-
{
348-
return kref_get_unless_zero(&lport->ref);
349-
}
350-
351419
/**
352420
* nvme_fc_unregister_localport - transport entry point called by an
353421
* LLDD to deregister/remove a previously
@@ -2731,6 +2799,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
27312799
ret = blk_mq_alloc_tag_set(&ctrl->admin_tag_set);
27322800
if (ret)
27332801
goto out_free_queues;
2802+
ctrl->ctrl.admin_tagset = &ctrl->admin_tag_set;
27342803

27352804
ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set);
27362805
if (IS_ERR(ctrl->ctrl.admin_q)) {

drivers/nvme/host/nvme.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct nvme_ctrl {
125125
struct kref kref;
126126
int instance;
127127
struct blk_mq_tag_set *tagset;
128+
struct blk_mq_tag_set *admin_tagset;
128129
struct list_head namespaces;
129130
struct mutex namespaces_mutex;
130131
struct device *device; /* char device */
@@ -142,6 +143,7 @@ struct nvme_ctrl {
142143
u16 cntlid;
143144

144145
u32 ctrl_config;
146+
u16 mtfa;
145147
u32 queue_count;
146148

147149
u64 cap;
@@ -160,13 +162,15 @@ struct nvme_ctrl {
160162
u16 kas;
161163
u8 npss;
162164
u8 apsta;
165+
unsigned int shutdown_timeout;
163166
unsigned int kato;
164167
bool subsystem;
165168
unsigned long quirks;
166169
struct nvme_id_power_state psd[32];
167170
struct work_struct scan_work;
168171
struct work_struct async_event_work;
169172
struct delayed_work ka_work;
173+
struct work_struct fw_act_work;
170174

171175
/* Power saving configuration */
172176
u64 ps_max_latency_us;
@@ -207,13 +211,9 @@ struct nvme_ns {
207211
bool ext;
208212
u8 pi_type;
209213
unsigned long flags;
210-
u16 noiob;
211-
212214
#define NVME_NS_REMOVING 0
213215
#define NVME_NS_DEAD 1
214-
215-
u64 mode_select_num_blocks;
216-
u32 mode_select_block_len;
216+
u16 noiob;
217217
};
218218

219219
struct nvme_ctrl_ops {

drivers/nvme/host/pci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,10 @@ static blk_status_t nvme_setup_prps(struct nvme_dev *dev, struct request *req)
555555
int nprps, i;
556556

557557
length -= (page_size - offset);
558-
if (length <= 0)
558+
if (length <= 0) {
559+
iod->first_dma = 0;
559560
return BLK_STS_OK;
561+
}
560562

561563
dma_len -= (page_size - offset);
562564
if (dma_len) {
@@ -1376,6 +1378,7 @@ static int nvme_alloc_admin_tags(struct nvme_dev *dev)
13761378

13771379
if (blk_mq_alloc_tag_set(&dev->admin_tagset))
13781380
return -ENOMEM;
1381+
dev->ctrl.admin_tagset = &dev->admin_tagset;
13791382

13801383
dev->ctrl.admin_q = blk_mq_init_queue(&dev->admin_tagset);
13811384
if (IS_ERR(dev->ctrl.admin_q)) {

0 commit comments

Comments
 (0)