Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hw,dma] DMA fixes after merge to master #24804

Merged
merged 4 commits into from
Oct 29, 2024
Merged

Conversation

Razer6
Copy link
Member

@Razer6 Razer6 commented Oct 17, 2024

This PR adds two fixes needed after merging the DMA to master:

  1. It changes the SHA mode None to SHA_None, which was changed in the related upstream package
  2. It removes the devmode interface, which was removed from the upstream register tooling.

This PR fixes the SHA opcode when no SHA mode is used.
On master, this definition changed from None to SHA_None.

Signed-off-by: Robert Schilling <[email protected]>
@Razer6 Razer6 requested a review from a team as a code owner October 17, 2024 14:29
@Razer6 Razer6 requested review from rswarbrick and alees24 and removed request for a team October 17, 2024 14:29
@Razer6 Razer6 added the IP:dma label Oct 17, 2024
@Razer6 Razer6 requested a review from andreaskurth October 17, 2024 15:20
@Razer6
Copy link
Member Author

Razer6 commented Oct 17, 2024

Smoke is still failing with:

    * Test dma_generic_smoke has 1 failures.
        * 0.dma_generic_smoke.41808117927340199003857090625009877405905829949318719279971918770493320013570\
          Line 108, in log /work/rschilling/opentitan/scratch/dma-fixes/dma-sim-xcelium/0.dma_generic_smoke/latest/run.log

                UVM_FATAL @  130003034ps: (dv_base_reg.sv:354) [dma_reg_block.range_regwen] lock register invalid access RW
                UVM_INFO @  130003034ps: (uvm_report_catcher.svh:705) [UVM/REPORT/CATCHER]
                --- UVM Report catcher Summary ---
                

@Razer6
Copy link
Member Author

Razer6 commented Oct 18, 2024

The issue is most probably because #20446 is missing on master.

@Razer6 Razer6 requested a review from msfschaffner as a code owner October 18, 2024 08:27
Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

REGWEN fields may exist in CSRs that are non-HRO, but
those registers must not be modified indirectly by
CSR testing.

Signed-off-by: Adrian Lees <[email protected]>
@Razer6
Copy link
Member Author

Razer6 commented Oct 19, 2024

Unfortunately, the last commit didn't change anything. @alees24 Could you help me here?

@Razer6
Copy link
Member Author

Razer6 commented Oct 22, 2024

@rswarbrick That is the DMA I was talking about regarding the regwen.

@rswarbrick
Copy link
Contributor

Looking at the line that's failing, I think this comes from an assertion in dv_base_reg. See lock_lockable_flds at dv_base_reg.sv:330.

It seems to be showing the REGWEN field as being RW. But that's confusing to me: it looks like it's:

    { name: "RANGE_REGWEN"
      desc: "Used to lock the DMA enabled memory range configuration registers."
      swaccess: "rw0c"
      hwaccess: "hro"
...

Maybe worth adding some tracing to figure out how the regwen field is considered RW. Maybe we're not propagating the access permissions correctly from a register to the fields inside it?

Copy link
Contributor

@andreaskurth andreaskurth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RTL change LGTM

@johngt johngt requested a review from martin-velay October 24, 2024 06:31
@johngt
Copy link

johngt commented Oct 24, 2024

@martin-velay - @andreaskurth has suggested that you take a quick look at this too.

Copy link
Contributor

@martin-velay martin-velay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DV & RTL seems OK. For the FPV in tpl format I have no idea.

And I think you should also update opentitan/hw/ip/dma/dv/doc/tb.svg to remove the references to devmode

Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Razer6! This looks good to me but I realise that we don't have CI coverage for this block yet. Are you happy for the change to be merged now or would you prefer to tweak it first?

@Razer6
Copy link
Member Author

Razer6 commented Oct 28, 2024

@rswarbrick I'm happy to merge that though smoke still fails with the error from above.

@rswarbrick
Copy link
Contributor

I've just taken a bit of a look and the problem is being caused by the fact that the regwen field of range_regwen appears in the auto-generated dma_ral_pkg.sv with access set to "RW". The code in dv_base_reg.sv always expects regwen fields to be "RO" or "W0C" (this is the test that's failing).

I was a bit surprised to see that this worked in the integrated-dev branch. If you do a bit of tracing through reggen, you find that the access flags actually come from access.py and this is different between the two branches. The difference comes from commit 0b90b90.

I'll do a bit more digging, but this should hopefully explain why there is a mismatch.

@rswarbrick
Copy link
Contributor

Ahah! The logic in the DV code is from this:

  // This function is used for wen_reg to lock its lockable flds by changing the lockable flds'
  // access policy. For register write via csr_wr(), this function is included in post_write().
  // For register write via tl_access(), user will need to call this function manually.
  virtual function void lock_lockable_flds(uvm_reg_data_t val, uvm_predict_e kind);
    if (is_wen_reg()) begin
      `uvm_info(`gfn, $sformatf("lock_lockable_flds %d val", val), UVM_LOW);
      foreach (m_fields[i]) begin
        dv_base_reg_field fld;
        `downcast(fld, m_fields[i])
        if (fld.is_wen_fld()) begin
          uvm_reg_data_t field_val = val & fld.get_field_mask();
          string field_access = fld.get_access();
          case (field_access)
            // discussed in issue #1922: enable register is standarized to W0C or RO (if HW has
            // write access).
            "W0C": begin
              // This is the regular behavior with W0C access policy enabled (i.e., only
              // clearing is possible).
              if (kind == UVM_PREDICT_WRITE && field_val == 1'b0) begin
                fld.set_lockable_flds_access(1);
              // In this case we are using direct prediction where the access policy is not
              // applied. I.e., a regwen bit that has been set to 0 can be set to 1 again.
              end else if (kind == UVM_PREDICT_DIRECT) begin
                fld.set_lockable_flds_access((~field_val) & fld.get_field_mask());
              end
            end
            "RO": ; // if RO, it's updated by design, need to predict in scb
            default:`uvm_fatal(`gfn, $sformatf("lock register invalid access %s", field_access))
          endcase
        end
      end
    end
  endfunction

This isn't particularly easy to read, but I think the point is that every field in a regwen is expected to either be W0C or RO`. The important thing is that neither of these values allows software to directly re-enable writes.

Looking at the Python code, the dv_rights function is supposed to return the access rights for a field in a form that UVM will understand. On integrated_dev, this is basically the name of the enum value except that r0w1c is mapped to "w1c" (presumably UVM doesn't know about r0w1c as an access pattern).

On master, the commit I pointed to was reasonable. The point is that a mubi value can't be considered (e.g.) R0C because UVM will be thinking about clearing each bit, rather than the logical meaning of the mubi.

I think the correct fix is to sort out the dv_base_reg logic and I'll start looking at that now.

@rswarbrick
Copy link
Contributor

Well, that was harder than I expected! I think the change in #24912 should be what we need.

Remove duplicated tl_agent_dma_ctn_cfg. Add reference to tl_agent_dma_sys_cfg.

Signed-off-by: Robert Schilling <[email protected]>
@Razer6
Copy link
Member Author

Razer6 commented Oct 29, 2024

I added a commit on top to update the TB figure. I removed the reference to devmode, removed the duplicated reference to tl_agent_dma_ctn_cfg and added a reference to tl_agent_dma_sys_cfg

@vogelpi
Copy link
Contributor

vogelpi commented Oct 29, 2024

I've reviewed and approved @rswarbrick 's fix. We should probably merge that one first and then this PR here.

@Razer6
Copy link
Member Author

Razer6 commented Oct 29, 2024

Sounds good. I see the fix got merged. Let's merge this once CI is happy to unblock the other DMA PRs.

@rswarbrick
Copy link
Contributor

We've got past the only changes that might be detectable by CI (all that remains is FPGA runs, which this can't break). Looks good!

@rswarbrick rswarbrick merged commit 6202b47 into lowRISC:master Oct 29, 2024
32 of 40 checks passed
@Razer6 Razer6 deleted the dma-fixes branch October 29, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants