Skip to content

Commit

Permalink
Merge branch '6.10/scsi-fixes' into 6.11/scsi-staging
Browse files Browse the repository at this point in the history
Pull in my fixes branch to resolve an mpi3mr merge conflict reported
by sfr.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Martin K. Petersen committed Jul 11, 2024
2 parents 6cd48c8 + 7a6bbc2 commit 5e9a522
Show file tree
Hide file tree
Showing 24 changed files with 273 additions and 75 deletions.
4 changes: 2 additions & 2 deletions Documentation/cdrom/cdrom-standard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ current *struct* is::
int (*media_changed)(struct cdrom_device_info *, int);
int (*tray_move)(struct cdrom_device_info *, int);
int (*lock_door)(struct cdrom_device_info *, int);
int (*select_speed)(struct cdrom_device_info *, int);
int (*select_speed)(struct cdrom_device_info *, unsigned long);
int (*get_last_session) (struct cdrom_device_info *,
struct cdrom_multisession *);
int (*get_mcn)(struct cdrom_device_info *, struct cdrom_mcn *);
Expand Down Expand Up @@ -396,7 +396,7 @@ action need be taken, and the return value should be 0.

::

int select_speed(struct cdrom_device_info *cdi, int speed)
int select_speed(struct cdrom_device_info *cdi, unsigned long speed)

Some CD-ROM drives are capable of changing their head-speed. There
are several reasons for changing the speed of a CD-ROM drive. Badly
Expand Down
31 changes: 22 additions & 9 deletions drivers/scsi/device_handler/scsi_dh_alua.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,28 +414,40 @@ static char print_alua_state(unsigned char state)
}
}

static enum scsi_disposition alua_check_sense(struct scsi_device *sdev,
struct scsi_sense_hdr *sense_hdr)
static void alua_handle_state_transition(struct scsi_device *sdev)
{
struct alua_dh_data *h = sdev->handler_data;
struct alua_port_group *pg;

rcu_read_lock();
pg = rcu_dereference(h->pg);
if (pg)
pg->state = SCSI_ACCESS_STATE_TRANSITIONING;
rcu_read_unlock();
alua_check(sdev, false);
}

static enum scsi_disposition alua_check_sense(struct scsi_device *sdev,
struct scsi_sense_hdr *sense_hdr)
{
switch (sense_hdr->sense_key) {
case NOT_READY:
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0a) {
/*
* LUN Not Accessible - ALUA state transition
*/
rcu_read_lock();
pg = rcu_dereference(h->pg);
if (pg)
pg->state = SCSI_ACCESS_STATE_TRANSITIONING;
rcu_read_unlock();
alua_check(sdev, false);
alua_handle_state_transition(sdev);
return NEEDS_RETRY;
}
break;
case UNIT_ATTENTION:
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0a) {
/*
* LUN Not Accessible - ALUA state transition
*/
alua_handle_state_transition(sdev);
return NEEDS_RETRY;
}
if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00) {
/*
* Power On, Reset, or Bus Device Reset.
Expand Down Expand Up @@ -502,7 +514,8 @@ static int alua_tur(struct scsi_device *sdev)

retval = scsi_test_unit_ready(sdev, ALUA_FAILOVER_TIMEOUT * HZ,
ALUA_FAILOVER_RETRIES, &sense_hdr);
if (sense_hdr.sense_key == NOT_READY &&
if ((sense_hdr.sense_key == NOT_READY ||
sense_hdr.sense_key == UNIT_ATTENTION) &&
sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a)
return SCSI_DH_RETRY;
else if (retval)
Expand Down
14 changes: 14 additions & 0 deletions drivers/scsi/libsas/sas_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ static inline void sas_fail_probe(struct domain_device *dev, const char *func, i
func, dev->parent ? "exp-attached" :
"direct-attached",
SAS_ADDR(dev->sas_addr), err);

/*
* If the device probe failed, the expander phy attached address
* needs to be reset so that the phy will not be treated as flutter
* in the next revalidation
*/
if (dev->parent && !dev_is_expander(dev->dev_type)) {
struct sas_phy *phy = dev->phy;
struct domain_device *parent = dev->parent;
struct ex_phy *ex_phy = &parent->ex_dev.ex_phy[phy->number];

memset(ex_phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
}

sas_unregister_dev(dev->port, dev);
}

Expand Down
62 changes: 62 additions & 0 deletions drivers/scsi/mpi3mr/mpi3mr_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -3247,10 +3247,72 @@ persistent_id_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(persistent_id);

/**
* sas_ncq_prio_supported_show - Indicate if device supports NCQ priority
* @dev: pointer to embedded device
* @attr: sas_ncq_prio_supported attribute descriptor
* @buf: the buffer returned
*
* A sysfs 'read-only' sdev attribute, only works with SATA devices
*/
static ssize_t
sas_ncq_prio_supported_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);

return sysfs_emit(buf, "%d\n", sas_ata_ncq_prio_supported(sdev));
}
static DEVICE_ATTR_RO(sas_ncq_prio_supported);

/**
* sas_ncq_prio_enable_show - send prioritized io commands to device
* @dev: pointer to embedded device
* @attr: sas_ncq_prio_enable attribute descriptor
* @buf: the buffer returned
*
* A sysfs 'read/write' sdev attribute, only works with SATA devices
*/
static ssize_t
sas_ncq_prio_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
struct mpi3mr_sdev_priv_data *sdev_priv_data = sdev->hostdata;

if (!sdev_priv_data)
return 0;

return sysfs_emit(buf, "%d\n", sdev_priv_data->ncq_prio_enable);
}

static ssize_t
sas_ncq_prio_enable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct scsi_device *sdev = to_scsi_device(dev);
struct mpi3mr_sdev_priv_data *sdev_priv_data = sdev->hostdata;
bool ncq_prio_enable = 0;

if (kstrtobool(buf, &ncq_prio_enable))
return -EINVAL;

if (!sas_ata_ncq_prio_supported(sdev))
return -EINVAL;

sdev_priv_data->ncq_prio_enable = ncq_prio_enable;

return strlen(buf);
}
static DEVICE_ATTR_RW(sas_ncq_prio_enable);

static struct attribute *mpi3mr_dev_attrs[] = {
&dev_attr_sas_address.attr,
&dev_attr_device_handle.attr,
&dev_attr_persistent_id.attr,
&dev_attr_sas_ncq_prio_supported.attr,
&dev_attr_sas_ncq_prio_enable.attr,
NULL,
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/mpi3mr/mpi3mr_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,
continue;

if (i >= sizeof(mr_sas_port->phy_mask) * 8) {
ioc_warn(mrioc, "skipping port %u, max allowed value is %lu\n",
ioc_warn(mrioc, "skipping port %u, max allowed value is %zu\n",
i, sizeof(mr_sas_port->phy_mask) * 8);
goto out_fail;
}
Expand Down
19 changes: 19 additions & 0 deletions drivers/scsi/mpt3sas/mpt3sas_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -8512,6 +8512,12 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
ioc->pd_handles_sz = (ioc->facts.MaxDevHandle / 8);
if (ioc->facts.MaxDevHandle % 8)
ioc->pd_handles_sz++;
/*
* pd_handles_sz should have, at least, the minimal room for
* set_bit()/test_bit(), otherwise out-of-memory touch may occur.
*/
ioc->pd_handles_sz = ALIGN(ioc->pd_handles_sz, sizeof(unsigned long));

ioc->pd_handles = kzalloc(ioc->pd_handles_sz,
GFP_KERNEL);
if (!ioc->pd_handles) {
Expand All @@ -8529,6 +8535,13 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
ioc->pend_os_device_add_sz = (ioc->facts.MaxDevHandle / 8);
if (ioc->facts.MaxDevHandle % 8)
ioc->pend_os_device_add_sz++;

/*
* pend_os_device_add_sz should have, at least, the minimal room for
* set_bit()/test_bit(), otherwise out-of-memory may occur.
*/
ioc->pend_os_device_add_sz = ALIGN(ioc->pend_os_device_add_sz,
sizeof(unsigned long));
ioc->pend_os_device_add = kzalloc(ioc->pend_os_device_add_sz,
GFP_KERNEL);
if (!ioc->pend_os_device_add) {
Expand Down Expand Up @@ -8820,6 +8833,12 @@ _base_check_ioc_facts_changes(struct MPT3SAS_ADAPTER *ioc)
if (ioc->facts.MaxDevHandle % 8)
pd_handles_sz++;

/*
* pd_handles should have, at least, the minimal room for
* set_bit()/test_bit(), otherwise out-of-memory touch may
* occur.
*/
pd_handles_sz = ALIGN(pd_handles_sz, sizeof(unsigned long));
pd_handles = krealloc(ioc->pd_handles, pd_handles_sz,
GFP_KERNEL);
if (!pd_handles) {
Expand Down
3 changes: 0 additions & 3 deletions drivers/scsi/mpt3sas/mpt3sas_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2048,9 +2048,6 @@ void
mpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
struct _raid_device *raid_device, Mpi25SCSIIORequest_t *mpi_request);

/* NCQ Prio Handling Check */
bool scsih_ncq_prio_supp(struct scsi_device *sdev);

void mpt3sas_setup_debugfs(struct MPT3SAS_ADAPTER *ioc);
void mpt3sas_destroy_debugfs(struct MPT3SAS_ADAPTER *ioc);
void mpt3sas_init_debugfs(void);
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/mpt3sas/mpt3sas_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4088,7 +4088,7 @@ sas_ncq_prio_supported_show(struct device *dev,
{
struct scsi_device *sdev = to_scsi_device(dev);

return sysfs_emit(buf, "%d\n", scsih_ncq_prio_supp(sdev));
return sysfs_emit(buf, "%d\n", sas_ata_ncq_prio_supported(sdev));
}
static DEVICE_ATTR_RO(sas_ncq_prio_supported);

Expand Down Expand Up @@ -4123,7 +4123,7 @@ sas_ncq_prio_enable_store(struct device *dev,
if (kstrtobool(buf, &ncq_prio_enable))
return -EINVAL;

if (!scsih_ncq_prio_supp(sdev))
if (!sas_ata_ncq_prio_supported(sdev))
return -EINVAL;

sas_device_priv_data->ncq_prio_enable = ncq_prio_enable;
Expand Down
27 changes: 2 additions & 25 deletions drivers/scsi/mpt3sas/mpt3sas_scsih.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ struct _scsi_io_transfer {

/**
* _scsih_set_debug_level - global setting of ioc->logging_level.
* @val: ?
* @kp: ?
* @val: value of the parameter to be set
* @kp: pointer to kernel_param structure
*
* Note: The logging levels are defined in mpt3sas_debug.h.
*/
Expand Down Expand Up @@ -12571,29 +12571,6 @@ scsih_pci_mmio_enabled(struct pci_dev *pdev)
return PCI_ERS_RESULT_RECOVERED;
}

/**
* scsih_ncq_prio_supp - Check for NCQ command priority support
* @sdev: scsi device struct
*
* This is called when a user indicates they would like to enable
* ncq command priorities. This works only on SATA devices.
*/
bool scsih_ncq_prio_supp(struct scsi_device *sdev)
{
struct scsi_vpd *vpd;
bool ncq_prio_supp = false;

rcu_read_lock();
vpd = rcu_dereference(sdev->vpd_pg89);
if (!vpd || vpd->len < 214)
goto out;

ncq_prio_supp = (vpd->data[213] >> 4) & 1;
out:
rcu_read_unlock();

return ncq_prio_supp;
}
/*
* The pci device ids are defined in mpi/mpi2_cnfg.h.
*/
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/qedf/qedf.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ struct qedf_ctx {
#define QEDF_IN_RECOVERY 5
#define QEDF_DBG_STOP_IO 6
#define QEDF_PROBING 8
#define QEDF_STAG_IN_PROGRESS 9
unsigned long flags; /* Miscellaneous state flags */
int fipvlan_retries;
u8 num_queues;
Expand Down
Loading

0 comments on commit 5e9a522

Please sign in to comment.