From: ppisa Date: Mon, 6 Jun 2005 23:43:00 +0000 (+0200) Subject: Merge: More updates in the C_CAN support, but locking not reworked still. X-Git-Tag: CLT_COMM_CAN_usb_can1_kriz_bp~55 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/commitdiff_plain/23de740dc1fe197cc326b0e3ef6c3622a0e3cb7f?hp=e76c475d24baf228af7d068c03c0f4634d45db3e Merge: More updates in the C_CAN support, but locking not reworked still. Merge commit 'remotes/sf-ocera-lincan/master' --- diff --git a/lincan/include/c_can.h b/lincan/include/c_can.h index b68bea0..f5d9d10 100644 --- a/lincan/include/c_can.h +++ b/lincan/include/c_can.h @@ -70,7 +70,7 @@ void c_can_registerdump(struct canchip_t *pchip); void c_can_if1_registerdump(struct canchip_t *pchip); -void c_can_irq_sync_activities(struct canchip_t *pchip, struct msgobj_t *obj); +void c_can_irq_sync_activities(struct canchip_t *chip, struct msgobj_t *obj); int c_can_irq_handler(int irq, struct canchip_t *pchip); diff --git a/lincan/src/c_can.c b/lincan/src/c_can.c index beb26d0..ed3991c 100644 --- a/lincan/src/c_can.c +++ b/lincan/src/c_can.c @@ -810,7 +810,7 @@ int c_can_wakeup_tx(struct canchip_t *chip, struct msgobj_t *obj) can_msgobj_set_fl(obj, TX_REQUEST); - /* calls i82527_irq_write_handler synchronized with other invocations + /* calls c_can_irq_write_handler synchronized with other invocations from kernel and IRQ context */ c_can_irq_sync_activities(chip, obj); diff --git a/lincan/src/c_can_irq.c b/lincan/src/c_can_irq.c index b689032..4ba6042 100644 --- a/lincan/src/c_can_irq.c +++ b/lincan/src/c_can_irq.c @@ -184,23 +184,72 @@ inline void c_can_irq_read_handler(struct canchip_t *pchip, // while } -void c_can_irq_sync_activities(struct canchip_t *chip, struct msgobj_t *obj) +/////////////////////////////////////////////////////////////////////////////// +// c_can_irq_update_filter +// +// update acceptance filter for given object. +// + +void c_can_irq_update_filter(struct canchip_t *pchip, struct msgobj_t *obj) +{ + struct canfilt_t filt; + + if(canqueue_ends_filt_conjuction(obj->qends, &filt)) { + obj->rx_preconfig_id=filt.id; + + if (filt.flags&MSG_EXT) + can_msgobj_set_fl(obj,RX_MODE_EXT); + else + can_msgobj_clear_fl(obj,RX_MODE_EXT); + + c_can_mask(obj, filt.mask, 0); + + c_can_pre_read_config(pchip, obj); + + CANMSG("c_can_irq_update_filter: obj #%d\n",obj->object); + } +} + +/////////////////////////////////////////////////////////////////////////////// +// c_can_irq_sync_activities +// +// ensure, that not requests for object activities are serialized. +// + +void c_can_irq_sync_activities(struct canchip_t *pchip, struct msgobj_t *obj) { while (!can_msgobj_test_and_set_fl(obj, TX_LOCK)) { - /*if(can_msgobj_test_and_clear_fl(obj,TX_REQUEST)) { - if(canobj_read_reg(chip,obj,iMSGCTL1)&TXRQ_RES) - i82527_irq_write_handler(chip, obj); - } + if(can_msgobj_test_and_clear_fl(obj,TX_REQUEST)) { + int cctreqx; + int idxobj = obj->object-1; + + if(idxobj<0) { + DEBUGMSG("c_can_irq_sync_activities wrong idxobj\n"); + break; + } + + if(idxobj < 16) + cctreqx = c_can_read_reg_w(pchip, CCTREQ1); + else + cctreqx = c_can_read_reg_w(pchip, CCTREQ2); - if(!obj->tx_slot) { - if(can_msgobj_test_and_clear_fl(obj,FILTCH_REQUEST)) { - i82527_irq_update_filter(chip, obj); - } - } */ - /* FIXME: these functionality has to be implemented to start TX */ + if (!(cctreqx & (1 << (idxobj & 0xf)))) { + can_msgobj_clear_fl(obj, TX_REQUEST); + c_can_irq_write_handler(pchip, idxobj); + } + } + + if(!obj->tx_slot) { + if(can_msgobj_test_and_clear_fl(obj,FILTCH_REQUEST)) { + c_can_irq_update_filter(pchip, obj); + } + } can_msgobj_clear_fl(obj, TX_LOCK); + + mb(); + if (can_msgobj_test_fl(obj, TX_REQUEST)) continue; if (can_msgobj_test_fl(obj, FILTCH_REQUEST) && !obj->tx_slot) @@ -356,7 +405,7 @@ int c_can_irq_handler(int irq, struct canchip_t *pchip) #endif /*CAN_WITH_STATISTICS */ //return; // continue? } else { - if (irqreg > 0 && irqreg < 33) { + if (irqreg >= 1 && irqreg <= 32) { struct msgobj_t *pmsgobj; int idxobj; @@ -402,6 +451,7 @@ int c_can_irq_handler(int irq, struct canchip_t *pchip) } //transfer Message Object to IF1 Buffer if (c_can_if1_busycheck(pchip)) ; + c_can_write_reg_w(pchip, readMaskCM, CCIF1CM); c_can_write_reg_w(pchip, idxobj + 1, CCIF1CR); @@ -410,6 +460,12 @@ int c_can_irq_handler(int irq, struct canchip_t *pchip) IFXARB2_DIR) { spin_unlock(&c_can_if1lock); c_can_irq_write_handler(pchip, idxobj); + + if(!pmsgobj->tx_slot){ + if(can_msgobj_test_and_clear_fl(pmsgobj, FILTCH_REQUEST)) { + c_can_irq_update_filter(pchip, pmsgobj); + } + } } else { if (can_msgobj_test_fl (pmsgobj, RX_MODE_EXT)) { @@ -462,11 +518,10 @@ int c_can_irq_handler(int irq, struct canchip_t *pchip) } spin_unlock(&c_can_if1lock); - //} } //else } - //if + //if (irqreg >= 1 && irqreg <= 32) } // Get irq status again irqreg = c_can_read_reg_w(pchip, CCINTR); diff --git a/lincan/src/i82527.c b/lincan/src/i82527.c index d5c7b24..60096c5 100644 --- a/lincan/src/i82527.c +++ b/lincan/src/i82527.c @@ -616,6 +616,8 @@ void i82527_irq_sync_activities(struct canchip_t *chip, struct msgobj_t *obj) } } + mb(); + can_msgobj_clear_fl(obj,TX_LOCK); if(can_msgobj_test_fl(obj,TX_REQUEST)) continue;