diff options
author | Roland Dreier <rolandd@cisco.com> | 2007-07-18 16:28:29 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-07-18 16:28:29 -0400 |
commit | 43509d1fece975ac457282ca1137fe438894a81d (patch) | |
tree | c96f9a628208fcb56fb616fed96b81081c1a2eee /drivers/infiniband | |
parent | e535c699bfeafd0380418156f93494e370613e9d (diff) |
IB/mthca: Simplify use of size0 in work request posting
Current code sets size0 to 0 at the start of work request posting
functions and then handles size0 == 0 specially within the loop over
work requests. Change this so size0 is set along with f0 the first
time through the loop (when nreq == 0). This makes the code easier to
understand by making it clearer that f0 and size0 are always
initialized if nreq != 0 without having to know that size0 == 0
implies nreq == 0.
Also annotate size0 with uninitialized_var() so that this doesn't
introduce a new compiler warning.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_qp.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index b5bd704ca55d..df01b2026a64 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
@@ -1629,13 +1629,14 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1629 | int nreq; | 1629 | int nreq; |
1630 | int i; | 1630 | int i; |
1631 | int size; | 1631 | int size; |
1632 | int size0 = 0; | ||
1633 | /* | 1632 | /* |
1634 | * f0 is only used if nreq != 0, and f0 will be initialized | 1633 | * f0 and size0 are only used if nreq != 0, and they will |
1635 | * the first time through the main loop, since size0 == 0 the | 1634 | * always be initialized the first time through the main loop |
1636 | * first time through. So nreq cannot become non-zero without | 1635 | * before nreq is incremented. So nreq cannot become non-zero |
1637 | * initializing f0, and f0 is in fact never used uninitialized. | 1636 | * without initializing f0 and size0, and they are in fact |
1637 | * never used uninitialized. | ||
1638 | */ | 1638 | */ |
1639 | int uninitialized_var(size0); | ||
1639 | u32 uninitialized_var(f0); | 1640 | u32 uninitialized_var(f0); |
1640 | int ind; | 1641 | int ind; |
1641 | u8 op0 = 0; | 1642 | u8 op0 = 0; |
@@ -1780,11 +1781,11 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1780 | mthca_opcode[wr->opcode]); | 1781 | mthca_opcode[wr->opcode]); |
1781 | wmb(); | 1782 | wmb(); |
1782 | ((struct mthca_next_seg *) prev_wqe)->ee_nds = | 1783 | ((struct mthca_next_seg *) prev_wqe)->ee_nds = |
1783 | cpu_to_be32((size0 ? 0 : MTHCA_NEXT_DBD) | size | | 1784 | cpu_to_be32((nreq ? 0 : MTHCA_NEXT_DBD) | size | |
1784 | ((wr->send_flags & IB_SEND_FENCE) ? | 1785 | ((wr->send_flags & IB_SEND_FENCE) ? |
1785 | MTHCA_NEXT_FENCE : 0)); | 1786 | MTHCA_NEXT_FENCE : 0)); |
1786 | 1787 | ||
1787 | if (!size0) { | 1788 | if (!nreq) { |
1788 | size0 = size; | 1789 | size0 = size; |
1789 | op0 = mthca_opcode[wr->opcode]; | 1790 | op0 = mthca_opcode[wr->opcode]; |
1790 | f0 = wr->send_flags & IB_SEND_FENCE ? | 1791 | f0 = wr->send_flags & IB_SEND_FENCE ? |
@@ -1834,7 +1835,14 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
1834 | int nreq; | 1835 | int nreq; |
1835 | int i; | 1836 | int i; |
1836 | int size; | 1837 | int size; |
1837 | int size0 = 0; | 1838 | /* |
1839 | * size0 is only used if nreq != 0, and it will always be | ||
1840 | * initialized the first time through the main loop before | ||
1841 | * nreq is incremented. So nreq cannot become non-zero | ||
1842 | * without initializing size0, and it is in fact never used | ||
1843 | * uninitialized. | ||
1844 | */ | ||
1845 | int uninitialized_var(size0); | ||
1838 | int ind; | 1846 | int ind; |
1839 | void *wqe; | 1847 | void *wqe; |
1840 | void *prev_wqe; | 1848 | void *prev_wqe; |
@@ -1888,7 +1896,7 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
1888 | ((struct mthca_next_seg *) prev_wqe)->ee_nds = | 1896 | ((struct mthca_next_seg *) prev_wqe)->ee_nds = |
1889 | cpu_to_be32(MTHCA_NEXT_DBD | size); | 1897 | cpu_to_be32(MTHCA_NEXT_DBD | size); |
1890 | 1898 | ||
1891 | if (!size0) | 1899 | if (!nreq) |
1892 | size0 = size; | 1900 | size0 = size; |
1893 | 1901 | ||
1894 | ++ind; | 1902 | ++ind; |
@@ -1910,7 +1918,6 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
1910 | 1918 | ||
1911 | qp->rq.next_ind = ind; | 1919 | qp->rq.next_ind = ind; |
1912 | qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB; | 1920 | qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB; |
1913 | size0 = 0; | ||
1914 | } | 1921 | } |
1915 | } | 1922 | } |
1916 | 1923 | ||
@@ -1952,13 +1959,14 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1952 | int nreq; | 1959 | int nreq; |
1953 | int i; | 1960 | int i; |
1954 | int size; | 1961 | int size; |
1955 | int size0 = 0; | ||
1956 | /* | 1962 | /* |
1957 | * f0 is only used if nreq != 0, and f0 will be initialized | 1963 | * f0 and size0 are only used if nreq != 0, and they will |
1958 | * the first time through the main loop, since size0 == 0 the | 1964 | * always be initialized the first time through the main loop |
1959 | * first time through. So nreq cannot become non-zero without | 1965 | * before nreq is incremented. So nreq cannot become non-zero |
1960 | * initializing f0, and f0 is in fact never used uninitialized. | 1966 | * without initializing f0 and size0, and they are in fact |
1967 | * never used uninitialized. | ||
1961 | */ | 1968 | */ |
1969 | int uninitialized_var(size0); | ||
1962 | u32 uninitialized_var(f0); | 1970 | u32 uninitialized_var(f0); |
1963 | int ind; | 1971 | int ind; |
1964 | u8 op0 = 0; | 1972 | u8 op0 = 0; |
@@ -1979,7 +1987,6 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1979 | doorbell[1] = cpu_to_be32((qp->qpn << 8) | size0); | 1987 | doorbell[1] = cpu_to_be32((qp->qpn << 8) | size0); |
1980 | 1988 | ||
1981 | qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB; | 1989 | qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB; |
1982 | size0 = 0; | ||
1983 | 1990 | ||
1984 | /* | 1991 | /* |
1985 | * Make sure that descriptors are written before | 1992 | * Make sure that descriptors are written before |
@@ -2133,7 +2140,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
2133 | ((wr->send_flags & IB_SEND_FENCE) ? | 2140 | ((wr->send_flags & IB_SEND_FENCE) ? |
2134 | MTHCA_NEXT_FENCE : 0)); | 2141 | MTHCA_NEXT_FENCE : 0)); |
2135 | 2142 | ||
2136 | if (!size0) { | 2143 | if (!nreq) { |
2137 | size0 = size; | 2144 | size0 = size; |
2138 | op0 = mthca_opcode[wr->opcode]; | 2145 | op0 = mthca_opcode[wr->opcode]; |
2139 | f0 = wr->send_flags & IB_SEND_FENCE ? | 2146 | f0 = wr->send_flags & IB_SEND_FENCE ? |