Skip to content

Commit

Permalink
scsi: libsas and users: Remove notifier indirection
Browse files Browse the repository at this point in the history
LLDDs report events to libsas with .notify_port_event and
.notify_phy_event callbacks.

These callbacks are fixed and so there is no reason why the functions
cannot be called directly, so do that.

This neatens the code slightly, makes it more obvious, and reduces
function pointer usage, which is generally a good thing. Downside is that
there are 2x more symbol exports.

Signed-off-by: John Garry <john.garry@huawei.com>
  • Loading branch information
John Garry authored and intel-lab-lkp committed Jan 11, 2021
1 parent 91b1b64 commit 86837fd
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 103 deletions.
8 changes: 2 additions & 6 deletions Documentation/scsi/libsas.rst
Expand Up @@ -190,12 +190,8 @@ The event interface::

/* LLDD calls these to notify the class of an event. */
void (*notify_ha_event)(struct sas_ha_struct *, enum ha_event);
void (*notify_port_event)(struct sas_phy *, enum port_event);
void (*notify_phy_event)(struct sas_phy *, enum phy_event);

When sas_register_ha() returns, those are set and can be
called by the LLDD to notify the SAS layer of such events
the SAS layer.
void sas_notify_port_event(struct sas_phy *, enum port_event);
void sas_notify_phy_event(struct sas_phy *, enum phy_event);

The port notification::

Expand Down
20 changes: 9 additions & 11 deletions drivers/scsi/aic94xx/aic94xx_scb.c
Expand Up @@ -68,7 +68,6 @@ static void asd_phy_event_tasklet(struct asd_ascb *ascb,
struct done_list_struct *dl)
{
struct asd_ha_struct *asd_ha = ascb->ha;
struct sas_ha_struct *sas_ha = &asd_ha->sas_ha;
int phy_id = dl->status_block[0] & DL_PHY_MASK;
struct asd_phy *phy = &asd_ha->phys[phy_id];

Expand All @@ -81,28 +80,28 @@ static void asd_phy_event_tasklet(struct asd_ascb *ascb,
ASD_DPRINTK("phy%d: device unplugged\n", phy_id);
asd_turn_led(asd_ha, phy_id, 0);
sas_phy_disconnected(&phy->sas_phy);
sas_ha->notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL);
sas_notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL);
break;
case CURRENT_OOB_DONE:
/* hot plugged device */
asd_turn_led(asd_ha, phy_id, 1);
get_lrate_mode(phy, oob_mode);
ASD_DPRINTK("phy%d device plugged: lrate:0x%x, proto:0x%x\n",
phy_id, phy->sas_phy.linkrate, phy->sas_phy.iproto);
sas_ha->notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE);
sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE);
break;
case CURRENT_SPINUP_HOLD:
/* hot plug SATA, no COMWAKE sent */
asd_turn_led(asd_ha, phy_id, 1);
sas_ha->notify_phy_event(&phy->sas_phy, PHYE_SPINUP_HOLD);
sas_notify_phy_event(&phy->sas_phy, PHYE_SPINUP_HOLD);
break;
case CURRENT_GTO_TIMEOUT:
case CURRENT_OOB_ERROR:
ASD_DPRINTK("phy%d error while OOB: oob status:0x%x\n", phy_id,
dl->status_block[1]);
asd_turn_led(asd_ha, phy_id, 0);
sas_phy_disconnected(&phy->sas_phy);
sas_ha->notify_phy_event(&phy->sas_phy, PHYE_OOB_ERROR);
sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_ERROR);
break;
}
}
Expand Down Expand Up @@ -222,7 +221,6 @@ static void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
int edb_el = edb_id + ascb->edb_index;
struct asd_dma_tok *edb = ascb->ha->seq.edb_arr[edb_el];
struct asd_phy *phy = &ascb->ha->phys[phy_id];
struct sas_ha_struct *sas_ha = phy->sas_phy.ha;
u16 size = ((dl->status_block[3] & 7) << 8) | dl->status_block[2];

size = min(size, (u16) sizeof(phy->frame_rcvd));
Expand All @@ -234,7 +232,7 @@ static void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags);
asd_dump_frame_rcvd(phy, dl);
asd_form_port(ascb->ha, phy);
sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED);
sas_notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED);
}

static void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
Expand Down Expand Up @@ -270,7 +268,7 @@ static void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
asd_turn_led(asd_ha, phy_id, 0);
sas_phy_disconnected(sas_phy);
asd_deform_port(asd_ha, phy);
sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR);
sas_notify_port_event(sas_phy, PORTE_LINK_RESET_ERR);

if (retries_left == 0) {
int num = 1;
Expand Down Expand Up @@ -315,7 +313,7 @@ static void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
spin_lock_irqsave(&sas_phy->sas_prim_lock, flags);
sas_phy->sas_prim = ffs(cont);
spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags);
sas_ha->notify_port_event(sas_phy,PORTE_BROADCAST_RCVD);
sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
break;

case LmUNKNOWNP:
Expand All @@ -336,7 +334,7 @@ static void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
/* The sequencer disables all phys on that port.
* We have to re-enable the phys ourselves. */
asd_deform_port(asd_ha, phy);
sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET);
sas_notify_port_event(sas_phy, PORTE_HARD_RESET);
break;

default:
Expand Down Expand Up @@ -567,7 +565,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
/* the device is gone */
sas_phy_disconnected(sas_phy);
asd_deform_port(asd_ha, phy);
sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT);
sas_notify_port_event(sas_phy, PORTE_TIMER_EVENT);
break;
default:
ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __func__,
Expand Down
10 changes: 4 additions & 6 deletions drivers/scsi/hisi_sas/hisi_sas_main.c
Expand Up @@ -628,7 +628,7 @@ static void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int phy_no)
}

sas_ha = &hisi_hba->sha;
sas_ha->notify_phy_event(sas_phy, PHYE_OOB_DONE);
sas_notify_phy_event(sas_phy, PHYE_OOB_DONE);

if (sas_phy->phy) {
struct sas_phy *sphy = sas_phy->phy;
Expand Down Expand Up @@ -656,7 +656,7 @@ static void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int phy_no)
}

sas_phy->frame_rcvd_size = phy->frame_rcvd_size;
sas_ha->notify_port_event(sas_phy, PORTE_BYTES_DMAED);
sas_notify_port_event(sas_phy, PORTE_BYTES_DMAED);
}

static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device)
Expand Down Expand Up @@ -1411,7 +1411,6 @@ static void hisi_sas_refresh_port_id(struct hisi_hba *hisi_hba)

static void hisi_sas_rescan_topology(struct hisi_hba *hisi_hba, u32 state)
{
struct sas_ha_struct *sas_ha = &hisi_hba->sha;
struct asd_sas_port *_sas_port = NULL;
int phy_no;

Expand All @@ -1432,7 +1431,7 @@ static void hisi_sas_rescan_topology(struct hisi_hba *hisi_hba, u32 state)
_sas_port = sas_port;

if (dev_is_expander(dev->dev_type))
sas_ha->notify_port_event(sas_phy,
sas_notify_port_event(sas_phy,
PORTE_BROADCAST_RCVD);
}
} else {
Expand Down Expand Up @@ -2194,7 +2193,6 @@ void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy)
{
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
struct asd_sas_phy *sas_phy = &phy->sas_phy;
struct sas_ha_struct *sas_ha = &hisi_hba->sha;
struct device *dev = hisi_hba->dev;

if (rdy) {
Expand All @@ -2210,7 +2208,7 @@ void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy)
return;
}
/* Phy down and not ready */
sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL);
sas_notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL);
sas_phy_disconnected(sas_phy);

if (port) {
Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
Expand Up @@ -1408,7 +1408,6 @@ static irqreturn_t int_bcast_v1_hw(int irq, void *p)
struct hisi_sas_phy *phy = p;
struct hisi_hba *hisi_hba = phy->hisi_hba;
struct asd_sas_phy *sas_phy = &phy->sas_phy;
struct sas_ha_struct *sha = &hisi_hba->sha;
struct device *dev = hisi_hba->dev;
int phy_no = sas_phy->id;
u32 irq_value;
Expand All @@ -1424,7 +1423,7 @@ static irqreturn_t int_bcast_v1_hw(int irq, void *p)
}

if (!test_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags))
sha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);

end:
hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2,
Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
Expand Up @@ -2818,14 +2818,13 @@ static void phy_bcast_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
{
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
struct asd_sas_phy *sas_phy = &phy->sas_phy;
struct sas_ha_struct *sas_ha = &hisi_hba->sha;
u32 bcast_status;

hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 1);
bcast_status = hisi_sas_phy_read32(hisi_hba, phy_no, RX_PRIMS_STATUS);
if ((bcast_status & RX_BCAST_CHG_MSK) &&
!test_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags))
sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0,
CHL_INT0_SL_RX_BCST_ACK_MSK);
hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 0);
Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
Expand Up @@ -1595,14 +1595,13 @@ static irqreturn_t phy_bcast_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
{
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
struct asd_sas_phy *sas_phy = &phy->sas_phy;
struct sas_ha_struct *sas_ha = &hisi_hba->sha;
u32 bcast_status;

hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 1);
bcast_status = hisi_sas_phy_read32(hisi_hba, phy_no, RX_PRIMS_STATUS);
if ((bcast_status & RX_BCAST_CHG_MSK) &&
!test_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags))
sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0,
CHL_INT0_SL_RX_BCST_ACK_MSK);
hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 0);
Expand Down
7 changes: 3 additions & 4 deletions drivers/scsi/isci/port.c
Expand Up @@ -164,7 +164,7 @@ static void isci_port_bc_change_received(struct isci_host *ihost,
"%s: isci_phy = %p, sas_phy = %p\n",
__func__, iphy, &iphy->sas_phy);

ihost->sas_ha.notify_port_event(&iphy->sas_phy, PORTE_BROADCAST_RCVD);
sas_notify_port_event(&iphy->sas_phy, PORTE_BROADCAST_RCVD);
sci_port_bcn_enable(iport);
}

Expand Down Expand Up @@ -223,8 +223,7 @@ static void isci_port_link_up(struct isci_host *isci_host,
/* Notify libsas that we have an address frame, if indeed
* we've found an SSP, SMP, or STP target */
if (success)
isci_host->sas_ha.notify_port_event(&iphy->sas_phy,
PORTE_BYTES_DMAED);
sas_notify_port_event(&iphy->sas_phy, PORTE_BYTES_DMAED);
}


Expand Down Expand Up @@ -270,7 +269,7 @@ static void isci_port_link_down(struct isci_host *isci_host,
* isci_port_deformed and isci_dev_gone functions.
*/
sas_phy_disconnected(&isci_phy->sas_phy);
isci_host->sas_ha.notify_phy_event(&isci_phy->sas_phy,
sas_notify_phy_event(&isci_phy->sas_phy,
PHYE_LOSS_OF_SIGNAL);

dev_dbg(&isci_host->pdev->dev,
Expand Down
13 changes: 4 additions & 9 deletions drivers/scsi/libsas/sas_event.c
Expand Up @@ -109,7 +109,7 @@ void sas_enable_revalidation(struct sas_ha_struct *ha)

sas_phy = container_of(port->phy_list.next, struct asd_sas_phy,
port_phy_el);
ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
}
mutex_unlock(&ha->disco_mutex);
}
Expand All @@ -131,7 +131,7 @@ static void sas_phy_event_worker(struct work_struct *work)
sas_free_event(ev);
}

static int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event)
int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event)
{
struct asd_sas_event *ev;
struct sas_ha_struct *ha = phy->ha;
Expand All @@ -151,6 +151,7 @@ static int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event)

return ret;
}
EXPORT_SYMBOL_GPL(sas_notify_port_event);

int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
{
Expand All @@ -172,11 +173,5 @@ int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)

return ret;
}
EXPORT_SYMBOL_GPL(sas_notify_phy_event);

int sas_init_events(struct sas_ha_struct *sas_ha)
{
sas_ha->notify_port_event = sas_notify_port_event;
sas_ha->notify_phy_event = sas_notify_phy_event;

return 0;
}
6 changes: 0 additions & 6 deletions drivers/scsi/libsas/sas_init.c
Expand Up @@ -123,12 +123,6 @@ int sas_register_ha(struct sas_ha_struct *sas_ha)
goto Undo_phys;
}

error = sas_init_events(sas_ha);
if (error) {
pr_notice("couldn't start event thread:%d\n", error);
goto Undo_ports;
}

error = -ENOMEM;
snprintf(name, sizeof(name), "%s_event_q", dev_name(sas_ha->dev));
sas_ha->event_q = create_singlethread_workqueue(name);
Expand Down
1 change: 0 additions & 1 deletion drivers/scsi/libsas/sas_internal.h
Expand Up @@ -54,7 +54,6 @@ void sas_free_event(struct asd_sas_event *event);
int sas_register_ports(struct sas_ha_struct *sas_ha);
void sas_unregister_ports(struct sas_ha_struct *sas_ha);

int sas_init_events(struct sas_ha_struct *sas_ha);
void sas_disable_revalidation(struct sas_ha_struct *ha);
void sas_enable_revalidation(struct sas_ha_struct *ha);
void __sas_drain_work(struct sas_ha_struct *ha);
Expand Down
11 changes: 4 additions & 7 deletions drivers/scsi/mvsas/mv_sas.c
Expand Up @@ -230,7 +230,7 @@ static void mvs_bytes_dmaed(struct mvs_info *mvi, int i)
}

sas_ha = mvi->sas;
sas_ha->notify_phy_event(sas_phy, PHYE_OOB_DONE);
sas_notify_phy_event(sas_phy, PHYE_OOB_DONE);

if (sas_phy->phy) {
struct sas_phy *sphy = sas_phy->phy;
Expand Down Expand Up @@ -262,8 +262,7 @@ static void mvs_bytes_dmaed(struct mvs_info *mvi, int i)

sas_phy->frame_rcvd_size = phy->frame_rcvd_size;

mvi->sas->notify_port_event(sas_phy,
PORTE_BYTES_DMAED);
sas_notify_port_event(sas_phy, PORTE_BYTES_DMAED);
}

void mvs_scan_start(struct Scsi_Host *shost)
Expand Down Expand Up @@ -1880,7 +1879,6 @@ static void mvs_work_queue(struct work_struct *work)
struct mvs_info *mvi = mwq->mvi;
unsigned long flags;
u32 phy_no = (unsigned long) mwq->data;
struct sas_ha_struct *sas_ha = mvi->sas;
struct mvs_phy *phy = &mvi->phy[phy_no];
struct asd_sas_phy *sas_phy = &phy->sas_phy;

Expand All @@ -1895,7 +1893,7 @@ static void mvs_work_queue(struct work_struct *work)
if (!(tmp & PHY_READY_MASK)) {
sas_phy_disconnected(sas_phy);
mvs_phy_disconnected(phy);
sas_ha->notify_phy_event(sas_phy,
sas_notify_phy_event(sas_phy,
PHYE_LOSS_OF_SIGNAL);
mv_dprintk("phy%d Removed Device\n", phy_no);
} else {
Expand All @@ -1908,8 +1906,7 @@ static void mvs_work_queue(struct work_struct *work)
}
} else if (mwq->handler & EXP_BRCT_CHG) {
phy->phy_event &= ~EXP_BRCT_CHG;
sas_ha->notify_port_event(sas_phy,
PORTE_BROADCAST_RCVD);
sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
mv_dprintk("phy%d Got Broadcast Change\n", phy_no);
}
list_del(&mwq->entry);
Expand Down

0 comments on commit 86837fd

Please sign in to comment.