Changeset 24abb85d in mainline for kernel/generic/src/ddi/irq.c


Ignore:
Timestamp:
2017-08-18T23:27:08Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4d76cfc
Parents:
e9d15d9
Message:

Remove SYS_DEVICE_ASSIGN_DEVNO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ddi/irq.c

    re9d15d9 r24abb85d  
    5959 * Note about the irq_hash_table.
    6060 *
    61  * The hash table is configured to use two keys: inr and devno.  However, the
    62  * hash index is computed only from inr. Moreover, if devno is -1, the match is
    63  * based on the return value of the claim() function instead of on devno.
     61 * The hash table is configured to use two keys: inr and mode.  However, the
     62 * hash index is computed only from inr. Moreover, if mode is IRQ_HT_MODE_CLAIM,
     63 * the match is based also on the return value of the claim(). Otherwise the
     64 * the keys do not match.
    6465 */
    6566
     
    7374#include <mem.h>
    7475#include <arch.h>
    75 
    76 #define KEY_INR    0
    77 #define KEY_DEVNO  1
    7876
    7977/** Spinlock protecting the kernel IRQ hash table.
     
    174172        link_initialize(&irq->notif_cfg.link);
    175173        irq->inr = -1;
    176         irq->devno = -1;
    177174       
    178175        irq_initialize_arch(irq);
     
    190187{
    191188        sysarg_t key[] = {
    192                 (sysarg_t) irq->inr,
    193                 (sysarg_t) irq->devno
     189                [IRQ_HT_KEY_INR] = (sysarg_t) irq->inr,
     190                [IRQ_HT_KEY_MODE] = (sysarg_t) IRQ_HT_MODE_NO_CLAIM
    194191        };
    195192       
     
    208205        link_t *lnk;
    209206        sysarg_t key[] = {
    210                 (sysarg_t) inr,
    211                 (sysarg_t) -1    /* Search will use claim() instead of devno */
     207                [IRQ_HT_KEY_INR] = (sysarg_t) inr,
     208                [IRQ_HT_KEY_MODE] = (sysarg_t) IRQ_HT_MODE_CLAIM
    212209        };
    213210       
     
    231228        link_t *lnk;
    232229        sysarg_t key[] = {
    233                 (sysarg_t) inr,
    234                 (sysarg_t) -1    /* Search will use claim() instead of devno */
     230                [IRQ_HT_KEY_INR] = (sysarg_t) inr,
     231                [IRQ_HT_KEY_MODE] = (sysarg_t) IRQ_HT_MODE_CLAIM
    235232        };
    236233       
     
    290287 * be collisions between different INRs.
    291288 *
    292  * The devno is not used to compute the hash.
    293  *
    294  * @param key The first of the keys is inr and the second is devno or -1.
     289 * The mode is not used to compute the hash.
     290 *
     291 * @param key The first of the keys is inr and the second is mode.
    295292 *
    296293 * @return Index into the hash table.
     
    299296size_t irq_ht_hash(sysarg_t key[])
    300297{
    301         inr_t inr = (inr_t) key[KEY_INR];
     298        inr_t inr = (inr_t) key[IRQ_HT_KEY_INR];
    302299        return inr % buckets;
    303300}
     
    308305 * more complex architecture setup in which there are way too many interrupt
    309306 * numbers (i.e. inr's) to arrange the hash table so that collisions occur only
    310  * among same inrs of different devnos. So the explicit check for inr match must
    311  * be done.  Second, if devno is -1, the second key (i.e. devno) is not used for
    312  * the match and the result of the claim() function is used instead.
     307 * among same inrs of different devices. So the explicit check for inr match
     308 * must be done.  Second, if mode is IRQ_HT_MODE_CLAIM, the result of the
     309 * claim() function is used for the match. Otherwise the key does not match.
    313310 *
    314311 * This function assumes interrupts are already disabled.
    315312 *
    316  * @param key  Keys (i.e. inr and devno).
     313 * @param key  Keys (i.e. inr and mode).
    317314 * @param keys This is 2.
    318315 * @param item The item to compare the key with.
     
    325322{
    326323        irq_t *irq = hash_table_get_instance(item, irq_t, link);
    327         inr_t inr = (inr_t) key[KEY_INR];
    328         devno_t devno = (devno_t) key[KEY_DEVNO];
     324        inr_t inr = (inr_t) key[IRQ_HT_KEY_INR];
     325        irq_ht_mode_t mode = (irq_ht_mode_t) key[IRQ_HT_KEY_MODE];
    329326       
    330327        bool rv;
    331328       
    332329        irq_spinlock_lock(&irq->lock, false);
    333         if (devno == -1) {
     330        if (mode == IRQ_HT_MODE_CLAIM) {
    334331                /* Invoked by irq_dispatch_and_lock(). */
    335                 rv = ((irq->inr == inr) &&
    336                     (irq->claim(irq) == IRQ_ACCEPT));
     332                rv = ((irq->inr == inr) && (irq->claim(irq) == IRQ_ACCEPT));
    337333        } else {
    338334                /* Invoked by irq_find_and_lock(). */
    339                 rv = ((irq->inr == inr) && (irq->devno == devno));
     335                rv = false;
    340336        }
    341337       
     
    363359 * no collisions between different INRs.
    364360 *
    365  * @param key The first of the keys is inr and the second is devno or -1.
     361 * @param key The first of the keys is inr and the second is mode.
    366362 *
    367363 * @return Index into the hash table.
     
    370366size_t irq_lin_hash(sysarg_t key[])
    371367{
    372         inr_t inr = (inr_t) key[KEY_INR];
     368        inr_t inr = (inr_t) key[IRQ_HT_KEY_INR];
    373369        return inr;
    374370}
     
    385381 * This function assumes interrupts are already disabled.
    386382 *
    387  * @param key  Keys (i.e. inr and devno).
     383 * @param key  Keys (i.e. inr and mode).
    388384 * @param keys This is 2.
    389385 * @param item The item to compare the key with.
     
    396392{
    397393        irq_t *irq = list_get_instance(item, irq_t, link);
    398         devno_t devno = (devno_t) key[KEY_DEVNO];
     394        irq_ht_mode_t mode = (irq_ht_mode_t) key[IRQ_HT_KEY_MODE];
    399395        bool rv;
    400396       
    401397        irq_spinlock_lock(&irq->lock, false);
    402         if (devno == -1) {
     398        if (mode == IRQ_HT_MODE_CLAIM) {
    403399                /* Invoked by irq_dispatch_and_lock() */
    404400                rv = (irq->claim(irq) == IRQ_ACCEPT);
    405401        } else {
    406402                /* Invoked by irq_find_and_lock() */
    407                 rv = (irq->devno == devno);
     403                rv = false;
    408404        }
    409405       
Note: See TracChangeset for help on using the changeset viewer.