Date: Sat, 4 Jun 2011 17:15:38 GMT From: Matt Jacob <mjacob@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 194216 for review Message-ID: <201106041715.p54HFcca035784@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@194216?ac=10 Change 194216 by mjacob@mjacob-sandbox on 2011/06/04 17:15:33 Refactor some stuff with config buffers to aid in forgetting to free. Affected files ... .. //depot/projects/mjacob-dev/sys/dev/mpt2sas/mpt2sas.h#6 edit Differences ... ==== //depot/projects/mjacob-dev/sys/dev/mpt2sas/mpt2sas.h#6 (text+ko) ==== @@ -678,9 +678,50 @@ mpt2sas_dma_chunk_t *linkage; MPI2_MPI_SGE_IO_UNION segs[0]; }; -/************************** Config/ATA data buffer management **************************/ + +/***************************** IOC Initialization *****************************/ +extern struct mpt2sas_tq mpt2sas_tailq; +int mpt2sas_reset(mpt2sas_t *); +void mpt2sas_send_port_enable(mpt2sas_t *); + +/**************************** CAM Routines ***************************/ +int mpt2sas_cam_attach(mpt2sas_t *); +void mpt2sas_cam_detach(mpt2sas_t *); +void mpt2sas_cam_done(mpt2sas_t *, request_t *, MPI2_SCSI_IO_REPLY *); +int mpt2sas_run_scsicmd(mpt2sas_t *, U16, U8 *, int, bus_addr_t, bus_size_t, boolean_t); +int mpt2sas_scsi_abort(mpt2sas_t *, request_t *); +int mpt2sas_cam_rescan(mpt2sas_t *); +void mpt2sas_cam_prt(mpt2sas_t *, struct cam_path *, int, const char *, ...) __printflike(4, 5); + + +/**************************** Unclassified Routines ***************************/ +void mpt2sas_send_cmd(mpt2sas_t *, request_t *); +int mpt2sas_wait_req(mpt2sas_t *, request_t *, req_state_t, req_state_t, int); +void mpt2sas_enable_ints(mpt2sas_t *); +void mpt2sas_disable_ints(mpt2sas_t *); +int mpt2sas_shutdown(mpt2sas_t *); +int mpt2sas_handshake_cmd(mpt2sas_t *, size_t, void *, size_t, void *); +request_t * mpt2sas_get_request(mpt2sas_t *); +void mpt2sas_free_request(mpt2sas_t *, request_t *); +void mpt2sas_intr(void *); +int mpt2sas_create_dev(mpt2sas_t *, U16); +void mpt2sas_build_ata_passthru(mpt2sas_t *, sas_dev_t *, U8 *, request_t *, bus_addr_t, uint32_t); +int mpt2sas_check_sata_passthru_failure(mpt2sas_t *, MPI2_SATA_PASSTHROUGH_REPLY *); +int mpt2sas_destroy_dev(mpt2sas_t *, U16); +void mpt2sas_destroy_dev_part2(sas_dev_t *); +void mpt2sas_prt(mpt2sas_t *, int, const char *, ...) __printflike(3, 4); +void mpt2sas_prt_cont(mpt2sas_t *, int, const char *, ...) __printflike(3, 4); +int mpt2sas_read_sep(mpt2sas_t *, sas_dev_t *); +int mpt2sas_write_sep(mpt2sas_t *, sas_dev_t *, U32); +int mpt2sas_attach(mpt2sas_t *); +int mpt2sas_detach(mpt2sas_t *); + +/************************** Inlines **************************/ static __inline int mpt2sas_get_cfgbuf(mpt2sas_t *, int *); static __inline void mpt2sas_free_cfgbuf(mpt2sas_t *, int); +static __inline sas_dev_t *mpt2_hdl2dev(mpt2sas_t *, uint16_t); +static __inline sas_dev_t * mpt2_tgt2dev(mpt2sas_t *, target_id_t); +static __inline target_id_t mpt2_dev2tgt(mpt2sas_t *, sas_dev_t *); static __inline int mpt2sas_get_cfgbuf(mpt2sas_t *mpt, int *off) @@ -690,6 +731,7 @@ if ((mpt->config_buf_mask & (1 << i)) == 0) { mpt->config_buf_mask |= (1 << i); *off = (i << 9); + mpt2sas_prt(mpt, MP2PRT_SPCL, "%s: alloc off %d (mask now 0x%08x)\n", __func__, i << 9, mpt->config_buf_mask); return (0); } } @@ -699,16 +741,19 @@ static __inline void mpt2sas_free_cfgbuf(mpt2sas_t *mpt, int off) { - if (off >= 0 && off < PAGE_SIZE) { - mpt->config_buf_mask &= ~(1 << (off >> 9)); + if (off >= 0 && off < PAGE_SIZE && (off & ((1 << 9) - 1)) == 0) { + int mask = 1 << (off >> 9); + if (mpt->config_buf_mask & mask) { + mpt->config_buf_mask ^= mask; + mpt2sas_prt(mpt, MP2PRT_SPCL, "%s: free off %d (mask now 0x%08x)\n", __func__, off, mpt->config_buf_mask); + } else { + mpt2sas_prt(mpt, MP2PRT_ERR, "%s: free off %d twice! (mask is 0x%08x)\n", __func__, off, mpt->config_buf_mask); + } + } else { + mpt2sas_prt(mpt, MP2PRT_ERR, "%s: bad off %d (mask is 0x%08x)\n", __func__, off, mpt->config_buf_mask); } } -/************************** Other Inlines **************************/ -static __inline sas_dev_t *mpt2_hdl2dev(mpt2sas_t *, uint16_t); -static __inline sas_dev_t * mpt2_tgt2dev(mpt2sas_t *, target_id_t); -static __inline target_id_t mpt2_dev2tgt(mpt2sas_t *, sas_dev_t *); - static __inline sas_dev_t * mpt2_hdl2dev(mpt2sas_t *mpt, U16 hdl) { @@ -743,40 +788,4 @@ return dp - mpt->sas_dev_pool; } -/***************************** IOC Initialization *****************************/ -extern struct mpt2sas_tq mpt2sas_tailq; -int mpt2sas_reset(mpt2sas_t *); -void mpt2sas_send_port_enable(mpt2sas_t *); - -/**************************** CAM Routines ***************************/ -int mpt2sas_cam_attach(mpt2sas_t *); -void mpt2sas_cam_detach(mpt2sas_t *); -void mpt2sas_cam_done(mpt2sas_t *, request_t *, MPI2_SCSI_IO_REPLY *); -int mpt2sas_run_scsicmd(mpt2sas_t *, U16, U8 *, int, bus_addr_t, bus_size_t, boolean_t); -int mpt2sas_scsi_abort(mpt2sas_t *, request_t *); -int mpt2sas_cam_rescan(mpt2sas_t *); -void mpt2sas_cam_prt(mpt2sas_t *, struct cam_path *, int, const char *, ...) __printflike(4, 5); - - -/**************************** Unclassified Routines ***************************/ -void mpt2sas_send_cmd(mpt2sas_t *, request_t *); -int mpt2sas_wait_req(mpt2sas_t *, request_t *, req_state_t, req_state_t, int); -void mpt2sas_enable_ints(mpt2sas_t *); -void mpt2sas_disable_ints(mpt2sas_t *); -int mpt2sas_shutdown(mpt2sas_t *); -int mpt2sas_handshake_cmd(mpt2sas_t *, size_t, void *, size_t, void *); -request_t * mpt2sas_get_request(mpt2sas_t *); -void mpt2sas_free_request(mpt2sas_t *, request_t *); -void mpt2sas_intr(void *); -int mpt2sas_create_dev(mpt2sas_t *, U16); -void mpt2sas_build_ata_passthru(mpt2sas_t *, sas_dev_t *, U8 *, request_t *, bus_addr_t, uint32_t); -int mpt2sas_check_sata_passthru_failure(mpt2sas_t *, MPI2_SATA_PASSTHROUGH_REPLY *); -int mpt2sas_destroy_dev(mpt2sas_t *, U16); -void mpt2sas_destroy_dev_part2(sas_dev_t *); -void mpt2sas_prt(mpt2sas_t *, int, const char *, ...) __printflike(3, 4); -void mpt2sas_prt_cont(mpt2sas_t *, int, const char *, ...) __printflike(3, 4); -int mpt2sas_read_sep(mpt2sas_t *, sas_dev_t *); -int mpt2sas_write_sep(mpt2sas_t *, sas_dev_t *, U32); -int mpt2sas_attach(mpt2sas_t *); -int mpt2sas_detach(mpt2sas_t *); #endif /* _MPT2_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106041715.p54HFcca035784>
