From: kbuild test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [linux-next:master 9757/13554] drivers/misc/habanalabs/command_submission.c:792:3: note: in expansion of macro 'if'
Date: Fri, 29 May 2020 10:14:18 +0800 [thread overview]
Message-ID: <202005291015.ToNuMaIB%lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 10317 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: ff387fc20c697cdc887b2abf7ef494e853795a2f
commit: b75f22505ac97ea680bcc3e23dcd56f421252b43 [9757/13554] habanalabs: add signal/wait to CS IOCTL operations
config: microblaze-randconfig-r033-20200528 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout b75f22505ac97ea680bcc3e23dcd56f421252b43
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>
All warnings (new ones prefixed by >>, old ones prefixed by <<):
In file included from include/linux/kernel.h:11,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/misc/habanalabs/habanalabs.h:14,
from drivers/misc/habanalabs/command_submission.c:9:
drivers/misc/habanalabs/command_submission.c: In function 'cs_ioctl_signal_wait':
drivers/misc/habanalabs/command_submission.c:793:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
793 | (void __user *) chunk->signal_seq_arr,
| ^
include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
| ^~~~
>> drivers/misc/habanalabs/command_submission.c:792:3: note: in expansion of macro 'if'
792 | if (copy_from_user(signal_seq_arr,
| ^~
drivers/misc/habanalabs/command_submission.c:793:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
793 | (void __user *) chunk->signal_seq_arr,
| ^
include/linux/compiler.h:58:61: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
| ^~~~
>> drivers/misc/habanalabs/command_submission.c:792:3: note: in expansion of macro 'if'
792 | if (copy_from_user(signal_seq_arr,
| ^~
drivers/misc/habanalabs/command_submission.c:793:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
793 | (void __user *) chunk->signal_seq_arr,
| ^
include/linux/compiler.h:69:3: note: in definition of macro '__trace_if_value'
69 | (cond) ? | ^~~~
include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var'
56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
| ^~~~~~~~~~~~~~
>> drivers/misc/habanalabs/command_submission.c:792:3: note: in expansion of macro 'if'
792 | if (copy_from_user(signal_seq_arr,
| ^~
vim +/if +792 drivers/misc/habanalabs/command_submission.c
716
717 static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
718 void __user *chunks, u32 num_chunks,
719 u64 *cs_seq)
720 {
721 struct hl_device *hdev = hpriv->hdev;
722 struct hl_ctx *ctx = hpriv->ctx;
723 struct hl_cs_chunk *cs_chunk_array, *chunk;
724 struct hw_queue_properties *hw_queue_prop;
725 struct dma_fence *sig_fence = NULL;
726 struct hl_cs_job *job;
727 struct hl_cs *cs;
728 struct hl_cb *cb;
729 u64 *signal_seq_arr = NULL, signal_seq;
730 u32 size_to_copy, q_idx, signal_seq_arr_len, cb_size;
731 int rc;
732
733 *cs_seq = ULLONG_MAX;
734
735 if (num_chunks > HL_MAX_JOBS_PER_CS) {
736 dev_err(hdev->dev,
737 "Number of chunks can NOT be larger than %d\n",
738 HL_MAX_JOBS_PER_CS);
739 rc = -EINVAL;
740 goto out;
741 }
742
743 cs_chunk_array = kmalloc_array(num_chunks, sizeof(*cs_chunk_array),
744 GFP_ATOMIC);
745 if (!cs_chunk_array) {
746 rc = -ENOMEM;
747 goto out;
748 }
749
750 size_to_copy = num_chunks * sizeof(struct hl_cs_chunk);
751 if (copy_from_user(cs_chunk_array, chunks, size_to_copy)) {
752 dev_err(hdev->dev, "Failed to copy cs chunk array from user\n");
753 rc = -EFAULT;
754 goto free_cs_chunk_array;
755 }
756
757 /* currently it is guaranteed to have only one chunk */
758 chunk = &cs_chunk_array[0];
759 q_idx = chunk->queue_index;
760 hw_queue_prop = &hdev->asic_prop.hw_queues_props[q_idx];
761
762 if ((q_idx >= HL_MAX_QUEUES) ||
763 (hw_queue_prop->type != QUEUE_TYPE_EXT)) {
764 dev_err(hdev->dev, "Queue index %d is invalid\n", q_idx);
765 rc = -EINVAL;
766 goto free_cs_chunk_array;
767 }
768
769 if (cs_type == CS_TYPE_WAIT) {
770 struct hl_cs_compl *sig_waitcs_cmpl;
771
772 signal_seq_arr_len = chunk->num_signal_seq_arr;
773
774 /* currently only one signal seq is supported */
775 if (signal_seq_arr_len != 1) {
776 dev_err(hdev->dev,
777 "Wait for signal CS supports only one signal CS seq\n");
778 rc = -EINVAL;
779 goto free_cs_chunk_array;
780 }
781
782 signal_seq_arr = kmalloc_array(signal_seq_arr_len,
783 sizeof(*signal_seq_arr),
784 GFP_ATOMIC);
785 if (!signal_seq_arr) {
786 rc = -ENOMEM;
787 goto free_cs_chunk_array;
788 }
789
790 size_to_copy = chunk->num_signal_seq_arr *
791 sizeof(*signal_seq_arr);
> 792 if (copy_from_user(signal_seq_arr,
793 (void __user *) chunk->signal_seq_arr,
794 size_to_copy)) {
795 dev_err(hdev->dev,
796 "Failed to copy signal seq array from user\n");
797 rc = -EFAULT;
798 goto free_signal_seq_array;
799 }
800
801 /* currently it is guaranteed to have only one signal seq */
802 signal_seq = signal_seq_arr[0];
803 sig_fence = hl_ctx_get_fence(ctx, signal_seq);
804 if (IS_ERR(sig_fence)) {
805 dev_err(hdev->dev,
806 "Failed to get signal CS with seq 0x%llx\n",
807 signal_seq);
808 rc = PTR_ERR(sig_fence);
809 goto free_signal_seq_array;
810 }
811
812 if (!sig_fence) {
813 /* signal CS already finished */
814 rc = 0;
815 goto free_signal_seq_array;
816 }
817
818 sig_waitcs_cmpl =
819 container_of(sig_fence, struct hl_cs_compl, base_fence);
820
821 if (sig_waitcs_cmpl->type != CS_TYPE_SIGNAL) {
822 dev_err(hdev->dev,
823 "CS seq 0x%llx is not of a signal CS\n",
824 signal_seq);
825 dma_fence_put(sig_fence);
826 rc = -EINVAL;
827 goto free_signal_seq_array;
828 }
829
830 if (dma_fence_is_signaled(sig_fence)) {
831 /* signal CS already finished */
832 dma_fence_put(sig_fence);
833 rc = 0;
834 goto free_signal_seq_array;
835 }
836 }
837
838 /* increment refcnt for context */
839 hl_ctx_get(hdev, ctx);
840
841 rc = allocate_cs(hdev, ctx, cs_type, &cs);
842 if (rc) {
843 if (cs_type == CS_TYPE_WAIT)
844 dma_fence_put(sig_fence);
845 hl_ctx_put(ctx);
846 goto free_signal_seq_array;
847 }
848
849 /*
850 * Save the signal CS fence for later initialization right before
851 * hanging the wait CS on the queue.
852 */
853 if (cs->type == CS_TYPE_WAIT)
854 cs->signal_fence = sig_fence;
855
856 hl_debugfs_add_cs(cs);
857
858 *cs_seq = cs->sequence;
859
860 job = hl_cs_allocate_job(hdev, QUEUE_TYPE_EXT, true);
861 if (!job) {
862 dev_err(hdev->dev, "Failed to allocate a new job\n");
863 rc = -ENOMEM;
864 goto put_cs;
865 }
866
867 cb = hl_cb_kernel_create(hdev, PAGE_SIZE);
868 if (!cb) {
869 kfree(job);
870 rc = -EFAULT;
871 goto put_cs;
872 }
873
874 if (cs->type == CS_TYPE_WAIT)
875 cb_size = hdev->asic_funcs->get_wait_cb_size(hdev);
876 else
877 cb_size = hdev->asic_funcs->get_signal_cb_size(hdev);
878
879 job->id = 0;
880 job->cs = cs;
881 job->user_cb = cb;
882 job->user_cb->cs_cnt++;
883 job->user_cb_size = cb_size;
884 job->hw_queue_id = q_idx;
885
886 /*
887 * No need in parsing, user CB is the patched CB.
888 * We call hl_cb_destroy() out of two reasons - we don't need the CB in
889 * the CB idr anymore and to decrement its refcount as it was
890 * incremented inside hl_cb_kernel_create().
891 */
892 job->patched_cb = job->user_cb;
893 job->job_cb_size = job->user_cb_size;
894 hl_cb_destroy(hdev, &hdev->kernel_cb_mgr, cb->id << PAGE_SHIFT);
895
896 cs->jobs_in_queue_cnt[job->hw_queue_id]++;
897
898 list_add_tail(&job->cs_node, &cs->job_list);
899
900 /* increment refcount as for external queues we get completion */
901 cs_get(cs);
902
903 hl_debugfs_add_job(hdev, job);
904
905 rc = hl_hw_queue_schedule_cs(cs);
906 if (rc) {
907 if (rc != -EAGAIN)
908 dev_err(hdev->dev,
909 "Failed to submit CS %d.%llu to H/W queues, error %d\n",
910 ctx->asid, cs->sequence, rc);
911 goto free_cs_object;
912 }
913
914 rc = HL_CS_STATUS_SUCCESS;
915 goto put_cs;
916
917 free_cs_object:
918 cs_rollback(hdev, cs);
919 *cs_seq = ULLONG_MAX;
920 /* The path below is both for good and erroneous exits */
921 put_cs:
922 /* We finished with the CS in this function, so put the ref */
923 cs_put(cs);
924 free_signal_seq_array:
925 if (cs_type == CS_TYPE_WAIT)
926 kfree(signal_seq_arr);
927 free_cs_chunk_array:
928 kfree(cs_chunk_array);
929 out:
930 return rc;
931 }
932
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 31509 bytes --]
reply other threads:[~2020-05-29 2:14 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=202005291015.ToNuMaIB%lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild-all@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.