Skip to content

Commit f41e546

Browse files
howlettdavem330
authored andcommitted
sunvdc: Add support for setting physical sector size
Physical sector size is supported in v1.2 of the vDisk protocol and should be set if available. If protocol version 1.2 is used and the physical disk size is unavailable, then the disk is considered busy. Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 269d852 commit f41e546

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

drivers/block/sunvdc.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ MODULE_LICENSE("GPL");
3434
MODULE_VERSION(DRV_MODULE_VERSION);
3535

3636
#define VDC_TX_RING_SIZE 512
37+
#define VDC_DEFAULT_BLK_SIZE 512
3738

3839
#define WAITING_FOR_LINK_UP 0x01
3940
#define WAITING_FOR_TX_SPACE 0x02
@@ -73,6 +74,7 @@ struct vdc_port {
7374
u32 vdisk_size;
7475
u8 vdisk_type;
7576
u8 vdisk_mtype;
77+
u32 vdisk_phys_blksz;
7678

7779
char disk_name[32];
7880
};
@@ -88,6 +90,7 @@ static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio)
8890

8991
/* Ordered from largest major to lowest */
9092
static struct vio_version vdc_versions[] = {
93+
{ .major = 1, .minor = 2 },
9194
{ .major = 1, .minor = 1 },
9295
{ .major = 1, .minor = 0 },
9396
};
@@ -271,6 +274,11 @@ static int vdc_handle_attr(struct vio_driver_state *vio, void *arg)
271274
if (pkt->max_xfer_size < port->max_xfer_size)
272275
port->max_xfer_size = pkt->max_xfer_size;
273276
port->vdisk_block_size = pkt->vdisk_block_size;
277+
278+
port->vdisk_phys_blksz = VDC_DEFAULT_BLK_SIZE;
279+
if (vdc_version_supported(port, 1, 2))
280+
port->vdisk_phys_blksz = pkt->phys_block_size;
281+
274282
return 0;
275283
} else {
276284
printk(KERN_ERR PFX "%s: Attribute NACK\n", vio->name);
@@ -754,6 +762,12 @@ static int probe_disk(struct vdc_port *port)
754762
if (err)
755763
return err;
756764

765+
/* Using version 1.2 means vdisk_phys_blksz should be set unless the
766+
* disk is reserved by another system.
767+
*/
768+
if (vdc_version_supported(port, 1, 2) && !port->vdisk_phys_blksz)
769+
return -ENODEV;
770+
757771
if (vdc_version_supported(port, 1, 1)) {
758772
/* vdisk_size should be set during the handshake, if it wasn't
759773
* then the underlying disk is reserved by another system
@@ -829,6 +843,8 @@ static int probe_disk(struct vdc_port *port)
829843
}
830844
}
831845

846+
blk_queue_physical_block_size(q, port->vdisk_phys_blksz);
847+
832848
pr_info(PFX "%s: %u sectors (%u MB) protocol %d.%d\n",
833849
g->disk_name,
834850
port->vdisk_size, (port->vdisk_size >> (20 - 9)),
@@ -910,7 +926,7 @@ static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)
910926
if (err)
911927
goto err_out_free_port;
912928

913-
port->vdisk_block_size = 512;
929+
port->vdisk_block_size = VDC_DEFAULT_BLK_SIZE;
914930
port->max_xfer_size = ((128 * 1024) / port->vdisk_block_size);
915931
port->ring_cookies = ((port->max_xfer_size *
916932
port->vdisk_block_size) / PAGE_SIZE) + 2;

0 commit comments

Comments
 (0)