{"id":100227,"date":"2026-09-04T07:48:56","date_gmt":"2026-09-03T23:48:56","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/100227.html"},"modified":"2026-09-04T07:48:56","modified_gmt":"2026-09-03T23:48:56","slug":"5-3-1-prime-%e7%9a%84%e4%b8%a4%e5%ba%a7%e6%a1%a5%ef%bc%9agem-%e2%86%94-dma-buf-%e6%a1%a5%e6%8e%a5%e5%9b%9e%e8%b0%83%e4%b8%8e-fd-handle-%e8%bd%ac%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/100227.html","title":{"rendered":"5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362"},"content":{"rendered":"<p>5.2 \u8282 \u5206\u6790 \u4e86dma-buf \u8fd9\u5957\u300c\u8de8\u8bbe\u5907\u7f13\u51b2\u533a\u5171\u4eab\u300d\u7684\u901a\u7528\u673a\u5236&#xff0c;\u4f46\u5b83\u59cb\u7ec8\u505c\u5728 dma-buf \u81ea\u5df1\u7684\u62bd\u8c61\u5c42\u3002\u56de\u5230 DRM\/GEM \u7684\u573a\u666f&#xff1a;\u7528\u6237\u6001\u8bbf\u95ee BO \u7684\u63a5\u53e3\u662f\u4e00\u4e2a\u8fdb\u7a0b\u5185\u7684 GEM handle&#xff08;\u4e00\u4e2a 32 \u4f4d\u6574\u6570&#xff09;&#xff0c;\u6e32\u67d3\u65f6\u7528 handle \u5f15\u7528 BO&#xff0c;\u63d0\u4ea4\u547d\u4ee4\u65f6\u7528 handle \u7d22\u5f15\u3002\u53ef handle \u53ea\u5728\u672c\u8fdb\u7a0b\u672c\u8bbe\u5907\u6709\u610f\u4e49&#xff0c;\u4e00\u65e6\u8981\u628a BO \u4ea4\u7ed9\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u3001\u53e6\u4e00\u5757 GPU&#xff0c;\u5c31\u5fc5\u987b\u6362\u6210\u80fd\u8de8\u8fdb\u7a0b\u4f20\u9012\u7684 dma-buf fd\u3002\u7136\u540e fd \u8981\u53d8\u6210importer \u8fdb\u7a0b\u4e2d\u7684 handle \u624d\u80fd\u88ab\u7528\u6237\u6001\u8bbf\u95ee\u3002<\/p>\n<p>PRIME \u5c31\u662f GEM \u4e16\u754c\u4e0e dma-buf \u4e16\u754c\u4e4b\u95f4\u7684\u53cc\u5411\u6865&#xff1a;\u5b83\u628a\u300c\u8fdb\u7a0b\u79c1\u6709\u7684 handle\u300d\u7ffb\u8bd1\u6210\u300c\u53ef\u4f20\u9012\u7684 fd\u300d&#xff08;\u5bfc\u51fa&#xff09;&#xff0c;\u53c8\u628a\u522b\u5904\u4f20\u6765\u7684\u300cfd\u300d\u7ffb\u8bd1\u56de\u300c\u672c\u8fdb\u7a0b\u7684 handle\u300d&#xff08;\u5bfc\u5165&#xff09;\u3002\u7528\u6237\u6001\u53ea\u9700\u4e24\u4e2a ioctl&#xff0c;\u5185\u6838\u5219\u7528\u4e00\u7ec4\u6865\u63a5\u56de\u8c03\u628a\u4e24\u5957\u5bf9\u8c61\u6a21\u578b\u7684\u751f\u547d\u5468\u671f\u3001\u5f15\u7528\u8ba1\u6570\u3001\u7f13\u5b58\u4e00\u4e00\u5bf9\u9f50\u3002<\/p>\n<h3>1. \u4e24\u4e2a ioctl&#xff0c;\u4e24\u5ea7\u6865<\/h3>\n<p>\u7528\u6237\u6001\u7684\u5168\u90e8\u5165\u53e3\u5c31\u662f\u4e24\u4e2a\u5bf9\u79f0\u7684 ioctl&#xff1a;<\/p>\n<table>\n<tr>ioctl\u65b9\u5411\u5185\u6838\u5165\u53e3\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>DRM_IOCTL_PRIME_HANDLE_TO_FD<\/td>\n<td>\u5bfc\u51fa<\/td>\n<td>drm_prime_handle_to_fd_ioctl \u2192 drm_gem_prime_handle_to_fd<\/td>\n<td>\u672c\u8fdb\u7a0b handle \u2192 \u53ef\u4f20\u9012\u7684 dma-buf fd<\/td>\n<\/tr>\n<tr>\n<td>DRM_IOCTL_PRIME_FD_TO_HANDLE<\/td>\n<td>\u5bfc\u5165<\/td>\n<td>drm_prime_fd_to_handle_ioctl \u2192 drm_gem_prime_fd_to_handle<\/td>\n<td>\u522b\u5904\u4f20\u6765\u7684 fd \u2192 \u672c\u8fdb\u7a0b handle<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e24\u4e2a ioctl \u90fd\u7559\u4e86\u300c\u9a71\u52a8\u53ef\u8986\u76d6\u300d\u7684\u56de\u8c03&#xff1a;\u82e5 dev-&gt;driver-&gt;prime_handle_to_fd \/ prime_fd_to_handle \u975e\u7a7a\u5219\u7528\u9a71\u52a8\u81ea\u5df1\u7684&#xff0c;\u5426\u5219\u7528 DRM \u6838\u5fc3\u7684\u9ed8\u8ba4\u5b9e\u73b0\u3002\u7edd\u5927\u591a\u6570\u9a71\u52a8\u76f4\u63a5\u7528\u9ed8\u8ba4\u7684\u3002<\/p>\n<p>  #mermaid-svg-KFoGBmistHtVvLoy{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-KFoGBmistHtVvLoy .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-KFoGBmistHtVvLoy .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-KFoGBmistHtVvLoy .error-icon{fill:#552222;}#mermaid-svg-KFoGBmistHtVvLoy .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-KFoGBmistHtVvLoy .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-KFoGBmistHtVvLoy .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-KFoGBmistHtVvLoy .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-KFoGBmistHtVvLoy .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-KFoGBmistHtVvLoy .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-KFoGBmistHtVvLoy .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-KFoGBmistHtVvLoy .marker{fill:#333333;stroke:#333333;}#mermaid-svg-KFoGBmistHtVvLoy .marker.cross{stroke:#333333;}#mermaid-svg-KFoGBmistHtVvLoy svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-KFoGBmistHtVvLoy p{margin:0;}#mermaid-svg-KFoGBmistHtVvLoy .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-KFoGBmistHtVvLoy .cluster-label text{fill:#333;}#mermaid-svg-KFoGBmistHtVvLoy .cluster-label span{color:#333;}#mermaid-svg-KFoGBmistHtVvLoy .cluster-label span p{background-color:transparent;}#mermaid-svg-KFoGBmistHtVvLoy .label text,#mermaid-svg-KFoGBmistHtVvLoy span{fill:#333;color:#333;}#mermaid-svg-KFoGBmistHtVvLoy .node rect,#mermaid-svg-KFoGBmistHtVvLoy .node circle,#mermaid-svg-KFoGBmistHtVvLoy .node ellipse,#mermaid-svg-KFoGBmistHtVvLoy .node polygon,#mermaid-svg-KFoGBmistHtVvLoy .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-KFoGBmistHtVvLoy .rough-node .label text,#mermaid-svg-KFoGBmistHtVvLoy .node .label text,#mermaid-svg-KFoGBmistHtVvLoy .image-shape .label,#mermaid-svg-KFoGBmistHtVvLoy .icon-shape .label{text-anchor:middle;}#mermaid-svg-KFoGBmistHtVvLoy .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-KFoGBmistHtVvLoy .rough-node .label,#mermaid-svg-KFoGBmistHtVvLoy .node .label,#mermaid-svg-KFoGBmistHtVvLoy .image-shape .label,#mermaid-svg-KFoGBmistHtVvLoy .icon-shape .label{text-align:center;}#mermaid-svg-KFoGBmistHtVvLoy .node.clickable{cursor:pointer;}#mermaid-svg-KFoGBmistHtVvLoy .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-KFoGBmistHtVvLoy .arrowheadPath{fill:#333333;}#mermaid-svg-KFoGBmistHtVvLoy .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-KFoGBmistHtVvLoy .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-KFoGBmistHtVvLoy .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-KFoGBmistHtVvLoy .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-KFoGBmistHtVvLoy .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-KFoGBmistHtVvLoy .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-KFoGBmistHtVvLoy .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-KFoGBmistHtVvLoy .cluster text{fill:#333;}#mermaid-svg-KFoGBmistHtVvLoy .cluster span{color:#333;}#mermaid-svg-KFoGBmistHtVvLoy div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-KFoGBmistHtVvLoy .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-KFoGBmistHtVvLoy rect.text{fill:none;stroke-width:0;}#mermaid-svg-KFoGBmistHtVvLoy .icon-shape,#mermaid-svg-KFoGBmistHtVvLoy .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-KFoGBmistHtVvLoy .icon-shape p,#mermaid-svg-KFoGBmistHtVvLoy .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-KFoGBmistHtVvLoy .icon-shape .label rect,#mermaid-svg-KFoGBmistHtVvLoy .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-KFoGBmistHtVvLoy .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-KFoGBmistHtVvLoy .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-KFoGBmistHtVvLoy :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u8fdb\u7a0b B \/ GPU-1<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u8fdb\u7a0b A \/ GPU-0<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>HANDLE_TO_FD<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>SCM_RIGHTS \u4f20\u9012 fd<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>FD_TO_HANDLE<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>GEM handle<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>dma-buf fd<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>dma-buf fd<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>GEM handle<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u540c\u4e00\u4e2a struct dma_buf\u540c\u4e00\u5757\u540e\u7aef\u5b58\u50a8<\/p>\n<p><\/span><\/p>\n<h3>2. \u5bfc\u51fa\u6865&#xff1a;handle \u2192 fd<\/h3>\n<p>drm_gem_prime_handle_to_fd() \u672c\u8eab\u53ea\u505a\u300c\u7533\u8bf7 fd \u2192 \u62ff dma_buf \u2192 \u5b89\u88c5 fd\u300d\u4e09\u6b65&#xff1a;<\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">drm_gem_prime_handle_to_fd<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">drm_device<\/span> <span class=\"token operator\">*<\/span>dev<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">drm_file<\/span> <span class=\"token operator\">*<\/span>file_priv<span class=\"token punctuation\">,<\/span><br \/>\n                               <span class=\"token class-name\">uint32_t<\/span> handle<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint32_t<\/span> flags<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token operator\">*<\/span>prime_fd<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">dma_buf<\/span> <span class=\"token operator\">*<\/span>dmabuf<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> fd <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">get_unused_fd_flags<\/span><span class=\"token punctuation\">(<\/span>flags<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>         <span class=\"token comment\">\/* 1. \u9884\u7559\u4e00\u4e2a\u7a7a fd *\/<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><br \/>\n        dmabuf <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">drm_gem_prime_handle_to_dmabuf<\/span><span class=\"token punctuation\">(<\/span>dev<span class=\"token punctuation\">,<\/span> file_priv<span class=\"token punctuation\">,<\/span> handle<span class=\"token punctuation\">,<\/span> flags<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/* 2. handle\u2192dma_buf *\/<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><br \/>\n        <span class=\"token function\">fd_install<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">,<\/span> dmabuf<span class=\"token operator\">-&gt;<\/span>file<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                <span class=\"token comment\">\/* 3. \u628a dma_buf \u7684 file \u88c5\u5230 fd \u4e0a *\/<\/span><br \/>\n        <span class=\"token operator\">*<\/span>prime_fd <span class=\"token operator\">&#061;<\/span> fd<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u771f\u6b63\u6709\u8bb2\u7a76\u7684\u662f\u7b2c 2 \u6b65 drm_gem_prime_handle_to_dmabuf()&#xff0c;\u5b83\u6309\u4e09\u79cd\u60c5\u51b5\u51b3\u5b9a dma_buf \u4ece\u54ea\u6765&#xff1a;<\/p>\n<p>        <span class=\"token comment\">\/* \u60c5\u51b5\u4e00&#xff1a;\u8fd9\u4e2a GEM \u5bf9\u8c61\u672c\u8eab\u5c31\u662f\u4ece\u522b\u5904\u5bfc\u5165\u6765\u7684 \u2192 \u590d\u7528\u539f\u59cb dma-buf *\/<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>obj<span class=\"token operator\">-&gt;<\/span>import_attach<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                dmabuf <span class=\"token operator\">&#061;<\/span> obj<span class=\"token operator\">-&gt;<\/span>import_attach<span class=\"token operator\">-&gt;<\/span>dmabuf<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token function\">get_dma_buf<\/span><span class=\"token punctuation\">(<\/span>dmabuf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token keyword\">goto<\/span> out_have_obj<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/* \u60c5\u51b5\u4e8c&#xff1a;\u4e4b\u524d\u5df2\u7ecf\u5bfc\u51fa\u8fc7 \u2192 \u590d\u7528\u7f13\u5b58\u7684 dma_buf&#xff08;\u4e0d\u91cd\u590d\u521b\u5efa&#xff09; *\/<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>obj<span class=\"token operator\">-&gt;<\/span>dma_buf<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token function\">get_dma_buf<\/span><span class=\"token punctuation\">(<\/span>obj<span class=\"token operator\">-&gt;<\/span>dma_buf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                dmabuf <span class=\"token operator\">&#061;<\/span> obj<span class=\"token operator\">-&gt;<\/span>dma_buf<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token keyword\">goto<\/span> out_have_obj<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/* \u60c5\u51b5\u4e09&#xff1a;\u7b2c\u4e00\u6b21\u5bfc\u51fa \u2192 \u771f\u6b63\u521b\u5efa\u5e76\u6ce8\u518c dma_buf *\/<\/span><br \/>\n        dmabuf <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">export_and_register_object<\/span><span class=\"token punctuation\">(<\/span>dev<span class=\"token punctuation\">,<\/span> obj<span class=\"token punctuation\">,<\/span> flags<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u4e09\u4e2a\u5206\u652f\u4fdd\u8bc1\u4e86\u4e00\u6761\u5173\u952e\u4e0d\u53d8\u91cf\u2014\u2014\u540c\u4e00\u4e2a GEM \u5bf9\u8c61\u5728\u5176\u751f\u547d\u5468\u671f\u5185\u53ea\u5bf9\u5e94\u552f\u4e00\u4e00\u4e2a dma_buf&#xff1a;<\/p>\n<ul>\n<li>\u60c5\u51b5\u4e00&#xff08;import_attach \u975e\u7a7a&#xff09;&#xff1a;\u8fd9\u5757 BO \u662f\u5bfc\u5165\u6765\u7684\u300c\u5f71\u5b50\u5bf9\u8c61\u300d&#xff0c;\u5bfc\u51fa\u5b83\u65f6\u4e0d\u80fd\u518d\u5305\u4e00\u5c42&#xff0c;\u800c\u8981\u628a\u6700\u521d\u7684\u539f\u59cb dma-buf \u539f\u6837\u4ea4\u51fa\u53bb\u2014\u2014\u5426\u5219\u4f1a\u51fa\u73b0\u300cdma-buf \u5957 GEM \u5957 dma-buf\u300d\u7684\u8352\u8c2c\u5d4c\u5957\u3002<\/li>\n<li>\u60c5\u51b5\u4e8c&#xff08;obj-&gt;dma_buf \u5df2\u7f13\u5b58&#xff09;&#xff1a;\u66fe\u7ecf\u5bfc\u51fa\u8fc7&#xff0c;\u76f4\u63a5\u590d\u7528\u5e76 get_dma_buf \u52a0\u5f15\u7528&#xff0c;\u907f\u514d\u540c\u4e00 BO \u4ea7\u751f\u4e24\u4e2a\u4e92\u4e0d\u76f8\u5e72\u7684 dma_buf\u3002<\/li>\n<li>\u60c5\u51b5\u4e09&#xff1a;\u9996\u6b21\u5bfc\u51fa\u624d\u8d70 export_and_register_object&#xff0c;\u5185\u90e8\u6700\u7ec8\u8c03 obj-&gt;funcs-&gt;export&#xff08;\u9ed8\u8ba4\u662f drm_gem_prime_export&#xff09;\u771f\u6b63\u521b\u5efa dma_buf&#xff0c;\u5e76\u628a\u5b83\u7f13\u5b58\u8fdb obj-&gt;dma_buf\u3002<\/li>\n<\/ul>\n<p>drm_gem_prime_export() \u5c31\u662f\u90a3\u4e2a\u300c\u771f\u6b63\u521b\u5efa\u300d\u7684\u9ed8\u8ba4\u5b9e\u73b0&#xff0c;\u5b83\u628a GEM \u5bf9\u8c61\u586b\u8fdb\u6807\u51c6\u7684 dma_buf_export_info&#xff1a;<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">dma_buf<\/span> <span class=\"token operator\">*<\/span><span class=\"token function\">drm_gem_prime_export<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">drm_gem_object<\/span> <span class=\"token operator\">*<\/span>obj<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> flags<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">dma_buf_export_info<\/span> exp_info <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token punctuation\">.<\/span>exp_name <span class=\"token operator\">&#061;<\/span> KBUILD_MODNAME<span class=\"token punctuation\">,<\/span><br \/>\n                <span class=\"token punctuation\">.<\/span>ops   <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&amp;<\/span>drm_gem_prime_dmabuf_ops<span class=\"token punctuation\">,<\/span>   <span class=\"token comment\">\/* GEM \u4e13\u7528\u7684 dma_buf_ops *\/<\/span><br \/>\n                <span class=\"token punctuation\">.<\/span>size  <span class=\"token operator\">&#061;<\/span> obj<span class=\"token operator\">-&gt;<\/span>size<span class=\"token punctuation\">,<\/span><br \/>\n                <span class=\"token punctuation\">.<\/span>flags <span class=\"token operator\">&#061;<\/span> flags<span class=\"token punctuation\">,<\/span><br \/>\n                <span class=\"token punctuation\">.<\/span>priv  <span class=\"token operator\">&#061;<\/span> obj<span class=\"token punctuation\">,<\/span>                         <span class=\"token comment\">\/* dma_buf-&gt;priv \u6307\u56de GEM \u5bf9\u8c61 *\/<\/span><br \/>\n                <span class=\"token punctuation\">.<\/span>resv  <span class=\"token operator\">&#061;<\/span> obj<span class=\"token operator\">-&gt;<\/span>resv<span class=\"token punctuation\">,<\/span>                   <span class=\"token comment\">\/* \u5171\u7528\u540c\u4e00\u4e2a reservation object *\/<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token function\">drm_gem_dmabuf_export<\/span><span class=\"token punctuation\">(<\/span>dev<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>exp_info<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4e24\u4e2a\u5b57\u6bb5\u503c\u5f97\u8bb0\u4f4f&#xff1a;priv &#061; obj \u5efa\u7acb\u4e86\u300cdma_buf \u2192 GEM \u5bf9\u8c61\u300d\u7684\u53cd\u5411\u6307\u9488&#xff08;\u524d\u51e0\u8282 amdgpu \u91cc gem_to_amdgpu_bo(dma_buf-&gt;priv) \u5c31\u9760\u5b83&#xff09;&#xff1b;resv &#061; obj-&gt;resv \u8ba9 dma-buf \u4e0e GEM \u5bf9\u8c61\u5171\u4eab\u540c\u4e00\u628a\u540c\u6b65\u9501\u4e0e fence \u5bb9\u5668&#xff0c;\u8fd9\u662f\u9690\u5f0f\u540c\u6b65&#xff08;6.3&#xff09;\u80fd\u8de8\u8bbe\u5907\u751f\u6548\u7684\u6839\u57fa\u3002<\/p>\n<p>ops &#061; &amp;drm_gem_prime_dmabuf_ops \u5219\u662f\u8fd9\u5ea7\u6865\u7684\u53e6\u4e00\u534a\u2014\u2014\u5b83\u628a dma-buf \u7684\u901a\u7528\u56de\u8c03\u8f6c\u63a5\u5230 GEM \u7684 drm_gem_object_funcs&#xff1a;<\/p>\n<table>\n<tr>dma_buf_ops \u56de\u8c03GEM \u6865\u63a5\u5b9e\u73b0\u6700\u7ec8\u59d4\u6d3e\u5230<\/tr>\n<tbody>\n<tr>\n<td>attach<\/td>\n<td>drm_gem_map_attach<\/td>\n<td>obj-&gt;funcs-&gt;pin<\/td>\n<\/tr>\n<tr>\n<td>map_dma_buf<\/td>\n<td>drm_gem_map_dma_buf<\/td>\n<td>obj-&gt;funcs-&gt;get_sg_table<\/td>\n<\/tr>\n<tr>\n<td>unmap_dma_buf<\/td>\n<td>drm_gem_unmap_dma_buf<\/td>\n<td>\u2014\u2014<\/td>\n<\/tr>\n<tr>\n<td>release<\/td>\n<td>drm_gem_dmabuf_release<\/td>\n<td>obj \u5f15\u7528\u91ca\u653e<\/td>\n<\/tr>\n<tr>\n<td>mmap<\/td>\n<td>drm_gem_dmabuf_mmap<\/td>\n<td>obj-&gt;funcs-&gt;mmap<\/td>\n<\/tr>\n<tr>\n<td>vmap \/ vunmap<\/td>\n<td>drm_gem_dmabuf_vmap<\/td>\n<td>obj-&gt;funcs-&gt;vmap<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>dma-buf core \u901a\u8fc7 drm_gem_prime_dmabuf_ops \u6572\u95e8&#xff0c;\u6700\u7ec8\u90fd\u843d\u5230\u67d0\u4e2a drm_gem_object_funcs \u4e0a\u3002\u8fd9\u4e5f\u89e3\u91ca\u4e86 5.2.4 \u91cc amdgpu \u7684 map_dma_buf \u4e3a\u4f55\u6700\u7ec8\u4f1a\u8d70\u5230 GEM \u7684 get_sg_table\u2014\u2014\u4e2d\u95f4\u6b63\u662f\u8fd9\u5f20\u8f6c\u63a5\u8868\u5728\u7275\u7ebf\u3002\u82e5\u9a71\u52a8\u7684 get_sg_table \u672a\u5b9e\u73b0&#xff0c;drm_gem_map_attach \u4f1a\u76f4\u63a5\u8fd4\u56de -ENOSYS&#xff0c;\u5373\u62d2\u7edd\u5bfc\u51fa\u5230\u522b\u7684\u8bbe\u5907\u3002<\/p>\n<h3>3. \u5bfc\u5165\u6865&#xff1a;fd \u2192 handle<\/h3>\n<p>\u53cd\u65b9\u5411\u7684 drm_gem_prime_fd_to_handle() \u8981\u628a\u4e00\u679a\u964c\u751f\u7684 fd \u53d8\u6210\u672c\u8fdb\u7a0b\u7684 handle&#xff1a;<\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">drm_gem_prime_fd_to_handle<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">drm_device<\/span> <span class=\"token operator\">*<\/span>dev<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">drm_file<\/span> <span class=\"token operator\">*<\/span>file_priv<span class=\"token punctuation\">,<\/span><br \/>\n                               <span class=\"token keyword\">int<\/span> prime_fd<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint32_t<\/span> <span class=\"token operator\">*<\/span>handle<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">dma_buf<\/span> <span class=\"token operator\">*<\/span>dma_buf <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">dma_buf_get<\/span><span class=\"token punctuation\">(<\/span>prime_fd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/* fd \u2192 struct dma_buf *\/<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><br \/>\n        <span class=\"token comment\">\/* 1. \u67e5\u672c\u8fdb\u7a0b\u7684\u5bfc\u5165\u7f13\u5b58&#xff1a;\u8fd9\u4e2a dma_buf \u4e4b\u524d\u5bfc\u5165\u8fc7\u5417&#xff1f; *\/<\/span><br \/>\n        ret <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">drm_prime_lookup_buf_handle<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>file_priv<span class=\"token operator\">-&gt;<\/span>prime<span class=\"token punctuation\">,<\/span> dma_buf<span class=\"token punctuation\">,<\/span> handle<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>ret <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">goto<\/span> out_put<span class=\"token punctuation\">;<\/span>                              <span class=\"token comment\">\/* \u547d\u4e2d \u2192 \u590d\u7528\u65e7 handle *\/<\/span><\/p>\n<p>        <span class=\"token comment\">\/* 2. \u6ca1\u89c1\u8fc7 \u2192 \u8c03\u9a71\u52a8\u7684 import \u56de\u8c03&#xff0c;\u9020\u4e00\u4e2a GEM \u5bf9\u8c61 *\/<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>dev<span class=\"token operator\">-&gt;<\/span>driver<span class=\"token operator\">-&gt;<\/span>gem_prime_import<span class=\"token punctuation\">)<\/span><br \/>\n                obj <span class=\"token operator\">&#061;<\/span> dev<span class=\"token operator\">-&gt;<\/span>driver<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">gem_prime_import<\/span><span class=\"token punctuation\">(<\/span>dev<span class=\"token punctuation\">,<\/span> dma_buf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">else<\/span><br \/>\n                obj <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">drm_gem_prime_import<\/span><span class=\"token punctuation\">(<\/span>dev<span class=\"token punctuation\">,<\/span> dma_buf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><br \/>\n        <span class=\"token comment\">\/* 3. \u5efa\u7acb GEM \u5bf9\u8c61 \u2194 dma_buf \u7684\u53cc\u5411\u5f15\u7528 *\/<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>obj<span class=\"token operator\">-&gt;<\/span>dma_buf<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                obj<span class=\"token operator\">-&gt;<\/span>dma_buf <span class=\"token operator\">&#061;<\/span> dma_buf<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token function\">get_dma_buf<\/span><span class=\"token punctuation\">(<\/span>dma_buf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/* 4. \u4e3a\u8fd9\u4e2a GEM \u5bf9\u8c61\u5206\u914d\u672c\u8fdb\u7a0b handle&#xff0c;\u5e76\u5199\u5165\u7f13\u5b58 *\/<\/span><br \/>\n        ret <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">drm_gem_handle_create_tail<\/span><span class=\"token punctuation\">(<\/span>file_priv<span class=\"token punctuation\">,<\/span> obj<span class=\"token punctuation\">,<\/span> handle<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        ret <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">drm_prime_add_buf_handle<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>file_priv<span class=\"token operator\">-&gt;<\/span>prime<span class=\"token punctuation\">,<\/span> dma_buf<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">*<\/span>handle<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5173\u952e\u4ecd\u662f\u7f13\u5b58 &#043; \u552f\u4e00\u6027&#xff1a;file_priv-&gt;prime \u662f\u6bcf\u4e2a DRM file \u79c1\u6709\u7684\u53cc\u5411\u7f13\u5b58&#xff08;dma_buf \u2194 handle&#xff09;\u3002\u540c\u4e00\u4e2a dma_buf \u5728\u540c\u4e00\u8fdb\u7a0b\u88ab\u5bfc\u5165\u4e24\u6b21&#xff0c;\u7b2c 1 \u6b65\u5c31\u4f1a\u547d\u4e2d\u7f13\u5b58\u8fd4\u56de\u540c\u4e00\u4e2a handle\u2014\u2014\u4fdd\u8bc1\u300c\u4e00\u5757\u5171\u4eab buffer \u5728\u4e00\u4e2a\u8fdb\u7a0b\u91cc\u53ea\u6709\u4e00\u4e2a handle\u300d\u3002<\/p>\n<p>\u7b2c 2 \u6b65\u7684 drm_gem_prime_import() \u8f6c\u8c03\u6838\u5fc3\u7684 drm_gem_prime_import_dev()&#xff0c;\u5b83\u624d\u662f\u771f\u6b63\u300c\u628a dma_buf \u53d8\u6210 GEM \u5bf9\u8c61\u300d\u7684\u5730\u65b9&#xff0c;\u5176\u4e2d\u85cf\u7740\u4e00\u4e2a\u91cd\u8981\u4f18\u5316&#xff1a;<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">drm_gem_object<\/span> <span class=\"token operator\">*<\/span><span class=\"token function\">drm_gem_prime_import_dev<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">drm_device<\/span> <span class=\"token operator\">*<\/span>dev<span class=\"token punctuation\">,<\/span><br \/>\n                <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">dma_buf<\/span> <span class=\"token operator\">*<\/span>dma_buf<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">device<\/span> <span class=\"token operator\">*<\/span>attach_dev<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/* \u81ea\u5bfc\u5165\u4f18\u5316&#xff1a;\u5982\u679c\u8fd9\u4e2a dma_buf \u6b63\u662f\u672c dev \u81ea\u5df1\u5bfc\u51fa\u7684&#xff0c;<br \/>\n         * \u4e0d\u5fc5 attach&#xff0c;\u76f4\u63a5\u7ed9\u539f GEM \u5bf9\u8c61\u52a0\u5f15\u7528\u5373\u53ef *\/<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">drm_gem_is_prime_exported_dma_buf<\/span><span class=\"token punctuation\">(<\/span>dev<span class=\"token punctuation\">,<\/span> dma_buf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                obj <span class=\"token operator\">&#061;<\/span> dma_buf<span class=\"token operator\">-&gt;<\/span>priv<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token function\">drm_gem_object_get<\/span><span class=\"token punctuation\">(<\/span>obj<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token keyword\">return<\/span> obj<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>dev<span class=\"token operator\">-&gt;<\/span>driver<span class=\"token operator\">-&gt;<\/span>gem_prime_import_sg_table<span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">return<\/span> <span class=\"token function\">ERR_PTR<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8211;<\/span>EINVAL<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/* \u6b63\u5e38\u8def\u5f84&#xff1a;attach \u2192 map \u62ff sg_table \u2192 \u8ba9\u9a71\u52a8\u636e\u6b64\u9020 GEM \u5bf9\u8c61 *\/<\/span><br \/>\n        attach <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">dma_buf_attach<\/span><span class=\"token punctuation\">(<\/span>dma_buf<span class=\"token punctuation\">,<\/span> attach_dev<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">get_dma_buf<\/span><span class=\"token punctuation\">(<\/span>dma_buf<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        sgt <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">dma_buf_map_attachment_unlocked<\/span><span class=\"token punctuation\">(<\/span>attach<span class=\"token punctuation\">,<\/span> DMA_BIDIRECTIONAL<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        obj <span class=\"token operator\">&#061;<\/span> dev<span class=\"token operator\">-&gt;<\/span>driver<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">gem_prime_import_sg_table<\/span><span class=\"token punctuation\">(<\/span>dev<span class=\"token punctuation\">,<\/span> attach<span class=\"token punctuation\">,<\/span> sgt<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/* \u9a71\u52a8\u56de\u8c03 *\/<\/span><\/p>\n<p>        obj<span class=\"token operator\">-&gt;<\/span>import_attach <span class=\"token operator\">&#061;<\/span> attach<span class=\"token punctuation\">;<\/span>      <span class=\"token comment\">\/* \u8bb0\u4f4f\u300c\u6211\u662f\u5bfc\u5165\u6765\u7684\u300d\u53ca\u5176 attachment *\/<\/span><br \/>\n        obj<span class=\"token operator\">-&gt;<\/span>resv <span class=\"token operator\">&#061;<\/span> dma_buf<span class=\"token operator\">-&gt;<\/span>resv<span class=\"token punctuation\">;<\/span>        <span class=\"token comment\">\/* \u5171\u7528\u6e90 dma-buf \u7684 resv \u2192 \u540c\u6b65\u80fd\u8de8\u8bbe\u5907\u751f\u6548 *\/<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> obj<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4e09\u4e2a\u8981\u70b9\u4e32\u8d77\u4e86\u524d\u51e0\u8282&#xff1a;<\/p>\n<li>\u81ea\u5bfc\u5165\u4f18\u5316&#xff08;drm_gem_is_prime_exported_dma_buf&#xff09;&#xff1a;\u628a\u81ea\u5df1\u5bfc\u51fa\u7684 dma-buf \u518d\u5bfc\u5165\u56de\u6765&#xff0c;\u53ea\u589e\u52a0 GEM \u5bf9\u8c61\u5f15\u7528\u3001\u4e0d\u589e\u52a0 dma-buf \u7684 f_count\u2014\u2014\u907f\u514d\u81ea\u5df1 attach \u81ea\u5df1\u7684\u75c5\u6001\u5faa\u73af\u3002\u8fd9\u4e0e\u7b2c 2 \u8282\u5bfc\u51fa\u4fa7\u300c\u60c5\u51b5\u4e00\u300d\u4e92\u4e3a\u955c\u50cf\u3002<\/li>\n<li>attach &#043; map \u590d\u7528 5.2.4 \u7684\u673a\u5236&#xff1a;\u5bfc\u5165\u6865\u5e76\u4e0d\u81ea\u5df1\u53d1\u660e\u8f6e\u5b50&#xff0c;\u800c\u662f\u8001\u8001\u5b9e\u5b9e\u8d70 dma_buf_attach \u2192 dma_buf_map_attachment \u62ff\u5230 sg_table&#xff0c;\u518d\u4ea4\u7ed9\u9a71\u52a8\u7684 gem_prime_import_sg_table \u636e\u6b64\u6784\u9020\u4e00\u4e2a\u300c\u5f71\u5b50 GEM \u5bf9\u8c61\u300d\u3002<\/li>\n<li>import_attach &#043; \u5171\u7528 resv&#xff1a;obj-&gt;import_attach \u6807\u8bb0\u8fd9\u662f\u5bfc\u5165\u5bf9\u8c61&#xff08;\u7b2c 2 \u8282\u5bfc\u51fa\u4fa7\u636e\u6b64\u590d\u7528\u539f\u59cb dma-buf&#xff09;&#xff1b;obj-&gt;resv &#061; dma_buf-&gt;resv \u8ba9\u5f71\u5b50\u5bf9\u8c61\u4e0e\u6e90 buffer \u5171\u4eab fence \u5bb9\u5668\u2014\u2014\u8fd9\u662f\u8de8\u8bbe\u5907\u9690\u5f0f\u540c\u6b65&#xff08;6.3&#xff09;\u6210\u7acb\u7684\u524d\u63d0\u3002\u9a71\u52a8\u8fd8\u987b\u5728\u5176 free \u56de\u8c03\u91cc\u8c03 drm_prime_gem_destroy() \u6536\u5c3e attach\u3002<\/li>\n<h3>4. \u4e00\u5f20\u5168\u666f\u56fe&#xff1a;\u4e24\u5957\u5bf9\u8c61\u6a21\u578b\u5982\u4f55\u5bf9\u9f50<\/h3>\n<p>\u628a\u5bfc\u51fa\u4e0e\u5bfc\u5165\u5408\u8d77\u6765\u770b&#xff0c;PRIME \u7684\u672c\u8d28\u662f\u7ef4\u62a4\u300cGEM \u5bf9\u8c61 \u2194 dma_buf\u300d\u7684\u4e00\u4e00\u5bf9\u5e94\u4e0e\u5f15\u7528\u8ba1\u6570&#xff1a;<\/p>\n<p>  #mermaid-svg-hUdqGAY787DTr4qE{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-hUdqGAY787DTr4qE .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-hUdqGAY787DTr4qE .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-hUdqGAY787DTr4qE .error-icon{fill:#552222;}#mermaid-svg-hUdqGAY787DTr4qE .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-hUdqGAY787DTr4qE .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-hUdqGAY787DTr4qE .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-hUdqGAY787DTr4qE .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-hUdqGAY787DTr4qE .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-hUdqGAY787DTr4qE .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-hUdqGAY787DTr4qE .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-hUdqGAY787DTr4qE .marker{fill:#333333;stroke:#333333;}#mermaid-svg-hUdqGAY787DTr4qE .marker.cross{stroke:#333333;}#mermaid-svg-hUdqGAY787DTr4qE svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-hUdqGAY787DTr4qE p{margin:0;}#mermaid-svg-hUdqGAY787DTr4qE .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-hUdqGAY787DTr4qE .cluster-label text{fill:#333;}#mermaid-svg-hUdqGAY787DTr4qE .cluster-label span{color:#333;}#mermaid-svg-hUdqGAY787DTr4qE .cluster-label span p{background-color:transparent;}#mermaid-svg-hUdqGAY787DTr4qE .label text,#mermaid-svg-hUdqGAY787DTr4qE span{fill:#333;color:#333;}#mermaid-svg-hUdqGAY787DTr4qE .node rect,#mermaid-svg-hUdqGAY787DTr4qE .node circle,#mermaid-svg-hUdqGAY787DTr4qE .node ellipse,#mermaid-svg-hUdqGAY787DTr4qE .node polygon,#mermaid-svg-hUdqGAY787DTr4qE .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-hUdqGAY787DTr4qE .rough-node .label text,#mermaid-svg-hUdqGAY787DTr4qE .node .label text,#mermaid-svg-hUdqGAY787DTr4qE .image-shape .label,#mermaid-svg-hUdqGAY787DTr4qE .icon-shape .label{text-anchor:middle;}#mermaid-svg-hUdqGAY787DTr4qE .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-hUdqGAY787DTr4qE .rough-node .label,#mermaid-svg-hUdqGAY787DTr4qE .node .label,#mermaid-svg-hUdqGAY787DTr4qE .image-shape .label,#mermaid-svg-hUdqGAY787DTr4qE .icon-shape .label{text-align:center;}#mermaid-svg-hUdqGAY787DTr4qE .node.clickable{cursor:pointer;}#mermaid-svg-hUdqGAY787DTr4qE .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-hUdqGAY787DTr4qE .arrowheadPath{fill:#333333;}#mermaid-svg-hUdqGAY787DTr4qE .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-hUdqGAY787DTr4qE .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-hUdqGAY787DTr4qE .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-hUdqGAY787DTr4qE .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-hUdqGAY787DTr4qE .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-hUdqGAY787DTr4qE .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-hUdqGAY787DTr4qE .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-hUdqGAY787DTr4qE .cluster text{fill:#333;}#mermaid-svg-hUdqGAY787DTr4qE .cluster span{color:#333;}#mermaid-svg-hUdqGAY787DTr4qE div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-hUdqGAY787DTr4qE .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-hUdqGAY787DTr4qE rect.text{fill:none;stroke-width:0;}#mermaid-svg-hUdqGAY787DTr4qE .icon-shape,#mermaid-svg-hUdqGAY787DTr4qE .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-hUdqGAY787DTr4qE .icon-shape p,#mermaid-svg-hUdqGAY787DTr4qE .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-hUdqGAY787DTr4qE .icon-shape .label rect,#mermaid-svg-hUdqGAY787DTr4qE .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-hUdqGAY787DTr4qE .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-hUdqGAY787DTr4qE .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-hUdqGAY787DTr4qE :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>dma-buf \u4e16\u754c<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>GEM \u4e16\u754c<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>export: funcs-&gt;export \/ drm_gem_prime_export<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>import: gem_prime_import_sg_table<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>handle \u2194 dma_buf \u7f13\u5b58&#xff08;file_priv-&gt;prime&#xff09;<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>fd \u2194 handle<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>drm_gem_objectobj-&gt;dma_buf&#xff08;\u7f13\u5b58&#xff09;obj-&gt;import_attach&#xff08;\u82e5\u5bfc\u5165&#xff09;obj-&gt;resv<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>struct dma_bufdma_buf-&gt;priv &#061; objdma_buf-&gt;ops &#061; drm_gem_prime_dmabuf_opsdma_buf-&gt;resv &#061; obj-&gt;resv<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u8fdb\u7a0b\u5185 handle<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u8de8\u8fdb\u7a0b fd<\/p>\n<p><\/span><\/p>\n<ul>\n<li>priv \/ dma_buf \u4e92\u6307&#xff1a;dma_buf \u7528 priv \u6307\u56de GEM \u5bf9\u8c61&#xff0c;GEM \u5bf9\u8c61\u7528 dma_buf \u7f13\u5b58\u53cd\u5411\u5f15\u7528&#xff0c;\u4e8c\u8005\u4e00\u4e00\u5bf9\u5e94\u3002<\/li>\n<li>resv \u5171\u7528&#xff1a;\u5bfc\u51fa\u65f6 dma_buf-&gt;resv &#061; obj-&gt;resv&#xff0c;\u5bfc\u5165\u65f6 obj-&gt;resv &#061; dma_buf-&gt;resv&#xff0c;\u6700\u7ec8\u8de8\u8bbe\u5907\u7684\u4e24\u4e2a GEM \u5f71\u5b50\u5bf9\u8c61\u5171\u4eab\u540c\u4e00\u4e2a dma_resv\u2014\u2014\u540c\u6b65\u8bed\u4e49\u5f97\u4ee5\u8d2f\u901a\u3002<\/li>\n<li>\u4e24\u7ea7\u7f13\u5b58&#xff1a;file_priv-&gt;prime \u7ba1\u300cfd\/dma_buf \u2194 handle\u300d&#xff0c;obj-&gt;dma_buf \u7ba1\u300cGEM \u5bf9\u8c61 \u2194 dma_buf\u300d&#xff0c;\u5171\u540c\u4fdd\u8bc1\u4efb\u4f55\u4e00\u5757\u5171\u4eab buffer \u5728\u4efb\u4e00\u8fdb\u7a0b\u3001\u4efb\u4e00\u65b9\u5411\u90fd\u4e0d\u4f1a\u5206\u88c2\u51fa\u591a\u4e2a\u526f\u672c\u3002<\/li>\n<\/ul>\n<h3>5. \u5c0f\u7ed3\u4e0e\u5ef6\u4f38<\/h3>\n<li>PRIME \u662f GEM \u4e0e dma-buf \u4e4b\u95f4\u7684\u53cc\u5411\u6865&#xff1a;HANDLE_TO_FD \u5bfc\u51fa\u3001FD_TO_HANDLE \u5bfc\u5165&#xff0c;\u628a\u300c\u8fdb\u7a0b\u79c1\u6709 handle\u300d\u4e0e\u300c\u53ef\u4f20\u9012 fd\u300d\u4e92\u76f8\u7ffb\u8bd1\u3002<\/li>\n<li>drm_gem_prime_dmabuf_ops \u662f\u8f6c\u63a5\u8868&#xff1a;dma-buf \u7684\u901a\u7528\u56de\u8c03&#xff08;attach\/map\/mmap\/vmap&#xff09;\u7ecf\u5b83\u7edf\u4e00\u843d\u5230 GEM \u7684 drm_gem_object_funcs&#xff0c;map_dma_buf \u6700\u7ec8\u59d4\u6d3e get_sg_table\u2014\u2014\u8fd9\u6b63\u662f 5.2.4 amdgpu \u90a3\u6761\u56de\u8c03\u94fe\u7684\u4e2d\u67a2\u3002<\/li>\n<li>\u552f\u4e00\u6027\u4e0e\u5f15\u7528\u8ba1\u6570\u662f\u7075\u9b42&#xff1a;obj-&gt;dma_buf \u7f13\u5b58\u3001import_attach \u590d\u7528\u3001file_priv-&gt;prime \u53cc\u5411\u7f13\u5b58\u3001\u81ea\u5bfc\u5165\u4f18\u5316\u3001\u5171\u7528 resv&#xff0c;\u4e94\u6761\u673a\u5236\u5171\u540c\u4fdd\u8bc1\u300c\u4e00\u5757 buffer \u5728\u4e00\u4e2a\u8fdb\u7a0b\u91cc\u53ea\u6709\u4e00\u4e2a handle\u3001\u4e00\u4e2a GEM \u5bf9\u8c61\u53ea\u5bf9\u5e94\u4e00\u4e2a dma_buf\u300d\u3002<\/li>\n<p>\u5230\u8fd9\u91cc&#xff0c;PRIME \u7684\u6838\u5fc3\u6865\u63a5\u5df2\u7ecf\u6e05\u6670&#xff0c;\u4f46\u8fd8\u6709\u4e00\u4e2a\u5b9e\u9645\u95ee\u9898&#xff1a;gem_prime_import_sg_table\u3001get_sg_table\u3001pin\/unpin \u8fd9\u4e9b\u56de\u8c03&#xff0c;\u666e\u901a\u9a71\u52a8\u8981\u4e0d\u8981\u6bcf\u4e2a\u90fd\u81ea\u5df1\u5199\u4e00\u904d&#xff1f;\u5bf9\u5927\u91cf\u57fa\u4e8e\u7cfb\u7edf\u5185\u5b58\u7684\u7b80\u5355\u9a71\u52a8&#xff0c;DRM \u63d0\u4f9b\u4e86\u5f00\u7bb1\u5373\u7528\u7684 GEM shmem helper&#xff0c;\u628a\u8fd9\u5957\u5171\u4eab\u8def\u5f84\u5168\u90e8\u5b9e\u73b0\u597d\u4e86\u3002\u8fd9\u6b63\u662f [5.3.2 GEM shmem helper \u7684\u5171\u4eab\u8def\u5f84] \u7684\u4e3b\u9898\u3002<\/p>\n<p>\u76f8\u5173\u9605\u8bfb&#xff1a;dma-buf \u7684 attach\/map \u673a\u5236\u89c1 5.2.4&#xff1b;get_sg_table \/ pin \/ unpin \u7b49 GEM \u56de\u8c03\u7684\u8bed\u4e49\u89c1 gem_object_funcs.md&#xff1b;\u5171\u7528 resv \u5e26\u6765\u7684\u9690\u5f0f\u540c\u6b65\u89c1 6.3 dma_resv\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>5.2 \u8282 \u5206\u6790 \u4e86dma-buf \u8fd9\u5957\u300c\u8de8\u8bbe\u5907\u7f13\u51b2\u533a\u5171\u4eab\u300d\u7684\u901a\u7528\u673a\u5236&#xff0c;\u4f46\u5b83\u59cb\u7ec8\u505c\u5728 dma-buf \u81ea\u5df1\u7684\u62bd\u8c61\u5c42\u3002\u56de\u5230 DRM\/GEM \u7684\u573a\u666f&#xff1a;\u7528\u6237\u6001\u8bbf\u95ee BO \u7684\u63a5\u53e3\u662f\u4e00\u4e2a\u8fdb\u7a0b\u5185\u7684 GEM handle&#xff08;\u4e00\u4e2a 32 \u4f4d\u6574\u6570&#xff09;&#xff0c;\u6e32\u67d3\u65f6\u7528 handle \u5f15\u7528 BO&#xff0c;\u63d0\u4ea4\u547d\u4ee4\u65f6\u7528 handle \u7d22\u5f15\u3002\u53ef handle \u53ea\u5728\u672c\u8fdb\u7a0b\u672c\u8bbe\u5907\u6709\u610f\u4e49&#xff0c;\u4e00\u65e6\u8981\u628a BO \u4ea4\u7ed9\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u3001\u53e6\u4e00\u5757 <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11470,11471,11469],"topic":[],"class_list":["post-100227","post","type-post","status-publish","format-standard","hentry","category-server","tag-fd2h","tag-h2fd","tag-prime"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/100227.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"5.2 \u8282 \u5206\u6790 \u4e86dma-buf \u8fd9\u5957\u300c\u8de8\u8bbe\u5907\u7f13\u51b2\u533a\u5171\u4eab\u300d\u7684\u901a\u7528\u673a\u5236&#xff0c;\u4f46\u5b83\u59cb\u7ec8\u505c\u5728 dma-buf \u81ea\u5df1\u7684\u62bd\u8c61\u5c42\u3002\u56de\u5230 DRM\/GEM \u7684\u573a\u666f&#xff1a;\u7528\u6237\u6001\u8bbf\u95ee BO \u7684\u63a5\u53e3\u662f\u4e00\u4e2a\u8fdb\u7a0b\u5185\u7684 GEM handle&#xff08;\u4e00\u4e2a 32 \u4f4d\u6574\u6570&#xff09;&#xff0c;\u6e32\u67d3\u65f6\u7528 handle \u5f15\u7528 BO&#xff0c;\u63d0\u4ea4\u547d\u4ee4\u65f6\u7528 handle \u7d22\u5f15\u3002\u53ef handle \u53ea\u5728\u672c\u8fdb\u7a0b\u672c\u8bbe\u5907\u6709\u610f\u4e49&#xff0c;\u4e00\u65e6\u8981\u628a BO \u4ea4\u7ed9\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u3001\u53e6\u4e00\u5757\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/100227.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-03T23:48:56+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/100227.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/100227.html\",\"name\":\"5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-03T23:48:56+00:00\",\"dateModified\":\"2026-09-03T23:48:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/100227.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/100227.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/100227.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/100227.html","og_locale":"zh_CN","og_type":"article","og_title":"5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"5.2 \u8282 \u5206\u6790 \u4e86dma-buf \u8fd9\u5957\u300c\u8de8\u8bbe\u5907\u7f13\u51b2\u533a\u5171\u4eab\u300d\u7684\u901a\u7528\u673a\u5236&#xff0c;\u4f46\u5b83\u59cb\u7ec8\u505c\u5728 dma-buf \u81ea\u5df1\u7684\u62bd\u8c61\u5c42\u3002\u56de\u5230 DRM\/GEM \u7684\u573a\u666f&#xff1a;\u7528\u6237\u6001\u8bbf\u95ee BO \u7684\u63a5\u53e3\u662f\u4e00\u4e2a\u8fdb\u7a0b\u5185\u7684 GEM handle&#xff08;\u4e00\u4e2a 32 \u4f4d\u6574\u6570&#xff09;&#xff0c;\u6e32\u67d3\u65f6\u7528 handle \u5f15\u7528 BO&#xff0c;\u63d0\u4ea4\u547d\u4ee4\u65f6\u7528 handle \u7d22\u5f15\u3002\u53ef handle \u53ea\u5728\u672c\u8fdb\u7a0b\u672c\u8bbe\u5907\u6709\u610f\u4e49&#xff0c;\u4e00\u65e6\u8981\u628a BO \u4ea4\u7ed9\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u3001\u53e6\u4e00\u5757","og_url":"https:\/\/www.wsisp.com\/helps\/100227.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-03T23:48:56+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/100227.html","url":"https:\/\/www.wsisp.com\/helps\/100227.html","name":"5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-03T23:48:56+00:00","dateModified":"2026-09-03T23:48:56+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/100227.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/100227.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/100227.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"5.3.1 PRIME \u7684\u4e24\u5ea7\u6865\uff1aGEM \u2194 dma-buf \u6865\u63a5\u56de\u8c03\u4e0e fd\/handle \u8f6c\u6362"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/100227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=100227"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/100227\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=100227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=100227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=100227"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=100227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}