From nobody Wed Nov 27 00:39:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=samsung.com ARC-Seal: i=1; a=rsa-sha256; t=1702045108; cv=none; d=zohomail.com; s=zohoarc; b=SlcU9tVMuIj7AO38ykMW2L7CBUzkQJDa/SKa7S74pHT966Co4PUlmYMrsjDFxbk2r2JuVirfVaJQCnmu19nBcSUucKSfc3iho5iX+jh0ypXAerEbsBafKm/+bb4JLyZjAxQyqvtwIAJwMlZxOW37peIj6SaIsHz/MzSYhdEaoII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702045108; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=UJAwXbUBpNhblGN3NC7suRaBoeMvvD3zzXXDfL7xeT0=; b=mFlkhmF1aIClr03thltmRA/iYrwkRtFG5shWFhDCm54h/zLrJCrqzPmVgOXiNl3mqphKEU3JA2wvbf6FVAkVnf0tTDAFUM4vmwc6ukEgxcsFj4O6QzD46fpcn0YX3CRx9Miy6ENJDZh29i1VsfIlniCjaQY1f72Lu54MdHFjgog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170204510859079.47133158499685; Fri, 8 Dec 2023 06:18:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBbgE-0005uH-Vc; Fri, 08 Dec 2023 09:18:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBU7Z-0005ua-Pz for qemu-devel@nongnu.org; Fri, 08 Dec 2023 01:13:58 -0500 Received: from mailout3.samsung.com ([203.254.224.33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBU7V-0003lj-7R for qemu-devel@nongnu.org; Fri, 08 Dec 2023 01:13:57 -0500 Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20231208061350epoutp03e8c4c9bd66fd9ce01f0519c72daf6c8f~exo-450bq2769227692epoutp03V for ; Fri, 8 Dec 2023 06:13:50 +0000 (GMT) Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20231208061350epcas2p1dd29736baa2b23b4c52eb94284c3281e~exo-hdyrK0517805178epcas2p1U; Fri, 8 Dec 2023 06:13:50 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.97]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4SmgnR2W9Xz4x9Pw; Fri, 8 Dec 2023 06:13:47 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id F5.C3.10006.B04B2756; Fri, 8 Dec 2023 15:13:31 +0900 (KST) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20231208061350epoutp03e8c4c9bd66fd9ce01f0519c72daf6c8f~exo-450bq2769227692epoutp03V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1702016030; bh=UJAwXbUBpNhblGN3NC7suRaBoeMvvD3zzXXDfL7xeT0=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=fC2PQawvSv52r71yzC5p88+Ip+AZeuhurcGhfCYlL1+kBHz/9kXpyWZQPyJfaAd8W bDhiA+s7b5c2FjyxJE4TV1SfeLfA8/gTy3DVxvQDzWgAOD7hqtYrFIxR2oFth0l37C TE+8kz6QTgEmiO4vzGDmv7eJISRuz8XcygUC6Ecs= X-AuditID: b6c32a45-3ebfd70000002716-c3-6572b40bd01a Mime-Version: 1.0 Subject: [PATCH 1/3] hw/ufs: Support for Zoned UFS From: Daejun Park To: Jeuk Kim , "pbonzini@redhat.com" , "fam@euphon.net" , "qemu-devel@nongnu.org" CC: JinHwan Park , Seokhwan Kim , Yonggil Song X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20231208061330epcms2p2f742a2d517b6836eca695a9b59bd109c@epcms2p2> Date: Fri, 08 Dec 2023 15:13:30 +0900 X-CMS-MailID: 20231208061330epcms2p2f742a2d517b6836eca695a9b59bd109c Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnk+LIzCtJLcpLzFFi42LZdljTQpd7S1GqwcPjmhYvD2laXNl/ntHi /tZrjBb9/9pZLPZv+8dqcbx3B4vFqo65jBZTzx9hcuDw+HGunc3jybXNTB7v911l8+jbsoox gCUq2yYjNTEltUghNS85PyUzL91WyTs43jne1MzAUNfQ0sJcSSEvMTfVVsnFJ0DXLTMH6Awl hbLEnFKgUEBicbGSvp1NUX5pSapCRn5xia1SakFKToF5gV5xYm5xaV66Xl5qiZWhgYGRKVBh QnZGz+ELLAXL9jNWPH39kq2BcWcrYxcjJ4eEgInE2SWfmboYuTiEBHYwSly/toali5GDg1dA UOLvDmGQGmEBI4knbxYzg9hCAkoS6y/OYoeI60ncergGbA6bgI7E9BP3weIiAqsYJR5NkgSx mQUqJbbPvQm1i1diRvtTFghbWmL78q1gcU4BP4klPycyQcQ1JH4s62WGsEUlbq5+yw5jvz82 H2qOiETrvbNQNYISD37uhopLStyeuwmqPl/i/5XlUHaNxLYD86BsfYlrHRvBbuAV8JW4d3Ui 2BwWAVWJ16vvskHUuEg0fPzFCHG/vMT2t3OYQUHCLKApsX6XPogpIaAsceQWC0QFn0TH4b/s MB82bPyNlb1j3hOoD9Uk1v1czzSBUXkWIpxnIdk1C2HXAkbmVYxiqQXFuempxUYFhvDITc7P 3cQITpFarjsYJ7/9oHeIkYmD8RCjBAezkghvzvn8VCHelMTKqtSi/Pii0pzU4kOMpkBfTmSW Ek3OBybpvJJ4QxNLAxMzM0NzI1MDcyVx3nutc1OEBNITS1KzU1MLUotg+pg4OKUamEwmaD+3 f/2YjUuwWWFil/y573tfqqbpCu16acyazvyheZuolgjbkj//99aYpNwWNPOuOiv3xOzWFNEt f2aK16mxTxLo7L3zQro0vOIrt2nkX9Y3DHVNGx+m5+8qjZIP2Fw3WZlhlsL/yemtF3blLhB/ YGFY23l4/duduZ7TUyce+ZyvdSSvbjfvwt0rRa2yN01sPupdqdW5vY7hzYzS6dy7vzMIfQgX Y+5pvsZeYfwy38PKq+bV7tKu7Rn/bTbWfg/eIKz4SHKhdvffQ2/YS90yw2RVWrglZoXnx7WZ hn69cj9d9G9W7vLKPrPDzOvV2GIn6aQamW2ySJdjFHXV3eMftEg/KuZZ+6dipf9KLMUZiYZa zEXFiQADs+yAGgQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba References: <20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.254.224.33; envelope-from=daejun7.park@samsung.com; helo=mailout3.samsung.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 08 Dec 2023 09:17:30 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: daejun7.park@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @samsung.com) X-ZM-MESSAGEID: 1702045109540100001 This patch enables zoned ufs support. By setting the LU parameter, each LU can be a host-managed zoned device. This patch manages the zone condition and write pointer of each zone for a zoned LU. It supports the report zones and reset write pointer commands for Zoned LUs. Signed-off-by: Daejun Park Reviewed-by: Jeuk Kim --- hw/ufs/lu.c | 616 ++++++++++++++++++++++++++++++++++++++++++++ hw/ufs/ufs.c | 6 +- hw/ufs/ufs.h | 32 +++ include/block/ufs.h | 31 +++ 4 files changed, 684 insertions(+), 1 deletion(-) diff --git a/hw/ufs/lu.c b/hw/ufs/lu.c index 81bfff9b4e..e709b75f38 100644 --- a/hw/ufs/lu.c +++ b/hw/ufs/lu.c @@ -20,6 +20,7 @@ #include "ufs.h" =20 #define SCSI_COMMAND_FAIL (-1) +#define REPORT_ZONES_DESC_HD_SIZE (64) =20 static void ufs_build_upiu_sense_data(UfsRequest *req, uint8_t *sense, uint32_t sense_len) @@ -59,6 +60,79 @@ static void ufs_build_scsi_response_upiu(UfsRequest *req= , uint8_t *sense, status, data_segment_length); } =20 +static inline uint32_t ufs_zone_idx(UfsLu *lu, uint64_t lba) +{ + return lba / lu->zone_desc.zone_size; +} + +static inline UfsZoneState *ufs_get_zone_by_lba(UfsLu *lu, uint64_t lba) +{ + uint32_t zone_idx =3D ufs_zone_idx(lu, lba); + + if (zone_idx >=3D lu->zone_desc.nr_zones) { + return NULL; + } + + return &lu->zone_array[zone_idx]; +} + +static void ufs_assign_zone_cond(UfsLu *lu, UfsZoneState *zone, + UfsZoneCond new_cond) +{ + switch (zone->cond) { + case ZONE_COND_IMPLICIT_OPEN: + case ZONE_COND_EXPLICIT_OPEN: + lu->zone_desc.nr_open--; + break; + case ZONE_COND_CLOSED: + case ZONE_COND_FULL: + break; + default: + break; + } + + zone->cond =3D new_cond; + + switch (new_cond) { + case ZONE_COND_EMPTY: + zone->wp =3D zone->start; + break; + case ZONE_COND_IMPLICIT_OPEN: + case ZONE_COND_EXPLICIT_OPEN: + lu->zone_desc.nr_open++; + break; + case ZONE_COND_CLOSED: + case ZONE_COND_FULL: + case ZONE_COND_READ_ONLY: + break; + default: + break; + } +} + +static inline uint64_t ufs_zone_wr_boundary(UfsLu *lu, UfsZoneState *zone) +{ + return zone->start + lu->zone_desc.zone_cap; +} + +static int ufs_full_zone(UfsLu *lu, UfsZoneState *zone) +{ + switch (zone->cond) { + case ZONE_COND_IMPLICIT_OPEN: + case ZONE_COND_EXPLICIT_OPEN: + ufs_assign_zone_cond(lu, zone, ZONE_COND_FULL); + return 0; + + case ZONE_COND_EMPTY: + case ZONE_COND_CLOSED: + case ZONE_COND_READ_ONLY: + case ZONE_COND_FULL: + case ZONE_COND_OFFLINE: + default: + return SCSI_COMMAND_FAIL; + } +} + static void ufs_scsi_command_complete(SCSIRequest *scsi_req, size_t resid) { UfsRequest *req =3D scsi_req->hba_private; @@ -81,6 +155,29 @@ static QEMUSGList *ufs_get_sg_list(SCSIRequest *scsi_re= q) return req->sg; } =20 +static int ufs_open_zone(UfsLu *lu, UfsZoneState *zone) +{ + switch (zone->cond) { + case ZONE_COND_EMPTY: + case ZONE_COND_CLOSED: + if (lu->zone_desc.nr_open >=3D lu->zone_desc.max_open) { + return SCSI_COMMAND_FAIL; + } + ufs_assign_zone_cond(lu, zone, ZONE_COND_IMPLICIT_OPEN); + return 0; + + case ZONE_COND_IMPLICIT_OPEN: + case ZONE_COND_EXPLICIT_OPEN: + return 0; + + case ZONE_COND_FULL: + case ZONE_COND_READ_ONLY: + case ZONE_COND_OFFLINE: + default: + return SCSI_COMMAND_FAIL; + } +} + static const struct SCSIBusInfo ufs_scsi_info =3D { .tcq =3D true, .max_target =3D 0, @@ -190,6 +287,430 @@ static int ufs_emulate_wlun_inquiry(UfsRequest *req, = uint8_t *outbuf, =20 return SCSI_INQUIRY_LEN; } +static int ufs_emulate_zbc_vpd_page(UfsLu *lu, UfsRequest *req, uint8_t *o= utbuf, + uint32_t outbuf_len) +{ + uint8_t page_code =3D req->req_upiu.sc.cdb[2]; + int start, buflen =3D 0; + + outbuf[buflen++] =3D TYPE_ZBC; + outbuf[buflen++] =3D page_code; + outbuf[buflen++] =3D 0x00; + outbuf[buflen++] =3D 0x00; + start =3D buflen; + + switch (page_code) { + case 0x00: /* Supported page codes, mandatory */ + { + outbuf[buflen++] =3D 0x00; /* list of supported pages (this page) = */ + outbuf[buflen++] =3D 0x87; /* mode page policy */ + outbuf[buflen++] =3D 0xb1; /* block device characteristics */ + outbuf[buflen++] =3D 0xb6; /* ZBC device characteristics */ + break; + } + case 0xb6: /* ZBC device characteristics */ + { + outbuf[buflen++] =3D 0x01; /* Host aware zoned block device model = */ + /* reserved */ + outbuf[buflen++] =3D 0x00; + outbuf[buflen++] =3D 0x00; + outbuf[buflen++] =3D 0x00; + + /* optimal number of open sequential write preferred zones */ + stl_be_p(&outbuf[buflen], 0xffffffff); + buflen +=3D 4; + + /* optimal number of non-seq. written seq. write preferred zones = */ + stl_be_p(&outbuf[buflen], 0xffffffff); + buflen +=3D 4; + + /* maximum number of open sequential write required zones */ + if (lu->zone_desc.max_open) { + stl_be_p(&outbuf[buflen], lu->zone_desc.max_open); + buflen +=3D 4; + } + + /* reserved */ + outbuf[buflen++] =3D 0x00; + outbuf[buflen++] =3D 0x00; + outbuf[buflen++] =3D 0x00; + break; + } + default: + return SCSI_COMMAND_FAIL; + } + /* done with EVPD */ + assert(buflen - start <=3D 255); + outbuf[start - 1] =3D buflen - start; + return buflen; +} + +static int ufs_scsi_emulate_zbc_in(UfsLu *lu, UfsRequest *req, uint8_t *ou= tbuf) +{ + uint8_t *cdb =3D req->req_upiu.sc.cdb; + uint64_t zone_start_lba, lba, + max_lba =3D be64_to_cpu(lu->unit_desc.logical_block_count); + uint32_t alloc_len, rep_opts, buf_offset; + bool partial; + unsigned int rep_max_zones, num_zones =3D 0; + UfsZoneState *zone; + + if (cdb[1] !=3D ZI_REPORT_ZONES) { + return SCSI_COMMAND_FAIL; + } + + zone_start_lba =3D ldq_be_p(&cdb[2]); + alloc_len =3D ldl_be_p(&cdb[10]); + + if (alloc_len =3D=3D 0) { + return 0; + } + rep_opts =3D cdb[14] & 0x3f; + partial =3D cdb[14] & 0x80; + + if (zone_start_lba > max_lba) { + return SCSI_COMMAND_FAIL; + } + + rep_max_zones =3D alloc_len / REPORT_ZONES_DESC_HD_SIZE; + buf_offset =3D REPORT_ZONES_DESC_HD_SIZE; + + for (lba =3D zone_start_lba; lba < max_lba; lba =3D zone->start + zone= ->size) { + zone =3D ufs_get_zone_by_lba(lu, lba); + if (!zone) { + break; + } + + switch (rep_opts) { + case 0x00: + /* All zones */ + break; + case 0x01: + /* Empty zones */ + if (zone->cond !=3D ZONE_COND_EMPTY) { + continue; + } + break; + case 0x02: + /* Implicit open zones */ + if (zone->cond !=3D ZONE_COND_IMPLICIT_OPEN) { + continue; + } + break; + case 0x03: + /* Explicit open zones */ + if (zone->cond !=3D ZONE_COND_EXPLICIT_OPEN) { + continue; + } + break; + case 0x04: + /* Closed zones */ + if (zone->cond !=3D ZONE_COND_CLOSED) { + continue; + } + break; + case 0x05: + /* Full zones */ + if (zone->cond !=3D ZONE_COND_FULL) { + continue; + } + break; + case 0x06: + case 0x07: + case 0x10: + /* + * Read-only, offline, reset WP recommended are + * not emulated: no zones to report; + */ + continue; + case 0x11: + /* non-seq-resource set */ + break; + case 0x3e: + /* All zones except gap zones. */ + break; + case 0x3f: + /* Not write pointer (conventional) zones */ + break; + default: + return SCSI_COMMAND_FAIL; + } + + if (num_zones < rep_max_zones) { + /* Fill zone descriptor */ + outbuf[0 + buf_offset] =3D zone->type; + outbuf[1 + buf_offset] =3D zone->cond << 4; + + stq_be_p(&outbuf[8 + buf_offset], zone->size); + stq_be_p(&outbuf[16 + buf_offset], zone->start); + stq_be_p(&outbuf[24 + buf_offset], zone->wp); + buf_offset +=3D REPORT_ZONES_DESC_HD_SIZE; + } + + if (partial && num_zones >=3D rep_max_zones) { + break; + } + + num_zones++; + } + + /* Report header */ + /* Zone list length. */ + stl_be_p(&outbuf[0], num_zones * REPORT_ZONES_DESC_HD_SIZE); + /* Maximum LBA */ + stq_be_p(&outbuf[8], be64_to_cpu(lu->unit_desc.logical_block_count) - = 1); + /* Zone starting LBA granularity. */ + if (lu->zone_desc.zone_cap < lu->zone_desc.zone_size) { + stq_be_p(&outbuf[16], lu->zone_desc.zone_size); + } + + return buf_offset; +} + +static void ufs_reset_write_pointer_zone(UfsLu *lu, UfsZoneState *zone) +{ + switch (zone->cond) { + case ZONE_COND_EMPTY: + /* nothing to do */ + break; + case ZONE_COND_IMPLICIT_OPEN: + case ZONE_COND_EXPLICIT_OPEN: + case ZONE_COND_READ_ONLY: + case ZONE_COND_OFFLINE: + /* ignore reset write pointer */ + break; + case ZONE_COND_CLOSED: + case ZONE_COND_FULL: + ufs_assign_zone_cond(lu, zone, ZONE_COND_EMPTY); + break; + default: + break; + } +} + +static void ufs_reset_write_pointer_all(UfsLu *lu) +{ + unsigned int i; + + for (i =3D 0; i < lu->zone_desc.nr_zones; i++) { + ufs_reset_write_pointer_zone(lu, &lu->zone_array[i]); + } +} + +static int ufs_scsi_emulate_zbc_out(UfsLu *lu, UfsRequest *req) +{ + uint8_t *cdb =3D req->req_upiu.sc.cdb; + uint64_t zone_start_lba, + max_lba =3D be64_to_cpu(lu->unit_desc.logical_block_count); + UfsZoneState *zone; + + switch (cdb[1]) { + case ZO_CLOSE_ZONE: + break; + case ZO_FINISH_ZONE: { + zone_start_lba =3D ldq_be_p(&cdb[2]); + + if (zone_start_lba > max_lba) { + /* overflow lba range */ + return SCSI_COMMAND_FAIL; + } + + zone =3D ufs_get_zone_by_lba(lu, zone_start_lba); + + if (zone_start_lba !=3D zone->start) { + /* invalid field error */ + return SCSI_COMMAND_FAIL; + } + + if (ufs_full_zone(lu, zone)) { + /* fail to finish zone */ + return SCSI_COMMAND_FAIL; + } + break; + } + case ZO_OPEN_ZONE: + /* TODO: support open zone command */ + break; + + case ZO_RESET_WRITE_POINTER: { + bool all =3D cdb[14] & 0x01; + + if (all) { + ufs_reset_write_pointer_all(lu); + return 0; + } + + zone_start_lba =3D ldq_be_p(&cdb[2]); + + if (zone_start_lba > max_lba) { + /* overflow lba range */ + return SCSI_COMMAND_FAIL; + } + + zone =3D ufs_get_zone_by_lba(lu, zone_start_lba); + + if ((zone->cond =3D=3D ZONE_COND_READ_ONLY) || + (zone->cond =3D=3D ZONE_COND_OFFLINE)) + return SCSI_COMMAND_FAIL; + + if (zone_start_lba !=3D zone->start) { + /* invalid field error */ + return SCSI_COMMAND_FAIL; + } + + ufs_reset_write_pointer_zone(lu, zone); + break; + } + default: + return SCSI_COMMAND_FAIL; + } + + return 0; +} + +static int ufs_check_zone_state_for_write(UfsZoneState *zone) +{ + switch (zone->cond) { + case ZONE_COND_EMPTY: + case ZONE_COND_IMPLICIT_OPEN: + case ZONE_COND_EXPLICIT_OPEN: + case ZONE_COND_CLOSED: + return 0; + + case ZONE_COND_FULL: + case ZONE_COND_READ_ONLY: + case ZONE_COND_OFFLINE: + default: + return SCSI_COMMAND_FAIL; + } +} + +/* Unaligned Write fail */ +const struct SCSISense sense_code_UNALIGNED_WRITE =3D { .key =3D ILLEGAL_R= EQUEST, + .asc =3D 0x21, + .ascq =3D 0x04 }; + +/* Insufficient zone resource fail */ +const struct SCSISense sense_code_INSUFFICENT_ZONE_RESOURCES =3D { + .key =3D DATA_PROTECT, .asc =3D 0x0C, .ascq =3D 0x12 +}; + + +static int ufs_check_zone_write(UfsLu *lu, UfsZoneState *zone, uint64_t lb= a, + uint32_t len) +{ + if (ufs_check_zone_state_for_write(zone)) { + return SCSI_COMMAND_FAIL; + } + + if (unlikely((lba + len) > ufs_zone_wr_boundary(lu, zone))) { + return SCSI_COMMAND_FAIL; + } + + return 0; +} + +static UfsReqResult ufs_emulate_zbc_cmd(UfsLu *lu, UfsRequest *req) +{ + g_autofree uint8_t *outbuf =3D NULL; + uint8_t sense_buf[UFS_SENSE_SIZE]; + uint8_t scsi_status; + int len =3D 0; + + switch (req->req_upiu.sc.cdb[0]) { + case WRITE_6: + case WRITE_10: + scsi_build_sense(sense_buf, SENSE_CODE(INVALID_FIELD)); + scsi_status =3D CHECK_CONDITION; + break; + case WRITE_16: { + uint64_t lba =3D ldq_be_p(&req->req_upiu.sc.cdb[2]); + uint32_t req_len =3D ldl_be_p(&req->req_upiu.sc.cdb[10]); + UfsZoneState *zone =3D ufs_get_zone_by_lba(lu, lba); + + if (unlikely(lba !=3D zone->wp)) { + /* unaligned write error */ + scsi_build_sense(sense_buf, SENSE_CODE(UNALIGNED_WRITE)); + scsi_status =3D CHECK_CONDITION; + break; + } + + len =3D ufs_check_zone_write(lu, zone, lba, req_len); + if (len =3D=3D SCSI_COMMAND_FAIL) { + scsi_build_sense(sense_buf, SENSE_CODE(INVALID_FIELD)); + scsi_status =3D CHECK_CONDITION; + break; + } + + len =3D ufs_open_zone(lu, zone); + if (len =3D=3D SCSI_COMMAND_FAIL) { + scsi_build_sense(sense_buf, SENSE_CODE(INSUFFICENT_ZONE_RESOUR= CES)); + scsi_status =3D CHECK_CONDITION; + break; + } + + zone->wp +=3D req_len; + + if (zone->wp =3D=3D ufs_zone_wr_boundary(lu, zone)) { + ufs_full_zone(lu, zone); + } + return UFS_REQUEST_NO_COMPLETE; + } + case ZBC_IN: + outbuf =3D g_new0(uint8_t, req->data_len + REPORT_ZONES_DESC_HD_SI= ZE); + len =3D ufs_scsi_emulate_zbc_in(lu, req, outbuf); + if (len =3D=3D SCSI_COMMAND_FAIL) { + scsi_build_sense(sense_buf, SENSE_CODE(INVALID_FIELD)); + scsi_status =3D CHECK_CONDITION; + } else { + scsi_status =3D GOOD; + } + break; + case ZBC_OUT: + len =3D ufs_scsi_emulate_zbc_out(lu, req); + if (len =3D=3D SCSI_COMMAND_FAIL) { + scsi_build_sense(sense_buf, SENSE_CODE(INVALID_FIELD)); + scsi_status =3D CHECK_CONDITION; + } else { + scsi_status =3D GOOD; + } + break; + case INQUIRY: + /* bypass standard inquiry */ + if (!(req->req_upiu.sc.cdb[1] & 0x1)) { + return UFS_REQUEST_NO_COMPLETE; + } + /* processing only ZBC related page codes */ + if (!(req->req_upiu.sc.cdb[2] =3D=3D 0x00) && + !(req->req_upiu.sc.cdb[2] =3D=3D 0xb6)) { + return UFS_REQUEST_NO_COMPLETE; + } + /* Vital product data */ + outbuf =3D g_new0(uint8_t, UFS_BLOCK_SIZE); + len =3D ufs_emulate_zbc_vpd_page(lu, req, outbuf, UFS_BLOCK_SIZE); + if (len =3D=3D SCSI_COMMAND_FAIL) { + scsi_build_sense(sense_buf, SENSE_CODE(INVALID_FIELD)); + scsi_status =3D CHECK_CONDITION; + } else { + scsi_status =3D GOOD; + } + break; + default: + return UFS_REQUEST_NO_COMPLETE; + } + + len =3D MIN(len, (int)req->data_len); + if (scsi_status =3D=3D GOOD && len > 0 && + dma_buf_read(outbuf, len, NULL, req->sg, MEMTXATTRS_UNSPECIFIED) != =3D + MEMTX_OK) { + return UFS_REQUEST_FAIL; + } + + ufs_build_scsi_response_upiu(req, sense_buf, sizeof(sense_buf), len, + scsi_status); + + return UFS_REQUEST_SUCCESS; +} =20 static UfsReqResult ufs_emulate_scsi_cmd(UfsLu *lu, UfsRequest *req) { @@ -252,6 +773,13 @@ static UfsReqResult ufs_process_scsi_cmd(UfsLu *lu, Uf= sRequest *req) { uint8_t task_tag =3D req->req_upiu.header.task_tag; =20 + if (lu->zone_enabled) { + UfsReqResult result =3D ufs_emulate_zbc_cmd(lu, req); + /* UFS_REQUEST_NO_COMPLETE continues command processing */ + if (result !=3D UFS_REQUEST_NO_COMPLETE) { + return result; + } + } /* * Each ufs-lu has its own independent virtual SCSI bus. Therefore, we= can't * use scsi_target_emulate_report_luns() which gets all lu information= over @@ -277,6 +805,11 @@ static UfsReqResult ufs_process_scsi_cmd(UfsLu *lu, Uf= sRequest *req) static Property ufs_lu_props[] =3D { DEFINE_PROP_DRIVE("drive", UfsLu, conf.blk), DEFINE_PROP_UINT8("lun", UfsLu, lun, 0), + DEFINE_PROP_BOOL("zoned", UfsLu, params.zoned, false), + DEFINE_PROP_SIZE("zoned.zone_size", UfsLu, params.zone_size, + UFS_DEFAULT_ZONE_SIZE /* 128MiB */), + DEFINE_PROP_SIZE("zoned.zone_capacity", UfsLu, params.zone_cap, 0), + DEFINE_PROP_UINT32("zoned.max_open", UfsLu, params.zone_max_open, 6), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -310,12 +843,84 @@ void ufs_init_wlu(UfsLu *wlu, uint8_t wlun) wlu->scsi_op =3D &ufs_emulate_scsi_cmd; } =20 +static void ufs_zoned_init_state(UfsLu *lu) +{ + uint64_t start =3D 0, zone_size =3D lu->zone_desc.zone_size; + uint64_t nblocks =3D be64_to_cpu(lu->unit_desc.logical_block_count); + UfsZoneState *zone; + int i; + + lu->zone_array =3D g_new0(UfsZoneState, lu->zone_desc.nr_zones); + zone =3D lu->zone_array; + + for (i =3D 0; i < lu->zone_desc.nr_zones; i++, zone++) { + if (start + zone_size > nblocks) { + zone_size =3D nblocks - start; + } + zone->id =3D i; + /* SEQUENTIAL WRITE REQUIRED */ + zone->type =3D 0x2; + zone->cond =3D ZONE_COND_EMPTY; + zone->start =3D start; + zone->size =3D zone_size; + zone->wp =3D start; + + start +=3D zone_size; + } +} + +static void ufs_lu_init_zoned(UfsLu *lu) +{ + ufs_zoned_init_state(lu); + + lu->zone_desc.nr_open =3D 0; + lu->zone_desc.max_open =3D lu->params.zone_max_open; + lu->zone_enabled =3D true; + + /* Host-managed zoned block device */ + lu->scsi_dev->type =3D TYPE_ZBC; +} + +static int ufs_lu_zoned_check_calc_geometry(UfsLu *lu, Error **errp) +{ + uint64_t zone_size =3D lu->params.zone_size, zone_cap =3D lu->params.z= one_cap, + nr_blocks; + + if (!zone_cap) { + zone_cap =3D zone_size; + } + + if (zone_cap > zone_size) { + error_setg(errp, + "zone capacity %" PRIu64 "B exceeds " + "zone size %" PRIu64 "B", + zone_cap, zone_size); + return -1; + } + + nr_blocks =3D be64_to_cpu(lu->unit_desc.logical_block_count); + lu->zone_desc.zone_size =3D zone_size / UFS_BLOCK_SIZE; + lu->zone_desc.zone_cap =3D zone_cap / UFS_BLOCK_SIZE; + lu->zone_desc.nr_zones =3D DIV_ROUND_UP(nr_blocks, lu->zone_desc.zone_= size); + + if (!lu->zone_desc.nr_zones) { + error_setg(errp, + "insufficient drive capacity, must be at least the size= " + "of one zone (%" PRIu64 "B)", + zone_size); + return -1; + } + + return 0; +} + static void ufs_init_lu(UfsLu *lu) { BlockBackend *blk =3D lu->conf.blk; int64_t brdv_len =3D blk_getlength(blk); =20 memset(&lu->unit_desc, 0, sizeof(lu->unit_desc)); + lu->zone_enabled =3D false; lu->unit_desc.length =3D sizeof(UnitDescriptor); lu->unit_desc.descriptor_idn =3D UFS_QUERY_DESC_IDN_UNIT; lu->unit_desc.lu_enable =3D 0x01; @@ -408,6 +1013,13 @@ static void ufs_lu_realize(DeviceState *dev, Error **= errp) } =20 ufs_init_scsi_device(lu, blk, errp); + + if (lu->params.zoned) { + if (ufs_lu_zoned_check_calc_geometry(lu, errp)) { + return; + } + ufs_lu_init_zoned(lu); + } } =20 static void ufs_lu_unrealize(DeviceState *dev) @@ -418,6 +1030,10 @@ static void ufs_lu_unrealize(DeviceState *dev) object_unref(OBJECT(lu->scsi_dev)); lu->scsi_dev =3D NULL; } + if (lu->zone_enabled) { + /* release zoned ufs structure */ + g_free(lu->zone_array); + } } =20 static void ufs_lu_class_init(ObjectClass *oc, void *data) diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c index 68c5f1f6c9..15faa634e4 100644 --- a/hw/ufs/ufs.c +++ b/hw/ufs/ufs.c @@ -18,7 +18,11 @@ * -drive file=3D,if=3Dnone,id=3D * -device ufs,serial=3D,id=3D, \ * nutrs=3D,nutmrs=3D - * -device ufs-lu,drive=3D,bus=3D + * -device ufs-lu,drive=3D,bus=3D, \ + * zoned=3D, + * zoned.zone_size=3D, \ + * zoned.zone_capacity=3D, \ + * zoned.max_open=3D */ =20 #include "qemu/osdep.h" diff --git a/hw/ufs/ufs.h b/hw/ufs/ufs.h index 8fda94f4ef..205df4d7d2 100644 --- a/hw/ufs/ufs.h +++ b/hw/ufs/ufs.h @@ -15,6 +15,26 @@ #include "hw/scsi/scsi.h" #include "block/ufs.h" =20 +typedef struct UfsZoneState { + int id; + int type; + UfsZoneCond cond; + uint64_t start; + uint64_t size; + uint64_t wp; +} UfsZoneState; + +/* For Zoned Ufs */ +typedef struct UfsZoneDescriptor { + unsigned int zone_cap; + unsigned int zone_size; + unsigned int nr_zones; + unsigned int nr_open; + unsigned int max_open; +} UfsZoneDescriptor; + +#define UFS_DEFAULT_ZONE_SIZE (128 * MiB) + #define UFS_MAX_LUS 32 #define UFS_BLOCK_SIZE_SHIFT 12 #define UFS_BLOCK_SIZE (1 << UFS_BLOCK_SIZE_SHIFT) @@ -62,6 +82,13 @@ typedef struct UfsRequest { struct UfsLu; typedef UfsReqResult (*UfsScsiOp)(struct UfsLu *, UfsRequest *); =20 +typedef struct UfsLuParams { + bool zoned; + uint64_t zone_cap; + uint64_t zone_size; + uint32_t zone_max_open; +} UfsLuParams; + typedef struct UfsLu { DeviceState qdev; uint8_t lun; @@ -70,6 +97,11 @@ typedef struct UfsLu { SCSIDevice *scsi_dev; BlockConf conf; UfsScsiOp scsi_op; + /* For Zoned Ufs */ + UfsLuParams params; + bool zone_enabled; + UfsZoneDescriptor zone_desc; + UfsZoneState *zone_array; } UfsLu; =20 typedef struct UfsParams { diff --git a/include/block/ufs.h b/include/block/ufs.h index 0b6ec0814d..d4d81d7845 100644 --- a/include/block/ufs.h +++ b/include/block/ufs.h @@ -547,6 +547,37 @@ enum { UFS_MASK_OCS =3D 0x0F, }; =20 +/* enumeration names taken from table 26, zbcr05 */ +typedef enum UfsZoneCond { + ZBC_NOT_WRITE_POINTER =3D 0x0, + ZONE_COND_EMPTY =3D 0x1, + ZONE_COND_IMPLICIT_OPEN =3D 0x2, + ZONE_COND_EXPLICIT_OPEN =3D 0x3, + ZONE_COND_CLOSED =3D 0x4, + ZONE_COND_READ_ONLY =3D 0xd, + ZONE_COND_FULL =3D 0xe, + ZONE_COND_OFFLINE =3D 0xf, +} UfsZoneCond; + +/* + * ZBC_IN/OUT codes + */ + +#define ZBC_OUT 0x94 +#define ZBC_IN 0x95 + +typedef enum ZbcInCodes { + ZI_REPORT_ZONES =3D 0x00, + /* Support only ZI_REPORT_ZONES */ +} ZbcInCodes; + +typedef enum ZbcOutCodes { + ZO_CLOSE_ZONE =3D 0x01, + ZO_FINISH_ZONE =3D 0x02, + ZO_OPEN_ZONE =3D 0x03, + ZO_RESET_WRITE_POINTER =3D 0x04, +} ZbcOutCodes; + /* * struct UfshcdSgEntry - UFSHCI PRD Entry * @addr: Physical address; DW-0 and DW-1. --=20 2.25.1 From nobody Wed Nov 27 00:39:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=samsung.com ARC-Seal: i=1; a=rsa-sha256; t=1702045097; cv=none; d=zohomail.com; s=zohoarc; b=nTBLmmFp86vLz/oDD0fcq6/UrKqRLvaREY3jNxh5tg3v2JfpB7pqWdQpSQ1JKAzXj3P4kLQjz99VIEds0GIAUtFu0j0xuhfAMN0gnCiwex1e7vmO8zmY5g+SUrJrQJrIO2SlhAoLRxX76+NymXASmuXm16YQLcTEO2Ueq3ew78s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702045097; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=/oUHa5D5McJvgpsJoL1q2msPaWi0JVoTytyZRDHtkBQ=; b=l0qwjSjOUYAqWQGIiJPufMj5O1Lcd0ZgeXq6VogWx25nVQmZ+cciKxewwOj4uOp3mqo39l7rcIEIK8AImRG+Cf4hoF568FC7CAGrk2AX7CpGn/MdTF4SP+CUvmJvjm+BD/6A4g2KyVU6ctfJt/fK3ZyIZJRFzY+atfnjpQjrpQA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702045097109745.5747313301405; Fri, 8 Dec 2023 06:18:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBbfw-0005pk-Lw; Fri, 08 Dec 2023 09:17:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBUFC-0007nl-EY for qemu-devel@nongnu.org; Fri, 08 Dec 2023 01:21:52 -0500 Received: from mailout2.samsung.com ([203.254.224.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBUF7-0000Q2-2U for qemu-devel@nongnu.org; Fri, 08 Dec 2023 01:21:50 -0500 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20231208062140epoutp02d5ab9467e42fa10d40fe86ab6b11125c~exv1SjWqc0059900599epoutp02e for ; Fri, 8 Dec 2023 06:21:40 +0000 (GMT) Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20231208062140epcas2p2857c08ad9ae41ce4296dd5b47d06c29c~exv03rONa0880008800epcas2p2J; Fri, 8 Dec 2023 06:21:40 +0000 (GMT) Received: from epsmgec2p1-new.samsung.com (unknown [182.195.36.91]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4SmgyW3T0Nz4x9Q1; Fri, 8 Dec 2023 06:21:39 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmgec2p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 80.FB.18994.3F5B2756; Fri, 8 Dec 2023 15:21:39 +0900 (KST) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20231208062140epoutp02d5ab9467e42fa10d40fe86ab6b11125c~exv1SjWqc0059900599epoutp02e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1702016500; bh=/oUHa5D5McJvgpsJoL1q2msPaWi0JVoTytyZRDHtkBQ=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=nj3XhyxjFTRMQS+9oVlXjIZTbuGLQlDOHmmC50SNjcoQSUILLmgDW0QHkI+QQNbXe Cg4/hUlXc2F0174lS5sHMh0So+Tb8dhovOKP3/J7dL/NoT+likIsqbjAjlFwapUe2/ 6FTewrkQaqIQ+wVpg5ILDXSfeq7lUzSWmO3e9LC4= X-AuditID: b6c32a4d-9f7ff70000004a32-fb-6572b5f3abc6 Mime-Version: 1.0 Subject: [PATCH 2/3] hw/scsi: add mode sense support for zbc device From: Daejun Park To: "pbonzini@redhat.com" , "fam@euphon.net" , Jeuk Kim , "qemu-devel@nongnu.org" , Daejun Park CC: Seokhwan Kim , Yonggil Song , JinHwan Park X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20231208062038epcms2p4d1783b8366059c392b0e8ea7a7eb4c9f@epcms2p4> Date: Fri, 08 Dec 2023 15:20:38 +0900 X-CMS-MailID: 20231208062038epcms2p4d1783b8366059c392b0e8ea7a7eb4c9f Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjk+LIzCtJLcpLzFFi42LZdljTTPfz1qJUg+bfkhYvD2larHoQbnFl /3lGi/tbrzFa9P9rZ7HYv+0fq8Xx3h0sFqs65jJaTD1/hMmB0+PHuXY2jyfXNjN5vN93lc2j b8sqxgCWqGybjNTElNQihdS85PyUzLx0WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFslF58AXbfM HKBTlBTKEnNKgUIBicXFSvp2NkX5pSWpChn5xSW2SqkFKTkF5gV6xYm5xaV56Xp5qSVWhgYG RqZAhQnZGRcb17MXtPFV9O9vYmpg/MzRxcjJISFgIvH51hnGLkYuDiGBPYwSK9fsYupi5ODg FRCU+LtDGKRGWMBZYtufs2wgtpCAksT6i7PYIeJ6ErcermEEsdkEdCSmn7jPDjJHROASo8TS 29vAGpgFKiWOXbjJCLGMV2JG+1MWCFtaYvvyrWBxTgE/iSU/JzJBxDUkfizrZYawRSVurn7L DmO/PzYfao6IROu9s1A1ghIPfu6GiktK3J67Cao+X+L/leVQdo3EtgPzoGx9iWsdG8Fu4BXw lej7/A3MZhFQlWhdsBVqpotE44Fv7BD3y0tsfzuHGRQmzAKaEut36YOYEgLKEkdusUBU8El0 HP7LDvNhw8bfWNk75j2B+lBNYt3P9UwTGJVnIQJ6FpJdsxB2LWBkXsUolVpQnJuemmxUYKib l1oOj9/k/NxNjOCEqeW7g/H1+r96hxiZOBgPMUpwMCuJ8Oacz08V4k1JrKxKLcqPLyrNSS0+ xGgK9OlEZinR5Hxgys4riTc0sTQwMTMzNDcyNTBXEue91zo3RUggPbEkNTs1tSC1CKaPiYNT qoHJ/+S3JT/2HK/f7Dx758pdx1ediMn4uKPumr7MBy/7jz2Op9fdmufC97r9Icu/+NCJ++Yt 0Opybvui/vb5mhUXYiYL3z/ieaFqmfAHa4OK3c5T45auEFBIa/wkzrxg8ZdVmjU9E3ODd0zg F3Rv3JIovnlRUTOznljXYp07H/cwTVmbX6bUMIdV5OWX/GPB3XdmcvWdmZR299LVq3UtN0/d ZKniqJP5zF6weO9Xcd+Nz5o5484ZlXM4m53x5vVf9b6iPF2h95ze2ZflehXnFBX6r6bIhbcJ B4erGV86OVv9QHSBX71xsfW7nkur596TvFJ3a7G0hm2qZMp9m8MzXq8st9HxL+z1UdtzadvW 31wpSizFGYmGWsxFxYkAYoMEKCEEAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba References: <20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.254.224.25; envelope-from=daejun7.park@samsung.com; helo=mailout2.samsung.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UPPERCASE_50_75=0.008 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 08 Dec 2023 09:17:30 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: daejun7.park@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @samsung.com) X-ZM-MESSAGEID: 1702045099277100004 This patch enables mode sense for zbc devices. Signed-off-by: Daejun Park --- hw/scsi/scsi-disk.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 6691f5edb8..f1ecb77317 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1083,11 +1083,14 @@ static int mode_sense_page(SCSIDiskState *s, int pa= ge, uint8_t **p_outbuf, int page_control) { static const int mode_sense_valid[0x3f] =3D { - [MODE_PAGE_VENDOR_SPECIFIC] =3D (1 << TYPE_DISK) | (1 << TY= PE_ROM), - [MODE_PAGE_HD_GEOMETRY] =3D (1 << TYPE_DISK), - [MODE_PAGE_FLEXIBLE_DISK_GEOMETRY] =3D (1 << TYPE_DISK), - [MODE_PAGE_CACHING] =3D (1 << TYPE_DISK) | (1 << TY= PE_ROM), - [MODE_PAGE_R_W_ERROR] =3D (1 << TYPE_DISK) | (1 << TY= PE_ROM), + [MODE_PAGE_VENDOR_SPECIFIC] =3D (1 << TYPE_DISK) | (1 << TY= PE_ROM) + | (1 << TYPE= _ZBC), + [MODE_PAGE_HD_GEOMETRY] =3D (1 << TYPE_DISK) | (1 << TY= PE_ZBC), + [MODE_PAGE_FLEXIBLE_DISK_GEOMETRY] =3D (1 << TYPE_DISK) | (1 << TY= PE_ZBC), + [MODE_PAGE_CACHING] =3D (1 << TYPE_DISK) | (1 << TY= PE_ROM) + | (1 << TYPE= _ZBC), + [MODE_PAGE_R_W_ERROR] =3D (1 << TYPE_DISK) | (1 << TY= PE_ROM) + | (1 << TYPE= _ZBC), [MODE_PAGE_AUDIO_CTL] =3D (1 << TYPE_ROM), [MODE_PAGE_CAPABILITIES] =3D (1 << TYPE_ROM), [MODE_PAGE_APPLE_VENDOR] =3D (1 << TYPE_ROM), --=20 2.25.1 From nobody Wed Nov 27 00:39:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=samsung.com ARC-Seal: i=1; a=rsa-sha256; t=1702045131; cv=none; d=zohomail.com; s=zohoarc; b=F/Yi5vjma3YtQo2kyeStK3c57esivh/lequ6bHMIA73wNMEMXdZx5ltbHv53+yYLWTUH2Mi4pXjk742ZBq5bYRVBEZdy/cPPDo86rZ6gHKHg6sZf58ksT1LlIRugh8GJlM4ZAVi+HaNOtBZ5RYNaPIRuW/5AGvOv+/JueC4M5AA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702045131; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=/VizRhPWdnwEHZarvVnucnLBlD129cCfPeJvOcB7GSg=; b=ToRdTVNN7v4CpnslNNfjLITH5m7rMTCQCyJdadlTm/3HGmZCMCu3CJEUDPJrvojHUneq5hRk9snuGMBYyPSU4rE0jdbhe2Y8nsjsIE7djVaLGjj83bimWXSm1PWLukD3oxK3QBb/nW+e8FJG9oi080VDAL5dJpd/ZnjpdfiHdno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702045131927985.9711977870793; Fri, 8 Dec 2023 06:18:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBbg7-0005sk-F0; Fri, 08 Dec 2023 09:18:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBUGX-0007ug-Kj for qemu-devel@nongnu.org; Fri, 08 Dec 2023 01:23:13 -0500 Received: from mailout4.samsung.com ([203.254.224.34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBUGR-0000oM-91 for qemu-devel@nongnu.org; Fri, 08 Dec 2023 01:23:13 -0500 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20231208062303epoutp0450b910a17627a0f8be3cdae0377a4a08~exxCqSt8t2409024090epoutp04P for ; Fri, 8 Dec 2023 06:23:03 +0000 (GMT) Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20231208062303epcas2p1713f4c6e37e394d013eea66e477cbec2~exxCIdft31119911199epcas2p1w; Fri, 8 Dec 2023 06:23:03 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.70]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Smh061bRfz4x9QD; Fri, 8 Dec 2023 06:23:02 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 94.E6.09607.646B2756; Fri, 8 Dec 2023 15:23:02 +0900 (KST) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20231208062303epoutp0450b910a17627a0f8be3cdae0377a4a08~exxCqSt8t2409024090epoutp04P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1702016583; bh=/VizRhPWdnwEHZarvVnucnLBlD129cCfPeJvOcB7GSg=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=WoCGe6H2MlUbRHy0N939vHSaf/H/uOn1jlfSj8AjF9J8TcD8mMTENDgLhPCu+amlD E5lS3GYMQ0oDiqNaPjDPBaOwb62K93U4gnRpNSUXIzOQu4URBnwX5JQnQGHcjWmKu4 9SFyHj5PdreTbFda7VjPKV+6yDHJeXmZmfzdz3AU= X-AuditID: b6c32a48-963ff70000002587-33-6572b646bdba Mime-Version: 1.0 Subject: [PATCH 3/3] tests/qtest: Add tests for Zoned UFS From: Daejun Park To: "thuth@redhat.com" , "lvivier@redhat.com" , Jeuk Kim , "pbonzini@redhat.com" , "qemu-devel@nongnu.org" , Daejun Park CC: Seokhwan Kim , Yonggil Song , JinHwan Park X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20231208062200epcms2p7de0f3ab428a85eff0280225dbd1b1f37@epcms2p7> Date: Fri, 08 Dec 2023 15:22:00 +0900 X-CMS-MailID: 20231208062200epcms2p7de0f3ab428a85eff0280225dbd1b1f37 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnk+LIzCtJLcpLzFFi42LZdljTVNdtW1GqwdHfHBYvD2larHoQbnF/ 6zVGi/5/7SwWnxqkLPZv+8dqcbx3B4vFqo65jBYrj9lYTD1/hMmBy+PJtc1MHu/3XWXz6Nuy ijGAOSrbJiM1MSW1SCE1Lzk/JTMv3VbJOzjeOd7UzMBQ19DSwlxJIS8xN9VWycUnQNctMwfo ECWFssScUqBQQGJxsZK+nU1RfmlJqkJGfnGJrVJqQUpOgXmBXnFibnFpXrpeXmqJlaGBgZEp UGFCdsaKL//YClY6VKxdeoutgfGBfhcjJ4eEgInErbdnmbsYuTiEBHYwStxdu5Cxi5GDg1dA UOLvDmGQGmEBS4kZU4+xgthCAkoS6y/OYoeI60nceriGEcRmE9CRmH7iPjvIHBGBZiaJ+63X mUESzAKVEscu3GSEWMYrMaP9KQuELS2xfflWsDingJ/Ekp8TmSDiGhI/lvUyQ9iiEjdXv2WH sd8fmw81R0Si9d5ZqBpBiQc/d0PFJSVuz90EVZ8v8f/Kcii7RmLbgXlQtr7EtY6NYDfwCvhK XHp8Fmwvi4CqxM1LX9lBfpcQcJE40sADcb68xPa3c5hBwswCmhLrd+lDVChLHLnFAlHBJ9Fx +C87zIMNG39jZe+Y9wTqQTWJdT/XM01gVJ6FCOdZSHbNQti1gJF5FaNYakFxbnpqsVGBCTxq k/NzNzGCU6SWxw7G2W8/6B1iZOJgPMQowcGsJMKbcz4/VYg3JbGyKrUoP76oNCe1+BCjKdCT E5mlRJPzgUk6ryTe0MTSwMTMzNDcyNTAXEmc917r3BQhgfTEktTs1NSC1CKYPiYOTqkGpuov J+8Gf53qqv2EP2Wava/M0hkNC+3/XY+sn7JNdxKf1NTdVyKqLsxwyzhj2P1AcvmXTzwiq1Z1 fg1b1Bl6IHR7R+TFsvXrdnyODF5rfUb8PveMOqsFBaaJ6VbpS7IEpm74tTnF2rE/dqOy8S7X 5I0vWwsPPJSPZ8+d5pkvoaHi/zBxioqE/eN69lXtl56a3qrpWdjOG7RTqvSgq5XLRYFde5kS tmy8df773KCg5wtfTV94u1/TyEzn5svXeefe+a7x6XtW/ebszfANktdyJf7Pmfp2fdfv91IM 7bOCclk3vNR6/f331qz6HVXv1HksNrUHZSuWZBv7rtS39d2qHrjviG81y02Dx91OgqVM95VY ijMSDbWYi4oTAVut9hsaBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba References: <20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.254.224.34; envelope-from=daejun7.park@samsung.com; helo=mailout4.samsung.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 08 Dec 2023 09:17:31 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: daejun7.park@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @samsung.com) X-ZM-MESSAGEID: 1702045134054100001 This patch includes the following tests Test VPD page and report zones Test write and unaligned write error Signed-off-by: Daejun Park Reviewed-by: Jeuk Kim --- tests/qtest/ufs-test.c | 178 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/tests/qtest/ufs-test.c b/tests/qtest/ufs-test.c index 5daf8c9c49..798035f45b 100644 --- a/tests/qtest/ufs-test.c +++ b/tests/qtest/ufs-test.c @@ -27,6 +27,11 @@ #define UTP_RESPONSE_UPIU_OFFSET 1024 #define UTP_PRDT_UPIU_OFFSET 2048 =20 +#define ZONE_SIZE (2 * 1024 * 1024) +#define MAX_OPEN_ZONE 6 +#define NUM_ZONES (TEST_IMAGE_SIZE / ZONE_SIZE) +#define REPORT_ZONES_DESC_HD_SIZE 64 + typedef struct QUfs QUfs; =20 struct QUfs { @@ -534,6 +539,160 @@ static void ufstest_read_write(void *obj, void *data,= QGuestAllocator *alloc) ufs_exit(ufs, alloc); } =20 +static void ufstest_zufs_init(void *obj, void *data, QGuestAllocator *allo= c) +{ + QUfs *ufs =3D obj; + const int test_lun =3D 2; + + uint8_t buf[4096] =3D { 0 }; + const uint8_t request_sense_cdb[UFS_CDB_SIZE] =3D { + REQUEST_SENSE, + 0x01, + 0x00, + 0x00, + }; + /* VPD 0x00 page */ + const uint8_t inquiry_vpd_00_cdb[UFS_CDB_SIZE] =3D { + INQUIRY, + 0x01, /* EVPD */ + 0x00, /* page code */ + 0x00, 0x40, /* length */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + /* VPD 0xb6 page */ + const uint8_t inquiry_vpd_b6_cdb[UFS_CDB_SIZE] =3D { + INQUIRY, 0x01, /* EVPD */ + 0xb6, /* page code */ + 0x00, 0x40, /* length */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + /* Report zones */ + const uint8_t report_zones_cdb[UFS_CDB_SIZE] =3D { + ZBC_IN, ZI_REPORT_ZONES, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* LBA */ + 0x00, 0x00, 0x02, 0x00, /* length */ + 0x00, 0x00 + }; + UtpTransferReqDesc utrd; + UtpUpiuRsp rsp_upiu; + uint32_t zone_list_len; + + ufs_init(ufs, alloc); + + /* Clear Unit Attention */ + ufs_send_scsi_command(ufs, 0, test_lun, request_sense_cdb, NULL, 0, bu= f, + sizeof(buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, CHECK_CONDITION); + + /* Inquiry VPD page: 0x00 */ + ufs_send_scsi_command(ufs, 0, test_lun, inquiry_vpd_00_cdb, NULL, 0, b= uf, + sizeof(buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + g_assert_cmpuint(buf[0], =3D=3D, TYPE_ZBC); + g_assert_cmpuint(buf[7], =3D=3D, 0xb6); + + /* Inquiry VPD page: 0xb6 */ + ufs_send_scsi_command(ufs, 0, test_lun, inquiry_vpd_b6_cdb, NULL, 0, b= uf, + sizeof(buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + g_assert_cmpuint(buf[0], =3D=3D, TYPE_ZBC); + /* ZBC device characteristics */ + g_assert_cmpuint(buf[1], =3D=3D, 0xb6); + /* Number of max open zones */ + g_assert_cmpuint(buf[19], =3D=3D, MAX_OPEN_ZONE); + + /* Report zones */ + ufs_send_scsi_command(ufs, 0, test_lun, report_zones_cdb, NULL, 0, buf, + sizeof(buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + zone_list_len =3D ldl_be_p(&buf[0]); + g_assert_cmpuint(zone_list_len, =3D=3D, REPORT_ZONES_DESC_HD_SIZE * NU= M_ZONES); + + ufs_exit(ufs, alloc); +} + +static void ufstest_zufs_write(void *obj, void *data, QGuestAllocator *all= oc) +{ + QUfs *ufs =3D obj; + uint8_t read_buf[4096] =3D { 0 }; + uint8_t write_buf[4096] =3D { 0 }; + const uint8_t read_capacity_cdb[UFS_CDB_SIZE] =3D { + /* allocation length 4096 */ + SERVICE_ACTION_IN_16, + SAI_READ_CAPACITY_16, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00 + }; + const uint8_t request_sense_cdb[UFS_CDB_SIZE] =3D { + REQUEST_SENSE, + }; + const uint8_t write_cdb[UFS_CDB_SIZE] =3D { + /* WRITE(16) to LBA 0, transfer length 1 */ + WRITE_16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 + }; + uint32_t block_size; + UtpTransferReqDesc utrd; + UtpUpiuRsp rsp_upiu; + const int test_lun =3D 2; + + ufs_init(ufs, alloc); + + /* Clear Unit Attention */ + ufs_send_scsi_command(ufs, 0, test_lun, request_sense_cdb, NULL, 0, + read_buf, sizeof(read_buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, CHECK_CONDITION); + + /* Read capacity */ + ufs_send_scsi_command(ufs, 0, test_lun, read_capacity_cdb, NULL, 0, + read_buf, sizeof(read_buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + block_size =3D ldl_be_p(&read_buf[8]); + g_assert_cmpuint(block_size, =3D=3D, 4096); + + /* Write data */ + memset(write_buf, 0xab, block_size); + ufs_send_scsi_command(ufs, 0, test_lun, write_cdb, write_buf, block_si= ze, + NULL, 0, &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + + /* Unaligned write error */ + ufs_send_scsi_command(ufs, 0, test_lun, write_cdb, write_buf, block_si= ze, + NULL, 0, &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, CHECK_CONDITION); + /* asc =3D=3D 0x21 */ + g_assert_cmpint(rsp_upiu.sr.sense_data[12], =3D=3D, 0x21); + /* ascq =3D=3D 0x04 */ + g_assert_cmpint(rsp_upiu.sr.sense_data[13], =3D=3D, 0x04); + + ufs_exit(ufs, alloc); +} + static void drive_destroy(void *path) { unlink(path); @@ -569,6 +728,19 @@ static void *ufs_blk_test_setup(GString *cmd_line, voi= d *arg) return arg; } =20 +static void *ufs_zufs_test_setup(GString *cmd_line, void *arg) +{ + char *tmp_path =3D drive_create(); + + g_string_append_printf(cmd_line, + " -blockdev file,filename=3D%s,node-name=3Ddrv2= " + "-device ufs-lu,bus=3Dufs0,drive=3Ddrv2,lun=3D2= ," + "zoned=3Don,zoned.max_open=3D%d,zoned.zone_size= =3D%d", + tmp_path, MAX_OPEN_ZONE, ZONE_SIZE); + + return arg; +} + static void ufs_register_nodes(void) { const char *arch; @@ -582,6 +754,10 @@ static void ufs_register_nodes(void) .before =3D ufs_blk_test_setup, }; =20 + QOSGraphTestOptions zufs_io_test_opts =3D { + .before =3D ufs_zufs_test_setup, + }; + add_qpci_address(&edge_opts, &(QPCIAddress){ .devfn =3D QPCI_DEVFN(4, = 0) }); =20 qos_node_create_driver("ufs", ufs_create); @@ -601,6 +777,8 @@ static void ufs_register_nodes(void) } qos_add_test("init", "ufs", ufstest_init, NULL); qos_add_test("read-write", "ufs", ufstest_read_write, &io_test_opts); + qos_add_test("zufs-init", "ufs", ufstest_zufs_init, &zufs_io_test_opts= ); + qos_add_test("zufs-write", "ufs", ufstest_zufs_write, &zufs_io_test_op= ts); } =20 libqos_init(ufs_register_nodes); --=20 2.25.1