]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge 3.5-rc7 into char-misc-next.
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jul 2012 13:22:45 +0000 (06:22 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jul 2012 13:22:45 +0000 (06:22 -0700)
This lets us pick up the mei driver changes that we need in order to
handle future merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1  2 
drivers/misc/mei/interrupt.c
drivers/misc/mei/main.c
drivers/misc/mei/wd.c

index b428b3fe409270be93434f3a5c26c0c1ad288e34,23f5463d4cae432e5e1b65ac97e5ba6042a2c59e..c6ffbbe5a6c014b11ee05855795c1c941d0f0abe
@@@ -267,7 -267,8 +267,7 @@@ static int _mei_irq_thread_iamthif_read
                        + sizeof(struct hbm_flow_control))) {
                return -EMSGSIZE;
        }
 -      *slots -= (sizeof(struct mei_msg_hdr) +
 -                              sizeof(struct hbm_flow_control) + 3) / 4;
 +      *slots -= mei_data2slots(sizeof(struct hbm_flow_control));
        if (mei_send_flow_control(dev, &dev->iamthif_cl)) {
                dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");
                return -EIO;
        dev->iamthif_msg_buf_index = 0;
        dev->iamthif_msg_buf_size = 0;
        dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
 -      dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev);
 +      dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
        return 0;
  }
  
@@@ -299,25 -300,28 +299,25 @@@ static int _mei_irq_thread_close(struc
                                struct mei_cl *cl,
                                struct mei_io_list *cmpl_list)
  {
 -      if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
 -                      sizeof(struct hbm_client_disconnect_request))) {
 -              *slots -= (sizeof(struct mei_msg_hdr) +
 -                      sizeof(struct hbm_client_disconnect_request) + 3) / 4;
 +      if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
 +                      sizeof(struct hbm_client_disconnect_request)))
 +              return -EBADMSG;
  
 -              if (mei_disconnect(dev, cl)) {
 -                      cl->status = 0;
 -                      cb_pos->information = 0;
 -                      list_move_tail(&cb_pos->cb_list,
 -                                      &cmpl_list->mei_cb.cb_list);
 -                      return -EMSGSIZE;
 -              } else {
 -                      cl->state = MEI_FILE_DISCONNECTING;
 -                      cl->status = 0;
 -                      cb_pos->information = 0;
 -                      list_move_tail(&cb_pos->cb_list,
 -                                      &dev->ctrl_rd_list.mei_cb.cb_list);
 -                      cl->timer_count = MEI_CONNECT_TIMEOUT;
 -              }
 +      *slots -= mei_data2slots(sizeof(struct hbm_client_disconnect_request));
 +
 +      if (mei_disconnect(dev, cl)) {
 +              cl->status = 0;
 +              cb_pos->information = 0;
 +              list_move_tail(&cb_pos->cb_list,
 +                              &cmpl_list->mei_cb.cb_list);
 +              return -EMSGSIZE;
        } else {
 -              /* return the cancel routine */
 -              return -EBADMSG;
 +              cl->state = MEI_FILE_DISCONNECTING;
 +              cl->status = 0;
 +              cb_pos->information = 0;
 +              list_move_tail(&cb_pos->cb_list,
 +                              &dev->ctrl_rd_list.mei_cb.cb_list);
 +              cl->timer_count = MEI_CONNECT_TIMEOUT;
        }
  
        return 0;
@@@ -571,9 -575,10 +571,9 @@@ static void mei_client_disconnect_reque
                                        disconnect_req->me_addr);
                        cl_pos->state = MEI_FILE_DISCONNECTED;
                        cl_pos->timer_count = 0;
 -                      if (cl_pos == &dev->wd_cl) {
 -                              dev->wd_due_counter = 0;
 +                      if (cl_pos == &dev->wd_cl)
                                dev->wd_pending = false;
 -                      else if (cl_pos == &dev->iamthif_cl)
 +                      else if (cl_pos == &dev->iamthif_cl)
                                dev->iamthif_timer = 0;
  
                        /* prepare disconnect response */
@@@ -830,15 -835,15 +830,15 @@@ static int _mei_irq_thread_read(struct 
                        struct mei_cl *cl,
                        struct mei_io_list *cmpl_list)
  {
-       if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
+       if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
                        sizeof(struct hbm_flow_control))) {
                /* return the cancel routine */
                list_del(&cb_pos->cb_list);
                return -EBADMSG;
        }
  
 -      *slots -= (sizeof(struct mei_msg_hdr) +
 -                      sizeof(struct hbm_flow_control) + 3) / 4;
 +      *slots -= mei_data2slots(sizeof(struct hbm_flow_control));
 +
        if (mei_send_flow_control(dev, cl)) {
                cl->status = -ENODEV;
                cb_pos->information = 0;
@@@ -867,25 -872,27 +867,25 @@@ static int _mei_irq_thread_ioctl(struc
                        struct mei_cl *cl,
                        struct mei_io_list *cmpl_list)
  {
 -      if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
 +      if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
                        sizeof(struct hbm_client_connect_request))) {
 -              cl->state = MEI_FILE_CONNECTING;
 -              *slots -= (sizeof(struct mei_msg_hdr) +
 -                      sizeof(struct hbm_client_connect_request) + 3) / 4;
 -              if (mei_connect(dev, cl)) {
 -                      cl->status = -ENODEV;
 -                      cb_pos->information = 0;
 -                      list_del(&cb_pos->cb_list);
 -                      return -ENODEV;
 -              } else {
 -                      list_move_tail(&cb_pos->cb_list,
 -                              &dev->ctrl_rd_list.mei_cb.cb_list);
 -                      cl->timer_count = MEI_CONNECT_TIMEOUT;
 -              }
 -      } else {
                /* return the cancel routine */
                list_del(&cb_pos->cb_list);
                return -EBADMSG;
        }
  
 +      cl->state = MEI_FILE_CONNECTING;
 +       *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
 +      if (mei_connect(dev, cl)) {
 +              cl->status = -ENODEV;
 +              cb_pos->information = 0;
 +              list_del(&cb_pos->cb_list);
 +              return -ENODEV;
 +      } else {
 +              list_move_tail(&cb_pos->cb_list,
 +                      &dev->ctrl_rd_list.mei_cb.cb_list);
 +              cl->timer_count = MEI_CONNECT_TIMEOUT;
 +      }
        return 0;
  }
  
@@@ -925,7 -932,8 +925,7 @@@ static int _mei_irq_thread_cmpl(struct 
                                cb_pos->information);
                dev_dbg(&dev->pdev->dev, "mei_hdr->length  =%d\n",
                                mei_hdr->length);
 -              *slots -= (sizeof(struct mei_msg_hdr) +
 -                              mei_hdr->length + 3) / 4;
 +              *slots -= mei_data2slots(mei_hdr->length);
                if (mei_write_message(dev, mei_hdr,
                                (unsigned char *)
                                (cb_pos->request_buffer.data +
                        list_move_tail(&cb_pos->cb_list,
                                &dev->write_waiting_list.mei_cb.cb_list);
                }
 -      } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
 +      } else if (*slots == dev->hbuf_depth) {
                /* buffer is still empty */
                mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
                mei_hdr->host_addr = cl->host_client_id;
                        (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
                mei_hdr->msg_complete = 0;
                mei_hdr->reserved = 0;
 -
 -              (*slots) -= (sizeof(struct mei_msg_hdr) +
 -                              mei_hdr->length + 3) / 4;
 +              *slots -= mei_data2slots(mei_hdr->length);
                if (mei_write_message(dev, mei_hdr,
                                        (unsigned char *)
                                        (cb_pos->request_buffer.data +
@@@ -1011,7 -1021,8 +1011,7 @@@ static int _mei_irq_thread_cmpl_iamthif
                mei_hdr->msg_complete = 1;
                mei_hdr->reserved = 0;
  
 -              *slots -= (sizeof(struct mei_msg_hdr) +
 -                              mei_hdr->length + 3) / 4;
 +              *slots -= mei_data2slots(mei_hdr->length);
  
                if (mei_write_message(dev, mei_hdr,
                                        (dev->iamthif_msg_buf +
                                &dev->write_waiting_list.mei_cb.cb_list);
  
                }
 -      } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
 -                      /* buffer is still empty */
 +      } else if (*slots == dev->hbuf_depth) {
 +              /* buffer is still empty */
                mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
                mei_hdr->host_addr = cl->host_client_id;
                mei_hdr->me_addr = cl->me_client_id;
                mei_hdr->msg_complete = 0;
                mei_hdr->reserved = 0;
  
 -              *slots -= (sizeof(struct mei_msg_hdr) +
 -                              mei_hdr->length + 3) / 4;
 +              *slots -= mei_data2slots(mei_hdr->length);
  
                if (mei_write_message(dev, mei_hdr,
                                        (dev->iamthif_msg_buf +
@@@ -1187,19 -1199,17 +1187,19 @@@ static int mei_irq_thread_write_handler
        struct mei_io_list *list;
        int ret;
  
 -      if (!mei_host_buffer_is_empty(dev)) {
 +      if (!mei_hbuf_is_empty(dev)) {
                dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n");
                return 0;
        }
 -      *slots = mei_count_empty_write_slots(dev);
 +      *slots = mei_hbuf_empty_slots(dev);
 +      if (*slots <= 0)
 +              return -EMSGSIZE;
 +
        /* complete all waiting for write CB */
        dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
  
        list = &dev->write_waiting_list;
 -      list_for_each_entry_safe(pos, next,
 -                      &list->mei_cb.cb_list, cb_list) {
 +      list_for_each_entry_safe(pos, next, &list->mei_cb.cb_list, cb_list) {
                cl = (struct mei_cl *)pos->file_private;
                if (cl == NULL)
                        continue;
                if (MEI_WRITING == cl->writing_state &&
                   (pos->major_file_operations == MEI_WRITE) &&
                   (cl != &dev->iamthif_cl)) {
 -                      dev_dbg(&dev->pdev->dev,
 -                              "MEI WRITE COMPLETE\n");
 +                      dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n");
                        cl->writing_state = MEI_WRITE_COMPLETE;
                        list_add_tail(&pos->cb_list,
 -                              &cmpl_list->mei_cb.cb_list);
 +                                    &cmpl_list->mei_cb.cb_list);
                }
                if (cl == &dev->iamthif_cl) {
                        dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
                        if (dev->iamthif_flow_control_pending) {
 -                              ret = _mei_irq_thread_iamthif_read(
 -                                              dev, slots);
 +                              ret = _mei_irq_thread_iamthif_read(dev, slots);
                                if (ret)
                                        return ret;
                        }
        }
        if (dev->mei_state == MEI_ENABLED) {
                if (dev->wd_pending &&
 -                      mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
 +                  mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
                        if (mei_wd_send(dev))
                                dev_dbg(&dev->pdev->dev, "wd send failed.\n");
 -                      else
 -                              if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
 -                                      return -ENODEV;
 +                      else if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
 +                              return -ENODEV;
  
                        dev->wd_pending = false;
  
 -                      if (dev->wd_timeout) {
 -                              *slots -= (sizeof(struct mei_msg_hdr) +
 -                                       MEI_START_WD_DATA_SIZE + 3) / 4;
 -                              dev->wd_due_counter = 2;
 -                      } else {
 -                              *slots -= (sizeof(struct mei_msg_hdr) +
 -                                       MEI_WD_PARAMS_SIZE + 3) / 4;
 -                              dev->wd_due_counter = 0;
 -                      }
 -
 +                      if (dev->wd_timeout)
 +                              *slots -= mei_data2slots(MEI_START_WD_DATA_SIZE);
 +                      else
 +                              *slots -= mei_data2slots(MEI_START_WD_DATA_SIZE);
                }
        }
        if (dev->stop)
        /* complete  write list CB */
        dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
        list_for_each_entry_safe(pos, next,
 -                      &dev->write_list.mei_cb.cb_list, cb_list) {
 +                              &dev->write_list.mei_cb.cb_list, cb_list) {
                cl = (struct mei_cl *)pos->file_private;
                if (cl == NULL)
                        continue;
  
                if (cl != &dev->iamthif_cl) {
 -                      if (!mei_flow_ctrl_creds(dev, cl)) {
 +                      if (mei_flow_ctrl_creds(dev, cl) <= 0) {
                                dev_dbg(&dev->pdev->dev,
 -                                      "No flow control"
 -                                  " credentials for client"
 -                                  " %d, not sending.\n",
 -                                  cl->host_client_id);
 +                                      "No flow control credentials for client %d, not sending.\n",
 +                                      cl->host_client_id);
                                continue;
                        }
 -                      ret = _mei_irq_thread_cmpl(dev, slots,
 -                                          pos,
 -                                          cl, cmpl_list);
 +                      ret = _mei_irq_thread_cmpl(dev, slots, pos,
 +                                              cl, cmpl_list);
                        if (ret)
                                return ret;
  
                } else if (cl == &dev->iamthif_cl) {
                        /* IAMTHIF IOCTL */
                        dev_dbg(&dev->pdev->dev, "complete amthi write cb.\n");
 -                      if (!mei_flow_ctrl_creds(dev, cl)) {
 +                      if (mei_flow_ctrl_creds(dev, cl) <= 0) {
                                dev_dbg(&dev->pdev->dev,
 -                                      "No flow control"
 -                                  " credentials for amthi"
 -                                  " client %d.\n",
 -                                  cl->host_client_id);
 +                                      "No flow control credentials for amthi client %d.\n",
 +                                      cl->host_client_id);
                                continue;
                        }
 -                      ret = _mei_irq_thread_cmpl_iamthif(dev,
 -                                              slots,
 -                                              pos,
 -                                              cl,
 -                                              cmpl_list);
 +                      ret = _mei_irq_thread_cmpl_iamthif(dev, slots, pos,
 +                                              cl, cmpl_list);
                        if (ret)
                                return ret;
  
@@@ -1528,7 -1555,7 +1528,7 @@@ irqreturn_t mei_interrupt_thread_handle
  end:
        dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
        dev->host_hw_state = mei_hcsr_read(dev);
 -      dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev);
 +      dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
  
        bus_message_received = false;
        if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {
diff --combined drivers/misc/mei/main.c
index aaf2683ea154cb923612ff487cd497582f50fa0d,783fcd7365bc1e770739db884bba4a5088479e22..0d98c2ee6fe3afac8eb8629c3ed6a352630d11b1
@@@ -714,8 -714,13 +714,8 @@@ static ssize_t mei_write(struct file *f
        if (rets && dev->mei_host_buffer_is_empty) {
                rets = 0;
                dev->mei_host_buffer_is_empty = false;
 -              if (length > ((((dev->host_hw_state & H_CBD) >> 24) *
 -                      sizeof(u32)) - sizeof(struct mei_msg_hdr))) {
 -
 -                      mei_hdr.length =
 -                              (((dev->host_hw_state & H_CBD) >> 24) *
 -                              sizeof(u32)) -
 -                              sizeof(struct mei_msg_hdr);
 +              if (length >  mei_hbuf_max_data(dev)) {
 +                      mei_hdr.length = mei_hbuf_max_data(dev);
                        mei_hdr.msg_complete = 0;
                } else {
                        mei_hdr.length = length;
@@@ -977,7 -982,7 +977,7 @@@ static int __devinit mei_probe(struct p
                err = request_threaded_irq(pdev->irq,
                        NULL,
                        mei_interrupt_thread_handler,
-                       0, mei_driver_name, dev);
+                       IRQF_ONESHOT, mei_driver_name, dev);
        else
                err = request_threaded_irq(pdev->irq,
                        mei_interrupt_quick_handler,
        if (err) {
                dev_err(&pdev->dev, "request_threaded_irq failure. irq = %d\n",
                       pdev->irq);
-               goto unmap_memory;
+               goto disable_msi;
        }
        INIT_DELAYED_WORK(&dev->timer_work, mei_timer);
        if (mei_hw_init(dev)) {
@@@ -1018,8 -1023,8 +1018,8 @@@ release_irq
        mei_disable_interrupts(dev);
        flush_scheduled_work();
        free_irq(pdev->irq, dev);
+ disable_msi:
        pci_disable_msi(pdev);
- unmap_memory:
        pci_iounmap(pdev, dev->mem_addr);
  free_device:
        kfree(dev);
@@@ -1096,6 -1101,8 +1096,8 @@@ static void __devexit mei_remove(struc
  
        pci_release_regions(pdev);
        pci_disable_device(pdev);
+       misc_deregister(&mei_misc_device);
  }
  #ifdef CONFIG_PM
  static int mei_pci_suspend(struct device *device)
@@@ -1140,7 -1147,7 +1142,7 @@@ static int mei_pci_resume(struct devic
                err = request_threaded_irq(pdev->irq,
                        NULL,
                        mei_interrupt_thread_handler,
-                       0, mei_driver_name, dev);
+                       IRQF_ONESHOT, mei_driver_name, dev);
        else
                err = request_threaded_irq(pdev->irq,
                        mei_interrupt_quick_handler,
@@@ -1211,7 -1218,6 +1213,6 @@@ module_init(mei_init_module)
   */
  static void __exit mei_exit_module(void)
  {
-       misc_deregister(&mei_misc_device);
        pci_unregister_driver(&mei_driver);
  
        pr_debug("unloaded successfully.\n");
diff --combined drivers/misc/mei/wd.c
index 0a893389f6cbfe4716ad9d964fab48a06cc41189,e2ec0505eb5c05458568f8d12a7cdd6d3da9939d..5133fd77b91cc8e01be11736094cd9869b265a86
@@@ -53,12 -53,11 +53,12 @@@ static void mei_wd_set_start_timeout(st
  }
  
  /**
 - * host_init_wd - mei initialization wd.
 + * mei_wd_host_init - connect to the watchdog client
   *
   * @dev: the device structure
   * returns -ENENT if wd client cannot be found
   *         -EIO if write has failed
 + *         0 on success
   */
  int mei_wd_host_init(struct mei_device *dev)
  {
@@@ -138,6 -137,7 +138,6 @@@ int mei_wd_stop(struct mei_device *dev
                return 0;
  
        dev->wd_timeout = 0;
 -      dev->wd_due_counter = 0;
        memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_PARAMS_SIZE);
        dev->stop = true;
  
@@@ -341,7 -341,7 +341,7 @@@ static const struct watchdog_ops wd_op
  };
  static const struct watchdog_info wd_info = {
                .identity = INTEL_AMT_WATCHDOG_ID,
-               .options = WDIOF_KEEPALIVEPING,
+               .options = WDIOF_KEEPALIVEPING | WDIOF_ALARMONLY,
  };
  
  static struct watchdog_device amt_wd_dev = {
@@@ -357,6 -357,8 +357,6 @@@ void  mei_watchdog_register(struct mei_
  {
        dev_dbg(&dev->pdev->dev, "dev->wd_timeout =%d.\n", dev->wd_timeout);
  
 -      dev->wd_due_counter = !!dev->wd_timeout;
 -
        if (watchdog_register_device(&amt_wd_dev)) {
                dev_err(&dev->pdev->dev,
                        "wd: unable to register watchdog device.\n");