mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davide Rossetti <davide.rossetti@roma1.infn.it>
To: linux-kernel@vger.kernel.org
Subject: workqueues and schedule()
Date: Wed, 16 Feb 2005 17:02:39 +0100	[thread overview]
Message-ID: <42136E9F.1060804@roma1.infn.it> (raw)

<environment>
I'm authoring a (GPL) driver for a custom 3D network card.
</environment>

on calling some polling functions from within a workqueue, I'm getting 
lockups... sysrq-p got it clear I have a workqueue thread down into 
schedule_timeout().
is considered polite to call schedule ? is in_softirq() capable to diff 
workqueue/normal case ?

static int __apedev_hdrring_poll_end_dma(ApeDev* apedev, struct 
ApeHdrRing* ring)
{
    int ret = 0;
    int counter;

    APE_BUG_ON(0 == ring);
    APE_BUG_ON(0 == apedev);   
   
    // here I poll on the rwbuf memory content till dma is done
    ndelay(5*HZPCI);
    APEDEV_COUNTER_INC(apedev, hdrring_poll_ndelay_cnt);
    counter = 0;
    while(1) {
        if(0 != __apedev_hdrring_check_magic(apedev, ring))
            break;

        counter++;
        ndelay(20*HZPCI);
        if(0 == counter % 512) {
            APEDEV_COUNTER_INC(apedev, hdrring_poll_ndelay_cnt);
            ndelay(50*HZPCI);
        }
        if(counter==2048*16) { // time past is 2048*16/512*50HZPCI
            PDEBUG("counter overflows 2048*16, delaying 1 jiffy\n");

            set_current_state(TASK_UNINTERRUPTIBLE);
            schedule_timeout(MAX(HZ/100,1));            //<----

            counter = 0;
            APEDEV_COUNTER_INC(apedev, hdrring_poll_resched_cnt);
        }
        if(signal_pending(current)) {
            PERROR("GOT SIGNAL!!!\n");
            //apedev_v3_dump_regs(apedev);
            ret = -EINTR;
            goto err;
        }
    }
 err:
    return ret;
}

// fast path
static inline int apedev_hdrring_poll_end_dma(ApeDev* apedev, struct 
ApeHdrRing* ring)
{
    int ret = 0;
    int retcode;

    APE_BUG_ON(0 == ring);
    APE_BUG_ON(0 == apedev);   
   
    retcode = __apedev_hdrring_check_magic(apedev, ring);
    if(retcode < 0) {
        PERROR("error in check_magic\n");
        ret = retcode;
        // exit with true...
    } else if(ret==0) {
        ret = __apedev_hdrring_poll_end_dma(apedev, ring);
        PDEBUG("ret=%d\n", ret);
    }
    return ret;
}



                 reply	other threads:[~2005-02-16 16:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42136E9F.1060804@roma1.infn.it \
    --to=davide.rossetti@roma1.infn.it \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®