Skip to content

Commit 4404621

Browse files
committed
Merge tag 'for-5.14/drivers-2021-06-29' of git://git.kernel.dk/linux-block
Pull block driver updates from Jens Axboe: "Pretty calm round, mostly just NVMe and a bit of MD: - NVMe updates (via Christoph) - improve the APST configuration algorithm (Alexey Bogoslavsky) - look for StorageD3Enable on companion ACPI device (Mario Limonciello) - allow selecting the network interface for TCP connections (Martin Belanger) - misc cleanups (Amit Engel, Chaitanya Kulkarni, Colin Ian King, Christoph) - move the ACPI StorageD3 code to drivers/acpi/ and add quirks for certain AMD CPUs (Mario Limonciello) - zoned device support for nvmet (Chaitanya Kulkarni) - fix the rules for changing the serial number in nvmet (Noam Gottlieb) - various small fixes and cleanups (Dan Carpenter, JK Kim, Chaitanya Kulkarni, Hannes Reinecke, Wesley Sheng, Geert Uytterhoeven, Daniel Wagner) - MD updates (Via Song) - iostats rewrite (Guoqing Jiang) - raid5 lock contention optimization (Gal Ofri) - Fall through warning fix (Gustavo) - Misc fixes (Gustavo, Jiapeng)" * tag 'for-5.14/drivers-2021-06-29' of git://git.kernel.dk/linux-block: (78 commits) nvmet: use NVMET_MAX_NAMESPACES to set nn value loop: Fix missing discard support when using LOOP_CONFIGURE nvme.h: add missing nvme_lba_range_type endianness annotations nvme: remove zeroout memset call for struct nvme-pci: remove zeroout memset call for struct nvmet: remove zeroout memset call for struct nvmet: add ZBD over ZNS backend support nvmet: add Command Set Identifier support nvmet: add nvmet_req_bio put helper for backends nvmet: add req cns error complete helper block: export blk_next_bio() nvmet: remove local variable nvmet: use nvme status value directly nvmet: use u32 type for the local variable nsid nvmet: use u32 for nvmet_subsys max_nsid nvmet: use req->cmd directly in file-ns fast path nvmet: use req->cmd directly in bdev-ns fast path nvmet: make ver stable once connection established nvmet: allow mn change if subsys not discovered nvmet: make sn stable once connection was established ...
2 parents df668a5 + 5ed9b35 commit 4404621

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1467
-519
lines changed

block/blk-lib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct bio *blk_next_bio(struct bio *bio, unsigned int nr_pages, gfp_t gfp)
2121

2222
return new;
2323
}
24+
EXPORT_SYMBOL_GPL(blk_next_bio);
2425

2526
int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
2627
sector_t nr_sects, gfp_t gfp_mask, int flags,

drivers/acpi/device_pm.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,4 +1368,36 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
13681368
return 1;
13691369
}
13701370
EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
1371+
1372+
/**
1373+
* acpi_storage_d3 - Check if D3 should be used in the suspend path
1374+
* @dev: Device to check
1375+
*
1376+
* Return %true if the platform firmware wants @dev to be programmed
1377+
* into D3hot or D3cold (if supported) in the suspend path, or %false
1378+
* when there is no specific preference. On some platforms, if this
1379+
* hint is ignored, @dev may remain unresponsive after suspending the
1380+
* platform as a whole.
1381+
*
1382+
* Although the property has storage in the name it actually is
1383+
* applied to the PCIe slot and plugging in a non-storage device the
1384+
* same platform restrictions will likely apply.
1385+
*/
1386+
bool acpi_storage_d3(struct device *dev)
1387+
{
1388+
struct acpi_device *adev = ACPI_COMPANION(dev);
1389+
u8 val;
1390+
1391+
if (force_storage_d3())
1392+
return true;
1393+
1394+
if (!adev)
1395+
return false;
1396+
if (fwnode_property_read_u8(acpi_fwnode_handle(adev), "StorageD3Enable",
1397+
&val))
1398+
return false;
1399+
return val == 1;
1400+
}
1401+
EXPORT_SYMBOL_GPL(acpi_storage_d3);
1402+
13711403
#endif /* CONFIG_PM */

drivers/acpi/internal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@ static inline int suspend_nvs_save(void) { return 0; }
234234
static inline void suspend_nvs_restore(void) {}
235235
#endif
236236

237+
#ifdef CONFIG_X86
238+
bool force_storage_d3(void);
239+
#else
240+
static inline bool force_storage_d3(void)
241+
{
242+
return false;
243+
}
244+
#endif
245+
237246
/*--------------------------------------------------------------------------
238247
Device properties
239248
-------------------------------------------------------------------------- */

drivers/acpi/x86/utils.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,28 @@ bool acpi_device_always_present(struct acpi_device *adev)
135135

136136
return ret;
137137
}
138+
139+
/*
140+
* AMD systems from Renoir and Lucienne *require* that the NVME controller
141+
* is put into D3 over a Modern Standby / suspend-to-idle cycle.
142+
*
143+
* This is "typically" accomplished using the `StorageD3Enable`
144+
* property in the _DSD that is checked via the `acpi_storage_d3` function
145+
* but this property was introduced after many of these systems launched
146+
* and most OEM systems don't have it in their BIOS.
147+
*
148+
* The Microsoft documentation for StorageD3Enable mentioned that Windows has
149+
* a hardcoded allowlist for D3 support, which was used for these platforms.
150+
*
151+
* This allows quirking on Linux in a similar fashion.
152+
*/
153+
static const struct x86_cpu_id storage_d3_cpu_ids[] = {
154+
X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 96, NULL), /* Renoir */
155+
X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 104, NULL), /* Lucienne */
156+
{}
157+
};
158+
159+
bool force_storage_d3(void)
160+
{
161+
return x86_match_cpu(storage_d3_cpu_ids);
162+
}

drivers/block/aoe/aoechr.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ bail: spin_unlock_irqrestore(&emsgs_lock, flags);
140140
}
141141

142142
mp = kmemdup(msg, n, GFP_ATOMIC);
143-
if (mp == NULL) {
144-
printk(KERN_ERR "aoe: allocation failure, len=%ld\n", n);
143+
if (!mp)
145144
goto bail;
146-
}
147145

148146
em->msg = mp;
149147
em->flags |= EMFL_VALID;

drivers/block/drbd/drbd_receiver.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3770,10 +3770,8 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in
37703770
}
37713771

37723772
new_net_conf = kmalloc(sizeof(struct net_conf), GFP_KERNEL);
3773-
if (!new_net_conf) {
3774-
drbd_err(connection, "Allocation of new net_conf failed\n");
3773+
if (!new_net_conf)
37753774
goto disconnect;
3776-
}
37773775

37783776
mutex_lock(&connection->data.mutex);
37793777
mutex_lock(&connection->resource->conf_update);
@@ -4020,10 +4018,8 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i
40204018

40214019
if (verify_tfm || csums_tfm) {
40224020
new_net_conf = kzalloc(sizeof(struct net_conf), GFP_KERNEL);
4023-
if (!new_net_conf) {
4024-
drbd_err(device, "Allocation of new net_conf failed\n");
4021+
if (!new_net_conf)
40254022
goto disconnect;
4026-
}
40274023

40284024
*new_net_conf = *old_net_conf;
40294025

@@ -4161,7 +4157,6 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info
41614157

41624158
new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL);
41634159
if (!new_disk_conf) {
4164-
drbd_err(device, "Allocation of new disk_conf failed\n");
41654160
put_ldev(device);
41664161
return -ENOMEM;
41674162
}
@@ -4288,10 +4283,8 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info
42884283
device = peer_device->device;
42894284

42904285
p_uuid = kmalloc_array(UI_EXTENDED_SIZE, sizeof(*p_uuid), GFP_NOIO);
4291-
if (!p_uuid) {
4292-
drbd_err(device, "kmalloc of p_uuid failed\n");
4286+
if (!p_uuid)
42934287
return false;
4294-
}
42954288

42964289
for (i = UI_CURRENT; i < UI_EXTENDED_SIZE; i++)
42974290
p_uuid[i] = be64_to_cpu(p->uuid[i]);
@@ -5484,8 +5477,7 @@ static int drbd_do_auth(struct drbd_connection *connection)
54845477
}
54855478

54865479
peers_ch = kmalloc(pi.size, GFP_NOIO);
5487-
if (peers_ch == NULL) {
5488-
drbd_err(connection, "kmalloc of peers_ch failed\n");
5480+
if (!peers_ch) {
54895481
rv = -1;
54905482
goto fail;
54915483
}
@@ -5504,8 +5496,7 @@ static int drbd_do_auth(struct drbd_connection *connection)
55045496

55055497
resp_size = crypto_shash_digestsize(connection->cram_hmac_tfm);
55065498
response = kmalloc(resp_size, GFP_NOIO);
5507-
if (response == NULL) {
5508-
drbd_err(connection, "kmalloc of response failed\n");
5499+
if (!response) {
55095500
rv = -1;
55105501
goto fail;
55115502
}
@@ -5552,8 +5543,7 @@ static int drbd_do_auth(struct drbd_connection *connection)
55525543
}
55535544

55545545
right_response = kmalloc(resp_size, GFP_NOIO);
5555-
if (right_response == NULL) {
5556-
drbd_err(connection, "kmalloc of right_response failed\n");
5546+
if (!right_response) {
55575547
rv = -1;
55585548
goto fail;
55595549
}

drivers/block/floppy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,7 @@ static void format_interrupt(void)
21232123
switch (interpret_errors()) {
21242124
case 1:
21252125
cont->error();
2126+
break;
21262127
case 2:
21272128
break;
21282129
case 0:
@@ -2330,7 +2331,6 @@ static void rw_interrupt(void)
23302331
if (!drive_state[current_drive].first_read_date)
23312332
drive_state[current_drive].first_read_date = jiffies;
23322333

2333-
nr_sectors = 0;
23342334
ssize = DIV_ROUND_UP(1 << raw_cmd->cmd[SIZECODE], 4);
23352335

23362336
if (reply_buffer[ST1] & ST1_EOC)

drivers/block/loop.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
12341234
blk_queue_physical_block_size(lo->lo_queue, bsize);
12351235
blk_queue_io_min(lo->lo_queue, bsize);
12361236

1237+
loop_config_discard(lo);
12371238
loop_update_rotational(lo);
12381239
loop_update_dio(lo);
12391240
loop_sysfs_init(lo);

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,6 @@ static ssize_t show_device_status(struct device_driver *drv, char *buf)
22382238
static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
22392239
size_t len, loff_t *offset)
22402240
{
2241-
struct driver_data *dd = (struct driver_data *)f->private_data;
22422241
int size = *offset;
22432242
char *buf;
22442243
int rv = 0;
@@ -2247,11 +2246,8 @@ static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
22472246
return 0;
22482247

22492248
buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
2250-
if (!buf) {
2251-
dev_err(&dd->pdev->dev,
2252-
"Memory allocation: status buffer\n");
2249+
if (!buf)
22532250
return -ENOMEM;
2254-
}
22552251

22562252
size += show_device_status(NULL, buf);
22572253

@@ -2277,11 +2273,8 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
22772273
return 0;
22782274

22792275
buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
2280-
if (!buf) {
2281-
dev_err(&dd->pdev->dev,
2282-
"Memory allocation: register buffer\n");
2276+
if (!buf)
22832277
return -ENOMEM;
2284-
}
22852278

22862279
size += sprintf(&buf[size], "H/ S ACTive : [ 0x");
22872280

@@ -2343,11 +2336,8 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
23432336
return 0;
23442337

23452338
buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
2346-
if (!buf) {
2347-
dev_err(&dd->pdev->dev,
2348-
"Memory allocation: flag buffer\n");
2339+
if (!buf)
23492340
return -ENOMEM;
2350-
}
23512341

23522342
size += sprintf(&buf[size], "Flag-port : [ %08lX ]\n",
23532343
dd->port->flags);
@@ -2884,11 +2874,8 @@ static int mtip_hw_init(struct driver_data *dd)
28842874

28852875
dd->port = kzalloc_node(sizeof(struct mtip_port), GFP_KERNEL,
28862876
dd->numa_node);
2887-
if (!dd->port) {
2888-
dev_err(&dd->pdev->dev,
2889-
"Memory allocation: port structure\n");
2877+
if (!dd->port)
28902878
return -ENOMEM;
2891-
}
28922879

28932880
/* Continue workqueue setup */
28942881
for (i = 0; i < MTIP_MAX_SLOT_GROUPS; i++)
@@ -4002,11 +3989,8 @@ static int mtip_pci_probe(struct pci_dev *pdev,
40023989
cpu_to_node(raw_smp_processor_id()), raw_smp_processor_id());
40033990

40043991
dd = kzalloc_node(sizeof(struct driver_data), GFP_KERNEL, my_node);
4005-
if (dd == NULL) {
4006-
dev_err(&pdev->dev,
4007-
"Unable to allocate memory for driver data\n");
3992+
if (!dd)
40083993
return -ENOMEM;
4009-
}
40103994

40113995
/* Attach the private data to this PCI device. */
40123996
pci_set_drvdata(pdev, dd);

drivers/block/rsxx/dma.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ struct dma_tracker {
7474
struct rsxx_dma *dma;
7575
};
7676

77-
#define DMA_TRACKER_LIST_SIZE8 (sizeof(struct dma_tracker_list) + \
78-
(sizeof(struct dma_tracker) * RSXX_MAX_OUTSTANDING_CMDS))
79-
8077
struct dma_tracker_list {
8178
spinlock_t lock;
8279
int head;
@@ -808,7 +805,8 @@ static int rsxx_dma_ctrl_init(struct pci_dev *dev,
808805

809806
memset(&ctrl->stats, 0, sizeof(ctrl->stats));
810807

811-
ctrl->trackers = vmalloc(DMA_TRACKER_LIST_SIZE8);
808+
ctrl->trackers = vmalloc(struct_size(ctrl->trackers, list,
809+
RSXX_MAX_OUTSTANDING_CMDS));
812810
if (!ctrl->trackers)
813811
return -ENOMEM;
814812

0 commit comments

Comments
 (0)