From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 348BED80D4E for ; Mon, 8 Jan 2024 15:26:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=MKXyKAH8LxWElLb4pX8H4mOfYiQkW8HT3Ik18rc77uU=; c=relaxed/simple; d=groups.io; h=Subject:To:From:User-Agent:MIME-Version:Date:References:In-Reply-To:Message-ID:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1704727587; v=1; b=gBEy0jY22uRH4+EAEzO8YCjsVlG0J0jWJ5Csf79AZsCJCCT2j9Bxkg2VZiH+gGc0wgoDaSEs rVwFnPx7I7SXRrotXo3qfk/HhNgzul+HvU4lg/Ltm05zRpIkYMHL4N7mUOGMBzo4QcZnLQPf7k2 ubAeRN6Dt68npVHU6fuKjLls= X-Received: by 127.0.0.2 with SMTP id 31rvYY7687511xuS1IZParyL; Mon, 08 Jan 2024 07:26:27 -0800 Subject: Re: [edk2-devel] [PATCH v10 4/5] MdePkg: Utilize Cache Management Operations Implementation For RISC-V To: Laszlo Ersek ,devel@edk2.groups.io From: "yorange" X-Originating-Location: Chengdu, Sichuan, CN (125.69.92.252) X-Originating-Platform: Windows Chrome 120 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Mon, 08 Jan 2024 07:26:27 -0800 References: <71b9c7de-7686-a3f2-0deb-63d9cc66f4c4@redhat.com> In-Reply-To: <71b9c7de-7686-a3f2-0deb-63d9cc66f4c4@redhat.com> Message-ID: <17828.1704727587183697949@groups.io> Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yangcheng.work@foxmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ihZ8vuJP5tnRnh322BM2YvWAx7686176AA= Content-Type: multipart/alternative; boundary="XH4kL1InApQS9N2MyTqh" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=gBEy0jY2; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=foxmail.com (policy=none) --XH4kL1InApQS9N2MyTqh Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, all I`m yangcheng, and I found this bug when using the *edk2-platforms/Silicon/= Synopsys/DesignWare/Drivers/DwEmmcDxe* driver on my VisionFive2 development= board, which does not support the *CMO* instruction set.=C2=A0 There are m= any functions in *DwEmmcDxe.c* that call Cache operations. For example, the= *DwEmmcReadBlockData* function below calls *WriteBackDataCacheRange* (). EFI_STATUS *DwEmmcReadBlockData* ( IN EFI_MMC_HOST_PROTOCOL=C2=A0 =C2=A0 =C2=A0*This, IN EFI_LBA=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Lba, IN UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Length, IN UINT32*=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0Buffer ) { ....... *WriteBackDataCacheRange* (gpIdmacDesc, DescPages * EFI_PAGE_SIZE); StartDma (Length); Status =3D SendCommand (mDwEmmcCommand, mDwEmmcArgument); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to read data, mDwEmmcCommand:%x, mDwEmmcArgume= nt:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); goto out; } out: // Restore Tpl gBS->RestoreTPL (Tpl); return Status; } Initially, I didn't set *PcdRiscVFeatureOverride* , so I got an illegal ins= truction exception. Then I set my *PcdRiscVFeatureOverride* to *0xFFFFFFFFF= FFFFFFE* to avoid using the *CMO* instruction set, and I got an *ASSERT*. Most cross-platform driver codes may call Cache management operations. Modi= fying these driver codes may cost a lot, and I think we may need some bette= r way than ASSERT. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113404): https://edk2.groups.io/g/devel/message/113404 Mute This Topic: https://groups.io/mt/103150435/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --XH4kL1InApQS9N2MyTqh Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Hi, all
I`m yangcheng, and I found this bug when using the edk2-platfo= rms/Silicon/Synopsys/DesignWare/Drivers/DwEmmcDxe driver on my Vis= ionFive2 development board, which does not support the CMO= instruction set.  There are many functions in DwEmmcDxe.c that call Cache operations. For example, the DwEmmcReadBlockD= ata function below calls WriteBackDataCacheRange(= ).
 
EFI_STATUS
DwEmmcReadBlockData (
  IN EFI_MMC_HOST_PROTOCOL     *This,
  IN EFI_LBA              &nbs= p;     Lba,
  IN UINTN               =       Length,
  IN UINT32*              &nbs= p;    Buffer
  )
{
 
  .......
 
  WriteBackDataCacheRange (gpIdmacDesc, DescPage= s * EFI_PAGE_SIZE);
  StartDma (Length);
 
  Status =3D SendCommand (mDwEmmcCommand, mDwEmmcArgument);
  if (EFI_ERROR (Status)) {
    DEBUG ((DEBUG_ERROR, "Failed to read data, mDwEmmcComman= d:%x, mDwEmmcArgument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, St= atus));
    goto out;
  }
out:
  // Restore Tpl
  gBS->RestoreTPL (Tpl);
  return Status;
}
 
Initially, I didn't set PcdRiscVFeatureOverride, so I= got an illegal instruction exception. Then I set my PcdRiscVFeatur= eOverride to 0xFFFFFFFFFFFFFFFE to avoid using th= e CMO instruction set, and I got an ASSERT. 

Most cross-platform driver codes may call Cache managem= ent operations. Modifying these driver codes may cost a lot, and I think we= may need some better way than ASSERT.

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#113404) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--XH4kL1InApQS9N2MyTqh--